From ce7092eba3f29ba8bc66cca8174f06ee989f92e7 Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Sun, 10 Sep 2023 16:19:05 +0200 Subject: [PATCH] fix: check for metadata before accessing --- .../src/main/java/io/github/algomaster99/Options.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/watchdog-agent/src/main/java/io/github/algomaster99/Options.java b/watchdog-agent/src/main/java/io/github/algomaster99/Options.java index f5a1af68..e4c5db99 100644 --- a/watchdog-agent/src/main/java/io/github/algomaster99/Options.java +++ b/watchdog-agent/src/main/java/io/github/algomaster99/Options.java @@ -7,6 +7,7 @@ import io.github.algomaster99.terminator.commons.cyclonedx.Bom14Schema; import io.github.algomaster99.terminator.commons.cyclonedx.Component; import io.github.algomaster99.terminator.commons.cyclonedx.CycloneDX; +import io.github.algomaster99.terminator.commons.cyclonedx.Metadata; import io.github.algomaster99.terminator.commons.fingerprint.JdkIndexer; import io.github.algomaster99.terminator.commons.fingerprint.classfile.ClassFileAttributes; import io.github.algomaster99.terminator.commons.fingerprint.classfile.ClassfileVersion; @@ -123,7 +124,12 @@ public Path getOutput() { } private void processRootComponent(Bom14Schema sbom) throws IOException, InterruptedException { - Component rootComponent = sbom.getMetadata().getComponent(); + Metadata metadata = sbom.getMetadata(); + if (metadata == null) { + LOGGER.warn("Metadata is not present."); + return; + } + Component rootComponent = metadata.getComponent(); if (rootComponent == null) { LOGGER.warn("Root component is not present."); return;