-
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): detect secrets removed or overwritten in upper layer #2611
Conversation
pkg/types/report.go
Outdated
@@ -53,6 +53,7 @@ type Result struct { | |||
Target string `json:"Target"` | |||
Class ResultClass `json:"Class,omitempty"` | |||
Type string `json:"Type,omitempty"` | |||
Layer string `json:"Layer,omitempty"` // Used only for secrets, as Trivy keeps secrets from all layers. |
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.
We should have Layer
here rather than in Result
.
trivy/pkg/fanal/types/secret.go
Lines 11 to 20 in 7699153
type SecretFinding struct { | |
RuleID string | |
Category SecretRuleCategory | |
Severity string | |
Title string | |
StartLine int | |
EndLine int | |
Code Code | |
Match string | |
} |
If the finding is the same, the first introduced layer should be taken.
- Layer 1
- no secret found
- Layer 2
- secret.txt
- GitHub PAT
- secret.txt
- Layer 3
- secret.txt
- GitHub PAT
- AWS Access Key
- secret.txt
- Layer 4
- remove secret.txt
The result would be as below.
{
"Target": "secret.txt",
"Secrets": [
{
"RuleID": "github-pat",
...
"Layer": "Layer 2",
},
{
"RuleID": "aws-access-key",
...
"Layer": "Layer 3",
}
]
}
We should not have github-pat
in Layer 3
.
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.
Note that Layer
actually consists of Digest
and DiffID
. The above example is for sake of simplicity.
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.
Done
Description
Secrets can be deleted or overwritten in the upper layer.
We still have to keep these secrets.
Which layer contains the secret file, you can see in the
Layer
field when using thejson
format:Related issues
Checklist