Skip to content

Commit 3d70d79

Browse files
author
Gustavo De Micheli
committed
fix: Disable OSS Index if its credentials are missing
1 parent 93422d2 commit 3d70d79

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ protected void prepareAnalyzer(Engine engine) throws InitializationException {
134134
synchronized (FETCH_MUTIX) {
135135
if (StringUtils.isEmpty(getSettings().getString(KEYS.ANALYZER_OSSINDEX_USER, StringUtils.EMPTY)) ||
136136
StringUtils.isEmpty(getSettings().getString(KEYS.ANALYZER_OSSINDEX_PASSWORD, StringUtils.EMPTY))) {
137-
throw new InitializationException("Error initializing OSS Index analyzer due to missing user/password credentials. Authentication is now required: https://ossindex.sonatype.org/doc/auth-required");
137+
LOG.info("Disabling OSS Index analyzer due to missing user/password credentials. Authentication is now required: https://ossindex.sonatype.org/doc/auth-required");
138+
setEnabled(false);
138139
}
139140
}
140141
}

core/src/test/java/org/owasp/dependencycheck/analyzer/OssIndexAnalyzerTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
import java.util.concurrent.Executors;
2929
import java.util.concurrent.Future;
3030

31-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
32-
import static org.junit.jupiter.api.Assertions.assertEquals;
33-
import static org.junit.jupiter.api.Assertions.assertThrows;
34-
import static org.junit.jupiter.api.Assertions.assertTrue;
31+
import static org.junit.jupiter.api.Assertions.*;
3532

3633
class OssIndexAnalyzerTest extends BaseTest {
3734

@@ -252,14 +249,14 @@ void should_analyzeDependency_fail_when_socket_error_from_sonatype() throws Exce
252249
}
253250

254251
@Test
255-
void should_prepareAnalyzer_fail_when_credentials_not_set() throws Exception {
252+
void should_prepareAnalyzer_disable_when_credentials_not_set() throws Exception {
256253
OssIndexAnalyzer analyzer = new OssIndexAnalyzer();
257254
Settings settings = getSettings();
258255
Engine engine = new Engine(settings);
259256
analyzer.initialize(settings);
260257
try {
261258
analyzer.prepareAnalyzer(engine);
262-
assertThrows(InitializationException.class, () -> analyzer.prepareAnalyzer(engine));
259+
assertFalse(analyzer.isEnabled());
263260
} catch (InitializationException e) {
264261
analyzer.close();
265262
engine.close();

src/site/markdown/analyzers/oss-index-analyzer.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ Sonatype [announced](https://ossindex.sonatype.org/doc/auth-required) that OSS I
1313

1414
You can get an API Token following these steps:
1515
1. [Sign In](https://ossindex.sonatype.org/user/signin) or [Sign Up](https://ossindex.sonatype.org/user/register) for free.
16-
2. Get the API Token from user Settings.
16+
2. Get the API Token from user Settings.
17+
18+
If no credentials are provided, this analyzer will be disabled.

0 commit comments

Comments
 (0)