Skip to content

Export command piping of stdout causes issues from logging #149

@idunbarh

Description

@idunbarh

When piping with the bomctl export <SBOM_ID> command to other tools, the other tools fail because log output is also being sent.

gitpod /workspace/bomctl-playground (main) $ bomctl fetch https://raw.githubusercontent.com/bomctl/bomctl-playground/main/examples/bomctl-container-image/bomctl_bomctl_v0.3.0.cdx.json
INFO  fetch: Fetching from HTTP URL url=https://raw.githubusercontent.com/bomctl/bomctl-playground/main/examples/bomctl-container-image/bomctl_bomctl_v0.3.0.cdx.json
INFO  fetch: Fetching from HTTP URL url=https://raw.githubusercontent.com/bomctl/bomctl-playground/main/examples/bomctl-container-image/app/bomctl_0.3.0_linux_amd64.tar.gz.spdx.json
gitpod /workspace/bomctl-playground (main) $ bomctl ls

                        ID                        │ Version  │ # Nodes  
──────────────────────────────────────────────────┼──────────┼──────────
 urn:uuid:f360ad8b-dc41-4256-afed-337a04dff5db    │    1     │    6     
 bomctl_0.3.0_linux_amd64.tar.gz                  │    0     │    81    

gitpod /workspace/bomctl-playground (main) $ bomctl export urn:uuid:f360ad8b-dc41-4256-afed-337a04dff5db | grype
failed to catalog: unable to decode sbom: sbom format not recognized

If we pipe the stdout of bomctl export to a file, the file contents are ...

INFO  export: Exporting Document sbomID=urn:uuid:f360ad8b-dc41-4256-afed-337a04dff5db
{
  "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
  "bomFormat": "CycloneDX",
  "specVersion": "1.5",
  "serialNumber": "urn:uuid:f360ad8b-dc41-4256-afed-337a04dff5db",
  ...
}

... and the first line of INFO export: Exporting Document ... should not be in stdout.

bomctl version v0.3.1 (built on 2024-08-19T21:18:14Z)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions