From 48ad23597fb3812426c92cdc52631b0dd630c34c Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Sat, 7 Oct 2023 18:37:46 +0100 Subject: [PATCH] Potential fix for 619. Server.js is imported as a dynamic import Signed-off-by: Prabhu Subramanian --- README.md | 8 ++++++++ bin/cdxgen.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7cc820e6b..ee841febe 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,14 @@ Arguments can be passed either via the query string or as a JSON body. The follo | projectGroup | Dependency track project group | | projectVersion | Dependency track project version [default: ""] | +### Health endpoint + +Use the /health endpoint to check if the SBOM server is up and running. + +```shell +curl "http://127.0.0.1:9090/health" +``` + ### Scanning a local path ```shell diff --git a/bin/cdxgen.js b/bin/cdxgen.js index 1fc0f09a1..738d04aa7 100755 --- a/bin/cdxgen.js +++ b/bin/cdxgen.js @@ -7,7 +7,6 @@ import { tmpdir } from "node:os"; import { basename, dirname, join, resolve } from "node:path"; import jws from "jws"; import crypto from "node:crypto"; -import { start as _serverStart } from "../server.js"; import { fileURLToPath } from "node:url"; import globalAgent from "global-agent"; import process from "node:process"; @@ -243,7 +242,8 @@ const checkPermissions = (filePath) => { (async () => { // Start SBOM server if (args.server) { - return await _serverStart(options); + const serverModule = await import("../server.js"); + return await serverModule.start(options); } // Check if cdxgen has the required permissions if (!checkPermissions(filePath)) {