Skip to content

Commit

Permalink
[SBOMER-108] - Fix the changed location of the final SBOM generated f…
Browse files Browse the repository at this point in the history
…or ZIP manifests; fix the generation of multiple deliverable analysis manifests
  • Loading branch information
vibe13 committed Jul 29, 2024
1 parent 20c9463 commit f8983d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
Expand Down Expand Up @@ -256,9 +257,15 @@ protected Path doGenerate() {
parent.addDependency(dependency);
}

Path sbomDirPath = Path.of(parent.getWorkdir().toAbsolutePath().toString(), "bom.json");
Path sbomDirPath = Path.of(
parent.getWorkdir().toAbsolutePath().toString(),
String.valueOf(getParent().getIndex()),
"bom.json");

try {
// Create all non-existent parent directories
Files.createDirectories(sbomDirPath.getParent());

ObjectMapperProvider.json()
.writerWithDefaultPrettyPrinter()
.writeValue(sbomDirPath.toFile(), toJsonNode(bom));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void generateDeliverableSbom(OperationConfig config, int i) {
command.add(configPath.toAbsolutePath().toString());

command.add("--index");
command.add(String.valueOf(index));
command.add(String.valueOf(i));

command.add("--workdir");
command.add(workdir.toAbsolutePath().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ protected List<Sbom> storeOperationSboms(GenerationRequest generationRequest) {
Path sbomPath = Path.of(
controllerConfig.sbomDir(),
generationRequest.getMetadata().getName(),
generationRequest.getMetadata().getName() + "-" + SbomGenerationPhase.OPERATIONGENERATE.ordinal()
+ "-" + SbomGenerationPhase.OPERATIONGENERATE.name().toLowerCase() + "-" + i,
SbomGenerationPhase.GENERATE.name().toLowerCase(),
String.valueOf(i),
"bom.json");

// Read the generated SBOM JSON file
Expand Down

0 comments on commit f8983d7

Please sign in to comment.