cdxgen: Unable to create SBOM with CDXGen 11

Hello,

I’m attemping to create an SBOM for an open source project (https://github.com/aws-solutions/connected-mobility-solution-on-aws for example) with the latest version of CDXGen and no SBOM is being generated.

When I use version 10 (specific version currently 10.2.6), the SBOM is generated.

Command used:

CDXGEN_DEBUG_MODE=debug FETCH_LICENSE=true cdxgen -t universal --spec-version 1.5 -o bom-1.5.json

No error is output, just returns to a prompt and no file is generated.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26 (13 by maintainers)

Commits related to this issue

Most upvoted comments

It looks like it’s casting the evidence.identity to an Array, then iterating through it to add appropriate methods.

I was thinking that the boolean value of Array.isArray(comp.evidence.identity); could be saved as a variable then after the logic is completed, cast it back to an object with something like:

if (!isArray) {
          existingComponent.evidence = {
            identity: existingComponent.evidence.identity[0]
          };
        }

Do you think that would accomplish the goal of the logic here or am I missing something that could cause adverse effects elsewhere?

Ok - I’ll look into it. Thank you!

Thank you. Since it is merged, please test with the master branch.

Well done! Please share a pull request once you are happy.

I think I found the other part for the validation issue!

I think this: https://github.com/CycloneDX/cdxgen/blob/0f1a142123a638c6ea1013c03e00d7a179ac6375/lib/cli/index.js#L4953

Should be:

const mbomData = await createMultiXBom(path, {
      ...options,
      projectType: [],
      multiProject: true,
      excludeType: options.excludeType,
    });

Still have to dig deeper into the license issue

I’m not quite at the bottom of what the root cause of either issue but this is what I know so far.

For the just stopping with out error issue I’m running into, it has something to do with fetching the license for the https://api.github.com/repos/cowboy/node-exit package but haven’t quite figured out WHAT about that is causing it to fail silently but it’s pretty consistently stopping at that package.

For the validation error, it’s because the specVersion isn’t included in the options sent for that package (it’s from a docker image, not sure if that matters).

The options passed to the addComponent function for the pkg:npm/npm@10.8.2 package are:

{
  "projectType": [
    "oci"
  ],
  "multiProject": true,
  "installDeps": false,
  "path": "public.ecr.aws/docker/library/node:18.20-bullseye-slim",
  "parentComponent": {},
  "exportData": {
    "inspectData": {
      "Id": "sha256:ff88d1409ac9cbe3186174cca0a949308f77a419d3411024e2b4e84f980f1246",
      "RepoTags": [
        "public.ecr.aws/docker/library/node:18.20-bullseye-slim"
      ],
      "RepoDigests": [
        "public.ecr.aws/docker/library/node@sha256:5f3ae2bd02f4f4dd2e886c42de4c5856fb99dab6b36edd4e8064983db42fd8fc"
      ],
      "Parent": "",
      "Comment": "buildkit.dockerfile.v0",
      "Created": "2024-11-15T23:05:18Z",
      "DockerVersion": "",
      "Author": "",
      "Config": {
        "Hostname": "",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
          "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
          "NODE_VERSION=18.20.5",
          "YARN_VERSION=1.22.22"
        ],
        "Cmd": [
          "node"
        ],
        "Image": "",
        "Volumes": null,
        "WorkingDir": "",
        "Entrypoint": [
          "docker-entrypoint.sh"
        ],
        "OnBuild": null,
        "Labels": null
      },
      "Architecture": "arm64",
      "Variant": "v8",
      "Os": "linux",
      "Size": 192281593,
      "GraphDriver": {
        "Data": {
          "LowerDir": "/var/lib/docker/overlay2/75cd24386b60fe77b48b08ad5087e9b1688ea96cef05b888ce8ad92efd74a0fb/diff:/var/lib/docker/overlay2/6f21ffbcb0d003546684a70f5947f120d2b8a8b0b09fbd181be62c7123ec52eb/diff:/var/lib/docker/overlay2/d5c0ac1e6be8c636a220e745ee7a6c411ef259631acdb876fef3c98d45df0c66/diff:/var/lib/docker/overlay2/cef7014313eaa6356b4dc5c418a0bee73003e6a5c040bf31ee6f7722d364ff35/diff",
          "MergedDir": "/var/lib/docker/overlay2/60cc3194a96a52745518fb8a33adf34033f62f19c5007ca34aed1a311ad24801/merged",
          "UpperDir": "/var/lib/docker/overlay2/60cc3194a96a52745518fb8a33adf34033f62f19c5007ca34aed1a311ad24801/diff",
          "WorkDir": "/var/lib/docker/overlay2/60cc3194a96a52745518fb8a33adf34033f62f19c5007ca34aed1a311ad24801/work"
        },
        "Name": "overlay2"
      },
      "RootFS": {
        "Type": "layers",
        "Layers": [
          "sha256:ff80ec55a37609daeaf3d3843aa8105f6c6b18984cf42badda290363444bdef3",
          "sha256:e71558f9e3c53b576de3e32837c2aaaebaf4338c93180bad83ff1a5991848e21",
          "sha256:f15431b9f121cd58d5aebea5098d3f0638a97b3711dd8a43cd795da43acfffe0",
          "sha256:d90cc8aa5a94bc516e5a9971c27e3017c4e0e7f5388c9e425623c0f78e892b84",
          "sha256:48657769e4a3b1ff65b621f217c6d77b9b7e1ab34952d7424df5cb95041a0819"
        ]
      },
      "Metadata": {
        "LastTagTime": "0001-01-01T00:00:00Z"
      }
    },
    "manifest": [
      {
        "Config": "blobs/sha256/ff88d1409ac9cbe3186174cca0a949308f77a419d3411024e2b4e84f980f1246",
        "RepoTags": [
          "public.ecr.aws/docker/library/node:18.20-bullseye-slim"
        ],
        "Layers": [
          "blobs/sha256/ff80ec55a37609daeaf3d3843aa8105f6c6b18984cf42badda290363444bdef3",
          "blobs/sha256/e71558f9e3c53b576de3e32837c2aaaebaf4338c93180bad83ff1a5991848e21",
          "blobs/sha256/f15431b9f121cd58d5aebea5098d3f0638a97b3711dd8a43cd795da43acfffe0",
          "blobs/sha256/d90cc8aa5a94bc516e5a9971c27e3017c4e0e7f5388c9e425623c0f78e892b84",
          "blobs/sha256/48657769e4a3b1ff65b621f217c6d77b9b7e1ab34952d7424df5cb95041a0819"
        ],
        "LayerSources": {
          "sha256:48657769e4a3b1ff65b621f217c6d77b9b7e1ab34952d7424df5cb95041a0819": {
            "mediaType": "application/vnd.oci.image.layer.v1.tar",
            "size": 3584,
            "digest": "sha256:48657769e4a3b1ff65b621f217c6d77b9b7e1ab34952d7424df5cb95041a0819"
          },
          "sha256:d90cc8aa5a94bc516e5a9971c27e3017c4e0e7f5388c9e425623c0f78e892b84": {
            "mediaType": "application/vnd.oci.image.layer.v1.tar",
            "size": 7270400,
            "digest": "sha256:d90cc8aa5a94bc516e5a9971c27e3017c4e0e7f5388c9e425623c0f78e892b84"
          },
          "sha256:e71558f9e3c53b576de3e32837c2aaaebaf4338c93180bad83ff1a5991848e21": {
            "mediaType": "application/vnd.oci.image.layer.v1.tar",
            "size": 350208,
            "digest": "sha256:e71558f9e3c53b576de3e32837c2aaaebaf4338c93180bad83ff1a5991848e21"
          },
          "sha256:f15431b9f121cd58d5aebea5098d3f0638a97b3711dd8a43cd795da43acfffe0": {
            "mediaType": "application/vnd.oci.image.layer.v1.tar",
            "size": 112338944,
            "digest": "sha256:f15431b9f121cd58d5aebea5098d3f0638a97b3711dd8a43cd795da43acfffe0"
          },
          "sha256:ff80ec55a37609daeaf3d3843aa8105f6c6b18984cf42badda290363444bdef3": {
            "mediaType": "application/vnd.oci.image.layer.v1.tar",
            "size": 78080000,
            "digest": "sha256:ff80ec55a37609daeaf3d3843aa8105f6c6b18984cf42badda290363444bdef3"
          }
        }
      }
    ],
    "allLayersDir": "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh",
    "allLayersExplodedDir": "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers",
    "lastLayerConfig": {},
    "lastWorkingDir": "",
    "pkgPathList": [
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/usr/local/go",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/usr/local/lib",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/usr/local/lib64",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/opt",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/home",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/usr/share",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/usr/src",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/var/www/html",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/var/lib",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/mnt",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/usr/lib",
      "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers/usr/lib64"
    ]
  },
  "lastWorkingDir": "",
  "allLayersExplodedDir": "/var/folders/ql/tpm1cdw13bq5vdxgzchnyx0r0000gr/T/docker-images-HxDBVh/all-layers",
  "createMultiXBom": true,
  "allOSComponentTypes": [
    "bullseye",
    "deb",
    "debian",
    "debian-11"
  ],
  "exclude": [
    "**/vendor/**"
  ]
}

