Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make cyclonedx report how many components it imported #314

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion components/producers/cdxgen/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
name: producer-cdxgen
labels:
v1.dracon.ocurity.com/component: producer
v1.dracon.ocurity.com/test-type: sbom
v1.dracon.ocurity.com/language: all
spec:
description: Generate a CycloneDX SBOM from source code.
params:
Expand Down Expand Up @@ -41,7 +43,8 @@ spec:
value: $(params.producer-cdxgen-astgen-ignore-file-pattern)
- name: ASTGEN_IGNORE_DIRS
value: $(params.producer-cdxgen-astgen-ignore-dirs)
script: node /opt/cdxgen/bin/cdxgen.js -r -p -o /scratch/out.json $(workspaces.output.path)/ --spec-version 1.4
script: |
node /opt/cdxgen/bin/cdxgen.js -r -p -o /scratch/out.json $(workspaces.output.path)/ --spec-version 1.4
volumeMounts:
- mountPath: /scratch
name: scratch
Expand Down
2 changes: 1 addition & 1 deletion examples/pipelines/cdxgen-project/pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
pipelineRef:
name: dracon-cdxgen-project
params:
- name: repository_url
- name: git-clone-url
value: https://github.com/ocurity/e2e-monorepo.git
- name: b64-signature-key
# THIS IS AN EXAMPLE, PLEASE USE A PROPERLY SECURED SECRET KEY IN PRODUCTION
Expand Down
7 changes: 7 additions & 0 deletions pkg/cyclonedx/cyclonedx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cyclonedx
import (
"bytes"
"fmt"
"log/slog"
"strings"

cdx "github.com/CycloneDX/cyclonedx-go"
Expand All @@ -27,6 +28,12 @@ func ToDracon(inFile []byte, format string) ([]*v1.Issue, error) {
if err := decoder.Decode(bom); err != nil {
return issues, err
}
componentLen := 0
if bom.Components != nil {
componentLen = len(*bom.Components)
}
slog.Info(fmt.Sprintf("Successfully parsed CycloneDX BOM, recorded %d components", componentLen))

buf := new(bytes.Buffer)
// Encode the BOM
err := cdx.NewBOMEncoder(buf, cdx.BOMFileFormatJSON).SetPretty(false).Encode(bom)
Expand Down