-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: package and utilize generated suppression file #8116
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
Open
jeremylong
wants to merge
9
commits into
main
Choose a base branch
from
scratch/download-generated
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a3513cc
feat: package and utilize generated suppression file
jeremylong 2f3a2ea
fix: use different downloader per copilot
jeremylong c1f7ded
Apply suggestion from @jeremylong
jeremylong 1d58894
Apply suggestion from @jeremylong
jeremylong f61f551
Apply suggestions from code review
jeremylong cab3470
Apply suggestion from @jeremylong
jeremylong aa38606
Apply suggestion from @jeremylong
jeremylong a9748b2
fix: dependency relocated
jeremylong ff0a23a
Merge branch 'main' into scratch/download-generated
nhumblot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,10 @@ public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer { | |
| * The file name of the base suppression XML file. | ||
| */ | ||
| private static final String BASE_SUPPRESSION_FILE = "dependencycheck-base-suppression.xml"; | ||
| /** | ||
| * The file name of the generated suppression XML file. | ||
| */ | ||
| private static final String GENERATED_SUPPRESSION_FILE = "generated-suppressions.xml"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we keep this approach, perhaps we could try and align on language to make it a bit less confusing. Right now it is referred to as
I wonder if referring to as |
||
| /** | ||
| * The key used to store and retrieve the suppression files. | ||
| */ | ||
|
|
@@ -195,17 +199,28 @@ private void loadSuppressionBaseData(final Engine engine) throws SuppressionPars | |
| * @throws SuppressionParseException thrown if the XML cannot be parsed. | ||
| */ | ||
| private void loadPackagedSuppressionBaseData(final SuppressionParser parser, final Engine engine) throws SuppressionParseException { | ||
| loadPackagedSuppressionBaseData(BASE_SUPPRESSION_FILE, parser, engine); | ||
| loadPackagedSuppressionBaseData(GENERATED_SUPPRESSION_FILE, parser, engine); | ||
jeremylong marked this conversation as resolved.
Show resolved
Hide resolved
jeremylong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| /** | ||
| * Loads the base suppression rules packaged with the application. | ||
| * | ||
| * @param parser The suppression parser to use | ||
jeremylong marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @param engine a reference the dependency-check engine | ||
| * @throws SuppressionParseException thrown if the XML cannot be parsed. | ||
| */ | ||
| private void loadPackagedSuppressionBaseData(final String packagedFileName, final SuppressionParser parser, final Engine engine) throws SuppressionParseException { | ||
jeremylong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| List<SuppressionRule> ruleList = null; | ||
| final URL jarLocation = AbstractSuppressionAnalyzer.class.getProtectionDomain().getCodeSource().getLocation(); | ||
| String suppressionFileLocation = jarLocation.getFile(); | ||
| if (suppressionFileLocation.endsWith(".jar")) { | ||
| suppressionFileLocation = "jar:file:" + suppressionFileLocation + "!/" + BASE_SUPPRESSION_FILE; | ||
| suppressionFileLocation = "jar:file:" + suppressionFileLocation + "!/" + packagedFileName; | ||
| } else if (suppressionFileLocation.startsWith("nested:") && suppressionFileLocation.endsWith(".jar!/")) { | ||
| // suppressionFileLocation -> nested:/app/app.jar/!BOOT-INF/lib/dependency-check-core-<version>.jar!/ | ||
| // goal-> jar:nested:/app/app.jar/!BOOT-INF/lib/dependency-check-core-<version>.jar!/dependencycheck-base-suppression.xml | ||
| suppressionFileLocation = "jar:" + suppressionFileLocation + BASE_SUPPRESSION_FILE; | ||
| suppressionFileLocation = "jar:" + suppressionFileLocation + packagedFileName; | ||
| } else { | ||
| suppressionFileLocation = "file:" + suppressionFileLocation + BASE_SUPPRESSION_FILE; | ||
| suppressionFileLocation = "file:" + suppressionFileLocation + packagedFileName; | ||
| } | ||
| URL baseSuppresssionURL = null; | ||
| try { | ||
|
|
||
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
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.
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.
issue: this seems to generate the following warning when performing a
mvn -s settings.xml clean install: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.
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.
Oops, missed this in my proposed edit earlier - thx!