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

JENKINS-74934: Display project references in OWASP dependency check table #156

Merged

Conversation

mbrannstrom
Copy link
Contributor

@mbrannstrom mbrannstrom commented Nov 28, 2024

Display project references in OWASP dependency check table.

See JENKINS-74934 for more information.

Parse "dependency/projectReferences/projectReference" from the dependency-check XML, available in dependency-check.1.7.xsd through dependency-check.4.0.xsd (latest).

Then display the value in the Dependency-Check Reports table, and also make it filterable (searchable).

Testing done

Added test-case to verify that XML parsing works fine (see ReportParserTest.testProjectReferences)

Deployed plugin to Jenkins installation and verified that the plugin works as intended.

Note that old jobs that were run with a previous version of the dependency-check plugin will not have the project references value populated in the table. It seems like the parsed Java objects are stored for historical jobs, rather than the original XML. However, new jobs will have value, as shown in the screenshot.

Also verified that the new table field is searchable (worked out of the box).

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Screenshot

Skärmavbild 2024-11-28 kl  11 11 01

@nfalco79
Copy link
Member

nfalco79 commented Dec 6, 2024

what are compileClasspath and testCompileClasspath? Maven project? Modules name?

@mbrannstrom
Copy link
Contributor Author

what are compileClasspath and testCompileClasspath? Maven project? Modules name?

It’s whatever the OWASP dependency check plugin inserts into the XML report. In this case it is a Java Gradle project, so the syntax is module colon classpath (test etc).

@nfalco79
Copy link
Member

nfalco79 commented Dec 9, 2024

I re-run job because increments build was not available. I want see change in our environment

@@ -131,6 +131,14 @@ public JSONObject transform(List<Finding> findings) {
vulnReferences.put("filterable", false);
columns.add(vulnReferences);

final JSONObject projReferences = new JSONObject();
projReferences.put("name", "dependency.projectReferences");
projReferences.put("title", "Project References");
Copy link
Member

Choose a reason for hiding this comment

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

Use "Referenced In Projects/Scopes" as title, scope is the part I did not expect in the name of the project. The title should advise about that (as html report does)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@@ -143,6 +151,9 @@ public JSONObject transform(List<Finding> findings) {
row.put("dependency.md5", escape(dependency.getMd5()));
row.put("dependency.sha1", escape(dependency.getSha1()));
row.put("dependency.sha256", escape(dependency.getSha256()));
if (CollectionUtils.isNotEmpty(dependency.getProjectReferences())) {
row.put("dependency.projectReferences", escape(String.join(", ", dependency.getProjectReferences())));
Copy link
Member

Choose a reason for hiding this comment

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

comma separated list is not clear. Please render as a ul list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

…eferenced In Projects/Scopes' as in the OWASP HTML report.
@mbrannstrom
Copy link
Contributor Author

Resulting screenshot after changes from review.

Skärmavbild 2024-12-12 kl  13 09 10

@nfalco79 nfalco79 merged commit ad22bfc into jenkinsci:master Dec 12, 2024
18 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.

2 participants