-
Notifications
You must be signed in to change notification settings - Fork 374
Add lazy Namespace storage client #4257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
buildkate
wants to merge
15
commits into
main
Choose a base branch
from
A-1435-namespace-storage-api-phase-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
45e4676
Add lazy Namespace storage client
ampagent 81e3f36
Ignore unlicensed Namespace generated modules
ampagent bbc105d
Replace NSC CLI transfers with storage API
ampagent 4568939
Fix Namespace storage lint errors
ampagent 9d00a2e
Document Namespace SDK version pin
ampagent f47047f
Wire Namespace client into cache commands
ampagent cc7cf3f
Use NSC naming for storage client
ampagent 54a25d7
Retry transient NSC cache downloads
ampagent 19a6fd9
Retry HTTP2 stream resets in NSC downloads
ampagent a24f28a
Recognize net HTTP2 stream reset errors
ampagent 625c6a2
Harden NSC cache download handling
ampagent 38e34f5
Retry transient NSC download statuses
ampagent 105c227
Treat NSC download 404 as cache miss
ampagent fb8d7db
Limit NSC whole-file download attempts
ampagent 9488a06
Tidy dependencies after rebase
ampagent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,41 @@ import ( | |
| "testing" | ||
| ) | ||
|
|
||
| func TestValidateFilePath(t *testing.T) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly to file.go, all these tests were just moved from nsc_test.go to here. |
||
| tests := []struct { | ||
| name string | ||
| filePath string | ||
| wantError string | ||
| }{ | ||
| {name: "valid simple path", filePath: "test.txt"}, | ||
| {name: "valid relative path", filePath: "dir/subdir/file.txt"}, | ||
| {name: "valid absolute path", filePath: "/tmp/test.txt"}, | ||
| {name: "empty path", wantError: "file path cannot be empty"}, | ||
| {name: "path with semicolon", filePath: "file;rm -rf /", wantError: "file path contains potentially dangerous character: ;"}, | ||
| {name: "path with ampersand", filePath: "file&malicious", wantError: "file path contains potentially dangerous character: &"}, | ||
| {name: "path with pipe", filePath: "file|cat /etc/passwd", wantError: "file path contains potentially dangerous character: |"}, | ||
| {name: "path with backtick", filePath: "file`whoami`", wantError: "file path contains potentially dangerous character: `"}, | ||
| {name: "path with dollar sign", filePath: "file$(whoami)", wantError: "file path contains potentially dangerous character: $"}, | ||
| {name: "path traversal attempt", filePath: "../../../etc/passwd", wantError: "file path contains path traversal sequence"}, | ||
| {name: "path with quotes", filePath: `file"test"`, wantError: `file path contains potentially dangerous character: "`}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := validateFilePath(tt.filePath) | ||
| if tt.wantError == "" { | ||
| if err != nil { | ||
| t.Fatalf("validateFilePath: %v", err) | ||
| } | ||
| return | ||
| } | ||
| if err == nil || !strings.Contains(err.Error(), tt.wantError) { | ||
| t.Fatalf("validateFilePath error = %v, want error containing %q", err, tt.wantError) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestNewLocalFileBlob(t *testing.T) { | ||
| ctx := t.Context() | ||
|
|
||
|
|
@@ -560,7 +595,7 @@ func TestNewBlobStoreLocalFile(t *testing.T) { | |
| ctx := t.Context() | ||
| tmpDir := t.TempDir() | ||
|
|
||
| blob, err := NewBlobStore(ctx, LocalFileStore, fileURL(tmpDir)) | ||
| blob, err := NewBlobStore(ctx, LocalFileStore, fileURL(tmpDir), nil) | ||
| if err != nil { | ||
| t.Fatalf("NewBlobStore: %v", err) | ||
| } | ||
|
|
@@ -576,7 +611,7 @@ func TestNewBlobStoreLocalFile(t *testing.T) { | |
| // file:// is accepted for agent_managed (local testing) and must reach the local | ||
| // file store rather than the S3 store, matching validateCacheStore. | ||
| func TestNewBlobStoreAgentManagedFile(t *testing.T) { | ||
| blob, err := NewBlobStore(t.Context(), AgentManaged, fileURL(t.TempDir())) | ||
| blob, err := NewBlobStore(t.Context(), AgentManaged, fileURL(t.TempDir()), nil) | ||
| if err != nil { | ||
| t.Fatalf("NewBlobStore: %v", err) | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was moved unchanged from
nsc.goas it's not required by the API but still used by the local file store for validation.