Validate revision id in consume of Vuln Cache Proc plugin
@@ -282,6 +282,20 @@ public class VulnerabilityCacheProcessorPlugin extends Plugin {
var revision = new Revision(id, groupId, artifactId, version, new Timestamp(timestamp));
logger.info("Processing revision: " + revision.toString());
+ // Sometimes the topic passes in artifacts with invalid revision id of 0.
+ if (revision.id == 0) {
+ logger.info("Failed to retrieve correct revision id from the topic. Trying to fetch it from DB...");
+ var fixedId = kbDao.getPackageVersionID(revision.product().toString(), revision.version.toString());
+ if(fixedId > 0) {
+ logger.info("Revision ID is fixed. Continuing the process...");
+ revision.id = fixedId;
+ } else {
+ logger.info("Failed to retrieve correct revision id from DB. Skipping the process...");
+ persistOutput(revision, "{}");
+ continue;
+ }
+ }
+
var depSet = graphResolver.resolveDependencies(revision, dbContext, true);
var depIds = depSet.stream().map(r -> r.id).collect(Collectors.toSet());
logger.info("Revision ID: " + revision.id);
