-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(secret): add secret config file for cache calculation #4837
Merged
Conversation
This file contains 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
DmitriyLewen
changed the title
refactor(secret): parse secret configuration file when initializing scanner configuration (before analyze)
feat(secret): add secret config file for cache calculation
Jul 19, 2023
knqyf263
reviewed
Jul 20, 2023
pkg/fanal/cache/key.go
Outdated
@@ -50,7 +50,21 @@ func CalcKey(id string, analyzerVersions analyzer.Versions, hookVersions map[str | |||
} | |||
} | |||
|
|||
// TODO: add secret scanner option here | |||
// Write secret config |
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.
I think we can use the existing logic for misconfiguration.
https://github.com/aquasecurity/trivy/blob/6534dec6704fb010f84b6add5db355a5ee81b0a8/pkg/fanal/cache/key.go#L39C1-L51C3
// Write policy, data contents and secret config file
paths := append(artifactOpt.MisconfScannerOption.PolicyPaths, artifactOpt.MisconfScannerOption.DataPaths...)
// Check if the secret config exists.
if _, err := os.Stat(artifactOpt.SecretScannerOption.ConfigPath); err == nil {
paths = append(paths, artifactOpt.SecretScannerOption.ConfigPath)
}
for _, p := range paths {
hash, err := hashContents(p)
if err != nil {
return "", err
}
if _, err := h.Write([]byte(hash)); err != nil {
return "", xerrors.Errorf("sha256 write error: %w", err)
}
}
knqyf263
approved these changes
Jul 23, 2023
AnaisUrlichs
pushed a commit
to AnaisUrlichs/trivy
that referenced
this pull request
Aug 10, 2023
…ity#4837) * move parse secret config to initScannerConfig + add secret to cache key * add calc cache test * just read config file and add to cache * refactor comments * refactor
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add secret config file for cache calculation.
It fixes bug with secret scan and cache (see #4796):
before:
after:
Related issues
Checklist