-
Notifications
You must be signed in to change notification settings - Fork 17
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
Cache support #17
Cache support #17
Conversation
This implementation attempts to support parallel CLI executions and has no automatic cleaning for now.
This ensures that we will also create OS-dependent cache directory if it doesn't exist yet.
Pass everything to Cirrus CI annotations.
) | ||
|
||
type PutOperation struct { | ||
tmpBlobFile *os.File |
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.
let's use a buffered writer here
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.
See 424a4fa.
internal/executor/cache/cache.go
Outdated
} | ||
|
||
func (c *Cache) blobPath(key string) string { | ||
// Sanitize user-controlled data by hashing it |
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.
Might not be necessary since cache keys are always in this form <cache name>-<sha256>
. Plus will be easier for users to find the blobs for manual inspection.
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.
It's technically possible for the arbitrary code that runs in the task's environment to impersonate the agent and connect to the CLI over new (or existing) RPC connection.
So this depends on whether we trust that environment or not.
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.
Alternatively, we can validate the key using a simple regular expression.
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.
Yeah, can do something like:
// Sanitize user-controlled data by hashing it | |
isSafeChar := func(c rune) bool { | |
if '0' <= c && c <= '9' { return true } | |
if 'a' <= c && c <= 'z' { return true } | |
if 'A' <= c && c <= 'Z' { return true } | |
if c == '-' || c == '_' { return true } | |
return false | |
} | |
isNotSafeChar := func(c rune) bool { | |
return !isSafeChar(c) | |
} | |
containsNonSafeChar := strings.IndexFunc(key, isNotSafeChar) >= 0 | |
if !containsNonSafeChar { | |
// only safe characters so no need for a sanitization | |
return key | |
} | |
// Sanitize user-controlled data by hashing it |
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.
See 379f4a2.
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.
Looks great! Left a few nitpicks.
Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
2020/08/03 13:14:37 Failed to download test-e7c76decfad1e83298b9a9ddf7f2f37ad42da790a1d665b6a2404c3c82b66e48 cache! rpc error: code = ResourceExhausted desc = grpc: received message larger than max (10485765 vs. 4194304)
This implementation attempts to support parallel CLI executions and has no automatic cleaning for now.