Skip to content

Commit 371c46e

Browse files
committed
Add handling to only apply lastModified date to remote repositories
1 parent 540c625 commit 371c46e

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.artifactory.fs.ItemInfo;
1515
import org.artifactory.repo.RepoPath;
1616
import org.artifactory.repo.Repositories;
17+
import org.artifactory.repo.RepositoryConfiguration;
1718
import org.jetbrains.annotations.NotNull;
1819
import org.slf4j.Logger;
1920
import org.slf4j.LoggerFactory;
@@ -97,6 +98,11 @@ private void filter(MonitoredArtifact artifact) {
9798
private @NotNull MonitoredArtifact toMonitoredArtifact(TestResult testResult, @NotNull RepoPath repoPath) {
9899
Ignores ignores = Ignores.read(new RepositoryArtifactProperties(repoPath, repositories));
99100
Instant lastModifiedDate = getLastModifiedDate(repoPath);
101+
102+
// Only apply lastModifiedDate to packages from remote repositories.
103+
if(!isRemoteRepository(repoPath)) {
104+
lastModifiedDate = null;
105+
}
100106
return new MonitoredArtifact(repoPath.toString(), testResult, ignores, lastModifiedDate);
101107
}
102108

@@ -108,11 +114,21 @@ private Instant getLastModifiedDate(RepoPath repoPath) {
108114
return lastModified;
109115
}
110116
} catch (Exception e) {
111-
LOG.debug("Could not retrieve created date for {}: {}", repoPath, e);
117+
LOG.debug("Could not retrieve last modified date for {}: {}", repoPath, e);
112118
}
113119
return null;
114120
}
115121

122+
private boolean isRemoteRepository(RepoPath repoPath) {
123+
String repoKey = repoPath.getRepoKey();
124+
RepositoryConfiguration repoConfig = repositories.getRepositoryConfiguration(repoKey);
125+
repoType = repoConfig.getType();
126+
127+
LOG.debug("Found repository type: {}", repoType);
128+
129+
return repoType == "remote";
130+
}
131+
116132
private boolean shouldTestContinuously() {
117133
return configurationModule.getPropertyOrDefault(PluginConfiguration.TEST_CONTINUOUSLY).equals("true");
118134
}

0 commit comments

Comments
 (0)