Skip to content

Commit 64a5388

Browse files
committed
Add configuration parameter for checking remote only repositories
1 parent 99bf79a commit 64a5388

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

core/src/main/groovy/io/snyk/plugins/artifactory/snykSecurityPlugin.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ snyk.api.organization=
6868

6969
# A delay in number of days since the package was last modified in Artifactory. Any packages that were modified more recently
7070
# than the current time minus the number of days in this configuration will be blocked from download. The use case is to prevent
71-
# packages that may contain zero-day vulnerabilities from being introduced to a consumer.
71+
# packages that may contain zero-day vulnerabilities from being introduced to a consumer.
72+
# Default: 0
7273
#snyk.scanner.lastModified.days
7374

75+
# If remoteOnly is set to true, only check lastModified for packages contained in remote repositories.
76+
# Default: true
77+
#snyk.scanner.lastModified.remoteOnly
78+
7479
# By default, if Snyk API fails while scanning an artifact for any reason, the download will be allowed.
7580
# Setting this property to "true" will block downloads when Snyk API fails.
7681
# Accepts: "true", "false"

core/src/main/java/io/snyk/plugins/artifactory/configuration/PluginConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public enum PluginConfiguration implements Configuration {
3333
TEST_CONTINUOUSLY("snyk.scanner.test.continuously","false"),
3434
TEST_FREQUENCY_HOURS("snyk.scanner.frequency.hours", "168"),
3535
EXTEND_TEST_DEADLINE_HOURS("snyk.scanner.extendTestDeadline.hours", "24"),
36-
SCANNER_LAST_MODIFIED_DELAY_DAYS("snyk.scanner.lastModified.days", "0");
36+
SCANNER_LAST_MODIFIED_DELAY_DAYS("snyk.scanner.lastModified.days", "0"),
37+
SCANNER_LAST_MODIFIED_CHECK_ONLY_REMOTE("snyk.scanner.lastModified.remoteOnly", "true");
3738

3839
private final String propertyKey;
3940
private final String defaultValue;

core/src/main/java/io/snyk/plugins/artifactory/scanner/ScannerModule.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void filter(MonitoredArtifact artifact) {
100100
Instant lastModifiedDate = getLastModifiedDate(repoPath);
101101

102102
// Only apply lastModifiedDate to packages from remote repositories.
103-
if(!isRemoteRepository(repoPath)) {
103+
if(lastModifiedDateRemoteOnly() && !isRemoteRepository(repoPath)) {
104104
lastModifiedDate = null;
105105
}
106106
return new MonitoredArtifact(repoPath.toString(), testResult, ignores, lastModifiedDate);
@@ -133,6 +133,10 @@ private boolean shouldTestContinuously() {
133133
return configurationModule.getPropertyOrDefault(PluginConfiguration.TEST_CONTINUOUSLY).equals("true");
134134
}
135135

136+
private boolean lastModifiedDateRemoteOnly() {
137+
return configurationModule.getPropertyOrDefault(PluginConfiguration.SCANNER_LAST_MODIFIED_CHECK_ONLY_REMOTE).equals("true");
138+
}
139+
136140
private Duration durationHoursProperty(PluginConfiguration property, ConfigurationModule configurationModule) {
137141
return Duration.ofHours(Integer.parseInt(configurationModule.getPropertyOrDefault(property)));
138142
}

0 commit comments

Comments
 (0)