JavaScript vulnerability management does not end with generating a dependency list. Generating an SBOM with Syft in CI and uploading it to Dependency-Track is useful for obtaining a reproducible dependency list, but whether that list matches the code actually included in a service remains a separate issue. A lockfile contains many packages, while only some make it into the final bundle, and determining whether the vulnerable code paths are even reachable requires yet another assessment.
Therefore, artifact vulnerability verification should be the next step after generating an SBOM. Mixing potential vulnerabilities, build-stage vulnerabilities, and direct risks in the final artifact under the same rating can inflate CVE counts because of development packages while obscuring the actual remediation order. The solution is not to abandon lockfile scanning, but to explicitly manage the differences between the lockfile and deployed artifacts.
Why the Full Lockfile Becomes an Excessive Candidate List
A lockfile records packages that never enter the final browser code, including development servers, bundlers, and test tools. For an SPA, excluding devDependencies can mitigate this to some extent, but in a Laravel structure, NPM packages are placed in devDependencies, making it difficult to describe the server-side build configuration based on that classification alone. Therefore, the first question is not the category name, but whether the package remains in the deployed artifact.
The same problem appears in a original thread about scanning JavaScript CVEs. Its central question is how to distinguish packages in the lockfile from packages included in the bundle, and it also presents an experience suggesting that generating sourcemaps can significantly reduce the results. Sourcemaps are useful clues, but they are not verification results that can be included with public assets.
Do Not Mix Two SBOMs into One Result
The recommended pipeline is to scan source dependencies and deployed artifacts separately. At the source stage, generate a lockfile-based SBOM to manage missing dependencies and update candidates. At the deployment stage, rescan the built public assets or final container image. In Dependency-Track, do not treat both results as identical evidence for the same asset; preserve the difference between the potential source list and the deployed inclusion list as a separate stage.
The source directory and build output can be managed as separate artifacts.
※ Note: The following is a conceptual simulation example (Illustrative Example, not official spec)
The following commands are a basic form of generating package lists for the working directory and build output.
npm ci
npm run build
syft dir:. -o cyclonedx-json > sbom-source.json
syft dir:public/build -o cyclonedx-json > sbom-build.json
Actual paths and build scripts should be adapted to the project structure. For a Laravel application, separately verify whether NPM dependencies are included in the final build configuration. The build output and files included in the deployment image should serve as the basis, rather than the classification in package.json.
Compare Inclusion in Bundles and Deployment Images
For typical frontend assets, inspect the final app.js and, if necessary, analyze the sourcemap generated during the build to compare bundle inclusion. Keep sourcemaps as analysis artifacts and exclude them from deployment images. The criterion should be the code paths that remain in the final bundle, not the number of lockfile entries.
Deployment verification must go one step further. Scanning the container image created in CI as-is makes it possible to confirm the separation between build tools and runtime files. Items in the artifact vulnerability verification results that are included in operational assets should receive a high remediation priority, while development, build-stage, and reproducibility-verification items should be managed under a separate policy.
Can You Trust Sourcemaps Alone?
Sourcemaps are important clues when comparing the lockfile with the bundle, but they do not prove inclusion in the deployed artifact by themselves. Therefore, use sourcemaps as supporting evidence and verify the files inside the deployment image and reachable code paths together.
Unconditionally upgrading every package because the CVE count is low is also risky. Updates should be decided only after checking whether the vulnerable package is included in the deployed artifact, whether its execution path is reachable, and whether the code is used. This approach preserves lockfile scanning while avoiding indiscriminate changes intended merely to reduce CVE counts.
In practice, store the lockfile SBOM as the list of potential source dependencies and identify the location of public assets after the build. Generate SBOMs for the source and build outputs separately with Syft, compare their differences, and identify runtime packages separately in the final container image. Add a CI rule that checks deployment inclusion and execution paths whenever an upgrade alert is received.
Practical Implementation Points
- Confirm coordination and approval paths with relevant teams
- Conduct advance impact testing in an isolated environment
- Establish a phased rollout and emergency rollback plan
Original Source
This article was written after reviewing the following original source: r/devops — How do I actually scan for CVEs for Javascript?

Leave a Reply