Skip to content

Commit 0ed53b7

Browse files
majaberejberejmaj
andauthored
purl processing exception fix (#74)
Co-authored-by: berejmaj <maja.berej@orange.com>
1 parent 6c420cf commit 0ed53b7

File tree

1 file changed

+10
-4
lines changed
  • backend/src/main/java/io/mixeway/mixewayflowapi/integrations/scanner/sca/service

1 file changed

+10
-4
lines changed

backend/src/main/java/io/mixeway/mixewayflowapi/integrations/scanner/sca/service/SCAGrypeService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ public void runGrype(String repoDir, CodeRepo codeRepo, CodeRepoBranch codeRepoB
136136
createFindingService.saveFindings(findings, codeRepoBranch, codeRepo, Finding.Source.SCA, null);
137137

138138
log.info("[GrypeService] Scan results processed successfully - [{} / {}]", codeRepo.getRepourl(), codeRepoBranch.getName());
139-
} catch (JsonParseException | MalformedPackageURLException e) {
140-
log.warn("[GrypeService] Error with running scan for repository - [{} / {}]", codeRepo.getRepourl(), codeRepoBranch.getName());
139+
} catch (JsonParseException e) {
140+
log.warn("[GrypeService] Error with running scan for repository - [{} / {}]", codeRepo.getRepourl(), codeRepoBranch.getName(), e);
141141
}
142142
}
143143

144144
@Transactional
145-
public void processSBOMComponents(File sbomFile, CodeRepo codeRepo) throws IOException, MalformedPackageURLException {
145+
public void processSBOMComponents(File sbomFile, CodeRepo codeRepo) throws IOException {
146146

147147
log.info("[GrypeService] Started processing SBOM components.");
148148

@@ -158,7 +158,13 @@ public void processSBOMComponents(File sbomFile, CodeRepo codeRepo) throws IOExc
158158
continue;
159159
}
160160

161-
PackageURL pkg = new PackageURL(purl);
161+
PackageURL pkg;
162+
try {
163+
pkg = new PackageURL(purl);
164+
} catch (MalformedPackageURLException e) {
165+
log.warn("[GrypeService] Skipping invalid component purl: {}", purl, e);
166+
continue;
167+
}
162168

163169
String type = pkg.getType();
164170
String version = pkg.getVersion();

0 commit comments

Comments
 (0)