Repository navigation
Conversation
Author
|
@advaitpatel ptal |
This branch has not been deployed
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
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.
Pull Request
Description
Fixes an issue where Trivy findings from nested Dockerfiles with the same basename could be incorrectly attributed to the root Dockerfile.
Previously,
run_trivy_config()scanned the Dockerfile's parent directory and used--file-patternswith the Dockerfile basename. This allowed nested Dockerfiles with the same basename to be included in the Trivy results. The parser then filtered results by basename, which could still cause findings from a nested Dockerfile to be associated with the requested Dockerfile.This change makes
run_trivy_config()pass the exact Dockerfile path to Trivy instead of scanning the parent directory. The basename-based filtering workaround was removed fromparse_trivy_config_json().A regression test was added to verify that Trivy receives the exact Dockerfile path, along with coverage for offline mode.
Closes #195
Type of Change
How Has This Been Tested?
Describe the tests run to verify the changes:
Test Configuration:
a859ce2Tests run:
pytest tests/test_findings.py— 22 passedpytest tests/— 544 passed, 3 skippedgit diff --cached --check— passedManually verified Trivy behavior with nested Dockerfiles using Trivy 0.74.0:
Manual reproduction
The issue was reproduced with a directory containing:
The nested Dockerfile contained a misconfiguration that Trivy reported as DS-0013.
Scanning the directory caused both Dockerfiles to appear in Trivy's results, while scanning the exact Dockerfile path returned only the requested Dockerfile.
Checklist
Screenshots (if applicable)
Not applicable.
Related Issues / PRs
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.