GitHub user ppkarwasz added a comment to the discussion: CloudStack SBOM improvements
As a starter for a discussion, I analyzed what ends up in the Debian `*.deb` packages, with particular attention to what no scanner (or almost no scanner) will find on an installed system. Scanners look for manifest files, compute hashes (e.g. to find the corresponding file in Maven Central or other content-indexed registries) or look for symbols in binaries. It is easy to throw them off (intentionally or, usually, unintentionally), but a `*.cdx.json` file, even in the `/usr/share/doc` folder of the package, will allow a scanner to retrieve a (possibly partially duplicate, because already detected) set of components that are in the system. ## Ghost components in `cloudstack-management` I ran `syft` on the extracted `cloudstack-management_4.23.0.0_all.deb`. It reports **25 components**: 9 JARs and the 16 Go modules of `cmk`. This is what it does **not** see: | Ghost | Where | Why scanners miss it | |---|---|---| | ~320 third-party Maven libraries (Spring, Jetty, CXF, Jackson, Netty, AWS SDK, ...) | shaded into `lib/cloudstack-4.23.0.0.jar` (264 MB, 193 000 classes) | All `META-INF/maven/**/pom.properties` are gone and the JAR's hash matches nothing in Maven Central. `syft` reports a single component, `cloudstack 4.23.0.0`. | | 71 native libraries (JNA, snappy-java, Netty epoll, ...), for Linux but also Windows, macOS and Solaris | inside the same shaded JAR | They are neither Java libraries nor files on the system: nothing catalogs a `.so` inside a JAR inside a package. | | ~130 npm packages (Vue, Ant Design, axios, ...) | bundled by webpack into the 483 files of `webapp/js` | A bundle has no `package.json` and no lockfile. The names are only visible in the `*.js.map` files that happen to be shipped, which no scanner reads. | The 9 JARs that *are* found are exactly those copied as-is into `lib/` (Bouncy Castle, MySQL Connector/J, Linstor, ...), next to the shaded JAR. `cmk` is found too, because Go binaries embed their module list. So the ghosts are not a limit of the scanners: they come from how we package. `cloudstack-common` has more of them, for example code copied into the source tree rather than declared as a dependency, like noVNC and jQuery in `systemvm/agent`, which ends up in `agent.zip` and in the system VMs. ## Can't the build tools tell us? For the shaded JAR, not yet. Support for the Maven Shade Plugin in the CycloneDX Maven Plugin was requested in CycloneDX/cyclonedx-maven-plugin#472 two and a half years ago, and it is finally going forward thanks to @hboutemy in CycloneDX/cyclonedx-maven-plugin#696. That PR teaches the plugin to tell, from the packaging plugins that run, which dependencies are embedded in the artifact and which are only required (CycloneDX 1.7 `isExternal`). We are not there yet: the PR is still open, Shade's configuration is flexible enough to need more work, and a module that produces both a plain and a shaded JAR still gets a single SBOM. In the meantime, I put together an experiment on top of #14570: [`ppkarwasz:sbom-phase1`](https://github.com/apache/cloudstack/compare/sbom-profile...ppkarwasz:cloudstack:sbom-phase1). It produces one SBOM per Maven module, which matches the JARs that `debian/rules` copies into each package by hash, pins the `cmk` download, and lists Marvin's Python requirements as external components. The [plan](https://github.com/ppkarwasz/cloudstack/blob/sbom-phase1/packaging/sbom/PLAN.md) describes how these pieces could be assembled into one SBOM per `.deb`. ## What could make CloudStack more detectable Some modifications of CloudStack might also be beneficial to have a more detectable set of embedded components: - **Stop shading `cloudstack.jar`.** The management server already starts with `lib/*` on the classpath, so the third-party JARs could be copied unchanged, like the 9 above. Every one of them would then be identifiable by its hash, and its signature (if any) would stay valid. This would also sidestep the Shade problem above. - **Ship only the native libraries we run.** Windows, macOS and Solaris binaries can't run on a Debian system, but they still show up in vulnerability reports. - **Ship an SBOM in each package**, e.g. `/usr/share/doc/cloudstack-management/cloudstack-management.cdx.json`, so that a scanner on the installed system can fill in what it cannot discover by itself. GitHub link: https://github.com/apache/cloudstack/discussions/14657#discussioncomment-19515818 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
