Skip to content

Commit

Permalink
refactor: align dependency check with moderneinc (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjungling authored Aug 9, 2024
1 parent 2dda7d7 commit a1d8602
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ configure<nebula.plugin.release.git.base.ReleasePluginExtension> {

configure<org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension> {
analyzers.assemblyEnabled = false
analyzers.nodeAuditEnabled = false
analyzers.nodeEnabled = false
failBuildOnCVSS = 9.0F
suppressionFile = "suppressions.xml"
failBuildOnCVSS = System.getenv("FAIL_BUILD_ON_CVSS")?.toFloatOrNull() ?: 9.0F
nvd.apiKey = System.getenv("NVD_API_KEY")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,35 @@
*/
package org.openrewrite.gradle;


import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.owasp.dependencycheck.gradle.DependencyCheckPlugin;
import org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension;

import java.util.Collections;

public class RewriteDependencyCheckPlugin implements Plugin<Project> {

@Override
public void apply(Project project) {
project.getPlugins().apply(DependencyCheckPlugin.class);

float failBuildOnCVSS = Float
.parseFloat(System.getenv("FAIL_BUILD_ON_CVSS") != null ? System.getenv("FAIL_BUILD_ON_CVSS") : "9");

// check to see if `suppressions.xml` exists in project root
if (project.file("suppressions.xml").exists()) {
project.getExtensions().configure(DependencyCheckExtension.class, ext -> {
ext.setSuppressionFile(project.file("suppressions.xml").getPath());
});
}

project.getExtensions().configure(DependencyCheckExtension.class, ext -> {
ext.getAnalyzers().setAssemblyEnabled(false);
ext.setFailBuildOnCVSS(9.0f);
ext.setScanProjects(Collections.singletonList(project.getName()));
ext.getAnalyzers().setNodeAuditEnabled(false);
ext.getAnalyzers().setNodeEnabled(false);
ext.setFailBuildOnCVSS(failBuildOnCVSS);
ext.getNvd().setApiKey(System.getenv("NVD_API_KEY"));

});

}
}

0 comments on commit a1d8602

Please sign in to comment.