Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reduce logging and use debug levels #46

Merged
1 commit merged into from
Aug 10, 2021
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
14 changes: 10 additions & 4 deletions core/src/main/java/io/snyk/plugins/artifactory/SnykPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.annotation.Nonnull;
import java.io.File;
import java.util.Optional;
import java.util.Properties;

import io.snyk.plugins.artifactory.audit.AuditModule;
Expand Down Expand Up @@ -91,15 +92,20 @@ public void handleBeforeDownloadEvent(RepoPath repoPath) {
try {
scannerModule.scanArtifact(repoPath);
} catch (CannotScanException e) {
LOG.warn("Artifact cannot be scanned {}. {}", repoPath, e.getMessage());
LOG.debug("Artifact cannot be scanned {}. {}", repoPath, e.getMessage());
} catch (SnykAPIFailureException e) {
final String blockOnApiFailurePropertyKey = SCANNER_BLOCK_ON_API_FAILURE.propertyKey();
final String blockOnApiFailure = configurationModule.getPropertyOrDefault(SCANNER_BLOCK_ON_API_FAILURE);
String message = "Failed to scan artifact '" + repoPath + "'. " + e.getMessage();
final String causeMessage = Optional.ofNullable(e.getCause())
.map(Throwable::getMessage)
.map(m -> " " + m)
.orElse("");

String message = "Failed to scan artifact '" + repoPath + "'. " + e.getMessage() + causeMessage;
if ("true".equals(blockOnApiFailure)) {
throw new CancelException(message, e, 500);
throw new CancelException(message, 500);
}
LOG.warn(message, e);
LOG.debug(message);
LOG.debug("Property '{}' is false, so allowing download: '{}'", blockOnApiFailurePropertyKey, repoPath);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public static String getArtifactDetailsURL(String groupID, String artifactID, St
}

public TestResult scan(FileLayoutInfo fileLayoutInfo, RepoPath repoPath) {
if (!fileLayoutInfo.isValid()) {
LOG.warn("Artifact '{}' file layout info is not valid.", repoPath);
}

String groupID = Optional.ofNullable(fileLayoutInfo.getOrganization())
.orElseThrow(() -> new CannotScanException("Group ID not provided."));
String artifactID = Optional.ofNullable(fileLayoutInfo.getModule())
Expand Down