Skip to content
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

fix(server): secrets inspectation for the config analyzer in client server mode #8418

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

iamtraining
Copy link
Contributor

fix secrets inspectation for the config analyzer in client server mode

Description

secrets that were found when inspecting the config in client/server mode are not saved in the remote cache
func (a Artifact) inspectConfig( ... )
the secret field for PutArtifact is not sent to the server so these secrets are lost
before
{ "SchemaVersion":1, "Architecture":"amd64", "Created":"2023-10-24T22:44:45Z", "DockerVersion":"", "OS":"linux" }
after this huge and massive fix
{"SchemaVersion":1,"Architecture":"amd64","Created":"2023-10-24T22:44:45Z","DockerVersion":"","OS":"linux","Secret":{"FilePath":"config.json","Findings":[{ ... }]}}

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@CLAassistant
Copy link

CLAassistant commented Feb 18, 2025

CLA assistant check
All committers have signed the CLA.

@iamtraining iamtraining changed the title fix secrets inspectation for the config analyzer in client server mode fix(report): secrets inspectation for the config analyzer in client server mode Feb 18, 2025
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamtraining Thanks for your work!
Looks good.
Left small comments

}
}

// ConvertFromRPCSecret converts fanal.Secret to common.Secret
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ConvertFromRPCSecret converts fanal.Secret to common.Secret
// ConvertToRPCSecret converts fanal.Secret to common.Secret

}

// ConvertFromRPCSecret converts fanal.Secret to common.Secret
func ConvertToRPCSecret(secret *ftypes.Secret) *common.Secret {
Copy link
Contributor

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 this function in ConvertToRPCSecrets:

trivy/pkg/rpc/convert.go

Lines 149 to 152 in a280cbb

rpcSecrets = append(rpcSecrets, &common.Secret{
Filepath: s.FilePath,
Findings: ConvertToRPCSecretFindings(s.Findings),
})

@@ -1015,3 +1017,25 @@ func ConvertFromDeleteBlobsRequest(deleteBlobsRequest *cache.DeleteBlobsRequest)
}
return deleteBlobsRequest.GetBlobIds()
}

// ConvertFromRPCSecret converts common.Secret to fanal.Secret
func ConvertFromRPCSecret(rpcSecret *common.Secret) *ftypes.Secret {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for ConvertFromRPCSecrets

@@ -21,6 +21,7 @@ message ArtifactInfo {
string docker_version = 4;
string os = 5;
repeated common.Package history_packages = 6;
common.Secret secret = 7;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use mage fmt

@DmitriyLewen DmitriyLewen changed the title fix(report): secrets inspectation for the config analyzer in client server mode fix(server): secrets inspectation for the config analyzer in client server mode Feb 19, 2025
@DmitriyLewen DmitriyLewen added this pull request to the merge queue Feb 19, 2025
Merged via the queue into aquasecurity:main with commit a1c4bd7 Feb 19, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trivy client server mode not scanning secrets exposed in image, Trivy standalone works
3 participants