Parcourir la source

fix(sbom): leave packages reached only as optional peers out of the webui SBOM

npm marks vite and its toolchain devOptional because vue-router lists vite
as an optional peer. syft only skips packages marked dev, so they were
listed as shipped. The webui is a bundle, so nothing reached that way
ships.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread il y a 20 heures
Parent
commit
506f7d4ab1
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7 1
      var/sbom/generate.sh

+ 7 - 1
var/sbom/generate.sh

@@ -30,7 +30,13 @@ trap 'rm -rf "${STAGE}"' EXIT
 
 mkdir -p "${STAGE}/bin" "${STAGE}/webui"
 cp "${BINARY}" "${STAGE}/bin/OliveTin"
-cp "${REPO_ROOT}/frontend/package.json" "${REPO_ROOT}/frontend/package-lock.json" "${STAGE}/webui/"
+cp "${REPO_ROOT}/frontend/package.json" "${STAGE}/webui/"
+
+# npm marks a package devOptional when production code reaches it only as an
+# optional peer, for example vite through vue-router. The webui is a bundle, so
+# nothing reached that way ships; mark it dev so syft leaves it out.
+jq '.packages |= map_values(if .devOptional == true then .dev = true else . end)' \
+  "${REPO_ROOT}/frontend/package-lock.json" > "${STAGE}/webui/package-lock.json"
 
 SYFT_JAVASCRIPT_INCLUDE_DEV_DEPENDENCIES=false syft scan "dir:${STAGE}" \
   --source-name OliveTin \