Skip to content

Commit ea3ad7b

Browse files
committed
fix: 7093 add username/password properties to be able to authenticate for central.content.url and analyzer.central.url again
1 parent 3e3274f commit ea3ad7b

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

cli/src/main/java/org/owasp/dependencycheck/App.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ protected void populateSettings(CliParser cli) throws InvalidSettingException {
604604
cli.hasOption(CliParser.ARGUMENT.ENABLE_NEXUS));
605605
settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_CENTRAL_URL,
606606
cli.getStringArgument(CliParser.ARGUMENT.CENTRAL_URL));
607+
settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_CENTRAL_USER,
608+
cli.getStringArgument(CliParser.ARGUMENT.CENTRAL_USERNAME));
609+
settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_CENTRAL_PASSWORD,
610+
cli.getStringArgument(CliParser.ARGUMENT.CENTRAL_PASSWORD));
607611
settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_OSSINDEX_URL,
608612
cli.getStringArgument(CliParser.ARGUMENT.OSSINDEX_URL));
609613
settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_OSSINDEX_USER,

cli/src/main/java/org/owasp/dependencycheck/CliParser.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,14 @@ public static class ARGUMENT {
13601360
* The alternative URL for Maven Central Search.
13611361
*/
13621362
public static final String CENTRAL_URL = "centralUrl";
1363+
/**
1364+
* The username for the alternative Maven Central Search.
1365+
*/
1366+
public static final String CENTRAL_USERNAME = "centralUsername";
1367+
/**
1368+
* The password for the alternative Maven Central Search.
1369+
*/
1370+
public static final String CENTRAL_PASSWORD = "centralPassword";
13631371
/**
13641372
* Disables the Nexus Analyzer.
13651373
*/

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ public void configure(Settings settings) throws InvalidSettingException {
175175
tryAddHostedSuppressionCredentials(settings, credentialsProvider);
176176
tryAddKEVCredentials(settings, credentialsProvider);
177177
tryAddNexusAnalyzerCredentials(settings, credentialsProvider);
178+
tryAddCentralAnalyzerCredentials(settings, credentialsProvider);
179+
tryAddCentralContentCredentials(settings, credentialsProvider);
178180
tryAddNVDApiDatafeed(settings, credentialsProvider);
179181
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
180182
httpClientBuilderExplicitNoproxy.setDefaultCredentialsProvider(credentialsProvider);
@@ -220,6 +222,26 @@ private void tryAddNexusAnalyzerCredentials(Settings settings, CredentialsStore
220222
}
221223
}
222224

225+
private void tryAddCentralAnalyzerCredentials(Settings settings, CredentialsStore credentialsStore) throws InvalidSettingException {
226+
if (settings.getString(Settings.KEYS.ANALYZER_CENTRAL_PASSWORD) != null) {
227+
addUserPasswordCreds(settings, credentialsStore,
228+
Settings.KEYS.ANALYZER_CENTRAL_USER,
229+
Settings.KEYS.ANALYZER_CENTRAL_URL,
230+
Settings.KEYS.ANALYZER_CENTRAL_PASSWORD,
231+
"Central Analyzer");
232+
}
233+
}
234+
235+
private void tryAddCentralContentCredentials(Settings settings, CredentialsStore credentialsStore) throws InvalidSettingException {
236+
if (settings.getString(Settings.KEYS.CENTRAL_CONTENT_PASSWORD) != null) {
237+
addUserPasswordCreds(settings, credentialsStore,
238+
Settings.KEYS.CENTRAL_CONTENT_USER,
239+
Settings.KEYS.CENTRAL_CONTENT_URL,
240+
Settings.KEYS.CENTRAL_CONTENT_PASSWORD,
241+
"Central Content");
242+
}
243+
}
244+
223245
private void tryAddNVDApiDatafeed(Settings settings, CredentialsStore credentialsStore) throws InvalidSettingException {
224246
if (settings.getString(Settings.KEYS.NVD_API_DATAFEED_PASSWORD) != null) {
225247
addUserPasswordCreds(settings, credentialsStore,

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,14 @@ public static final class KEYS {
620620
* Key for the URL to obtain content from Maven Central.
621621
*/
622622
public static final String CENTRAL_CONTENT_URL = "central.content.url";
623+
/**
624+
* Key for the Username to obtain content from Maven Central.
625+
*/
626+
public static final String CENTRAL_CONTENT_USER = "central.content.username";
627+
/**
628+
* Key for the Password to obtain content from Maven Central.
629+
*/
630+
public static final String CENTRAL_CONTENT_PASSWORD = "central.content.password";
623631
/**
624632
* The properties key for whether the Central analyzer should use
625633
* parallel processing.
@@ -656,6 +664,14 @@ public static final class KEYS {
656664
* The properties key for the Central search URL.
657665
*/
658666
public static final String ANALYZER_CENTRAL_URL = "analyzer.central.url";
667+
/**
668+
* The properties key for the Central search username.
669+
*/
670+
public static final String ANALYZER_CENTRAL_USER = "analyzer.central.username";
671+
/**
672+
* The properties key for the Central search password.
673+
*/
674+
public static final String ANALYZER_CENTRAL_PASSWORD = "analyzer.central.password";
659675
/**
660676
* The properties key for the Central search query.
661677
*/

0 commit comments

Comments
 (0)