Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ protected void prepareAnalyzer(Engine engine) throws InitializationException {
synchronized (FETCH_MUTIX) {
if (StringUtils.isEmpty(getSettings().getString(KEYS.ANALYZER_OSSINDEX_USER, StringUtils.EMPTY)) ||
StringUtils.isEmpty(getSettings().getString(KEYS.ANALYZER_OSSINDEX_PASSWORD, StringUtils.EMPTY))) {
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");
LOG.warn("Disabling OSS Index analyzer due to missing user/password credentials. Authentication is now required: https://ossindex.sonatype.org/doc/auth-required");
setEnabled(false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.dependency.naming.Identifier;
import org.owasp.dependencycheck.dependency.naming.PurlIdentifier;
import org.owasp.dependencycheck.exception.InitializationException;
import org.owasp.dependencycheck.utils.Settings;
import org.owasp.dependencycheck.utils.Settings.KEYS;

Expand All @@ -30,7 +29,7 @@

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class OssIndexAnalyzerTest extends BaseTest {
Expand Down Expand Up @@ -252,18 +251,21 @@ void should_analyzeDependency_fail_when_socket_error_from_sonatype() throws Exce
}

@Test
void should_prepareAnalyzer_fail_when_credentials_not_set() throws Exception {
void should_prepareAnalyzer_disable_when_credentials_not_set() throws Exception {
// Given
OssIndexAnalyzer analyzer = new OssIndexAnalyzer();
Settings settings = getSettings();
Engine engine = new Engine(settings);
analyzer.initialize(settings);
try {
analyzer.prepareAnalyzer(engine);
assertThrows(InitializationException.class, () -> analyzer.prepareAnalyzer(engine));
} catch (InitializationException e) {
analyzer.close();
engine.close();
}

// When
analyzer.prepareAnalyzer(engine);

// Then
boolean enabled = analyzer.isEnabled();
analyzer.close();
engine.close();
Comment thread
jeremylong marked this conversation as resolved.
assertFalse(enabled);
}

private static void setCredentials(final Settings settings) {
Expand Down
4 changes: 3 additions & 1 deletion src/site/markdown/analyzers/oss-index-analyzer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ Sonatype [announced](https://ossindex.sonatype.org/doc/auth-required) that OSS I

You can get an API Token following these steps:
1. [Sign In](https://ossindex.sonatype.org/user/signin) or [Sign Up](https://ossindex.sonatype.org/user/register) for free.
2. Get the API Token from user Settings.
2. Get the API Token from user Settings.

If no credentials are provided, this analyzer will be disabled.