Since the version is missing, it’s not true for the if statement if (options.specVersion < 1.6) because it’s undefined and thus doesn’t get removed.

From looking at your command I saw what was going on - I was missing the final . in the command so it became:

CDXGEN_DEBUG_MODE=debug FETCH_LICENSE=true cdxgen -t universal --spec-version 1.5 -o bom.json .

Once I did that, it ran but I’m also getting a validation error - different from what you found:

Obtained 4846 components and 4593 dependencies after dedupe.
Received 5245 unfiltered components 4593 dependencies so far.
Obtained 5134 components and 4593 dependencies after dedupe.
Schema validation failed for cms-vehicle-simulator-console
[
  {
    instancePath: '/components/206',
    schemaPath: '#/additionalProperties',
    keyword: 'additionalProperties',
    params: { additionalProperty: 'authors' },
    message: 'must NOT have additional properties',
    schema: false,
    parentSchema: {
      type: 'object',
      title: 'Component Object',
      required: [Array],
      additionalProperties: false,
      properties: [Object]
    },
    data: {
      author: 'GitHub Inc.',
      authors: undefined,
      publisher: undefined,
      group: '',
      name: 'npm',
      version: '10.8.2',
      description: 'a package manager for JavaScript',
      scope: undefined,
      licenses: [Array],
      purl: 'pkg:npm/npm@10.8.2',
      externalReferences: [Array],
      type: 'library',
      'bom-ref': 'pkg:npm/npm@10.8.2',
      properties: [Array]
    }
  }
]