Skip to content

Commit 5a5990e

Browse files
authored
feat: override pnpm audit registry parameter (#8158)
1 parent 8402bb6 commit 5a5990e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

core/src/main/java/org/owasp/dependencycheck/analyzer/PnpmAuditAnalyzer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public class PnpmAuditAnalyzer extends AbstractNpmAnalyzer {
6060
*/
6161
public static final String PNPM_PACKAGE_LOCK = "pnpm-lock.yaml";
6262

63+
/**
64+
* The default registry parameter to pass to the pnpm audit execution.
65+
*/
66+
public static final String DEFAULT_REGISTRY = "https://registry.npmjs.org/";
67+
6368
/**
6469
* Filter that detects files named "pnpm-lock.yaml"
6570
*/
@@ -202,9 +207,9 @@ private JSONObject fetchPnpmAuditJson(Dependency dependency, boolean skipDevDepe
202207
}
203208
// pnpm audit returns a json compliant with NpmAuditParser
204209
args.add("--json");
205-
// ensure we are using the right registry despite .npmrc
210+
// ensure we are using the right registry despite .npmrc, but allow override
206211
args.add("--registry");
207-
args.add("https://registry.npmjs.org/");
212+
args.add(getSettings().getString(Settings.KEYS.ANALYZER_PNPM_AUDIT_REGISTRY, DEFAULT_REGISTRY));
208213
final ProcessBuilder builder = new ProcessBuilder(args);
209214
builder.directory(folder);
210215
// Workaround 64k limitation of InputStream, redirect stdout to a file that we will read later

core/src/main/resources/dependencycheck.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ analyzer.node.package.enabled=true
118118
analyzer.node.audit.enabled=true
119119
analyzer.yarn.audit.enabled=true
120120
analyzer.pnpm.audit.enabled=true
121+
analyzer.pnpm.audit.registry=https://registry.npmjs.org/
121122
analyzer.golang.dep.enabled=true
122123
analyzer.retirejs.enabled=true
123124
analyzer.retirejs.repo.validforhours=24

utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ public static final class KEYS {
428428
* The properties key for whether the Pnpm Audit analyzer is enabled.
429429
*/
430430
public static final String ANALYZER_PNPM_AUDIT_ENABLED = "analyzer.pnpm.audit.enabled";
431+
/**
432+
* The properties key for the Pnpm registry url.
433+
*/
434+
public static final String ANALYZER_PNPM_AUDIT_REGISTRY = "analyzer.pnpm.audit.registry";
431435
/**
432436
* The properties key for supplying the URL to the Node Audit API.
433437
*/

0 commit comments

Comments
 (0)