
CLI para gerar, analisar, mesclar, comparar, validar, assinar e converter SBOMs CycloneDX nos formatos JSON, XML, Protobuf, CSV e SPDX.
______ __ ____ _ __ ________ ____
/ ____/_ _______/ /___ ____ ___ / __ \ |/ / / ____/ / / _/
/ / / / / / ___/ / __ \/ __ \/ _ \/ / / / / / / / / / /
/ /___/ /_/ / /__/ / /_/ / / / / __/ /_/ / | / /___/ /____/ /
\____/\__, /\___/_/\____/_/ /_/\___/_____/_/|_| \____/_____/___/
/____/
Usage:
cyclonedx [command] [options]
Options:
--version Show version information
-?, -h, --help Show help and usage information
Commands:
add Add information to a BOM (currently supports files)
analyze Analyze a BOM file
convert Convert between different BOM formats
diff <from-file> <to-file> Generate a BOM diff
keygen Generates an RSA public/private key pair for BOM signing
merge Merge two or more BOMs
sign Sign a BOM or file
validate Validate a BOM
verify Verify signatures in a BOM
A ferramenta CLI CycloneDX atualmente suporta análise, modificação, geração de diff, mesclagem, conversão de formato, assinatura e verificação de BOMs.
A conversão é suportada entre CycloneDX XML, JSON, Protobuf, CSV e SPDX JSON v2.3.
Os binários podem ser baixados da página de releases.
Nota: A ferramenta CLI CycloneDX foi desenvolvida para casos de uso de automação. Quaisquer comandos que tenham a opção --input-file também suportam entrada via stdin. Da mesma forma, quaisquer comandos que tenham a opção --output-file suportam saída para stdout. No entanto, você precisará fornecer os formatos de entrada/saída.
Por exemplo:
cat bom.json | cyclonedx-cli convert --input-format json --output-format xml > bom.xml
files
Add files to a BOM
Usage:
cyclonedx add files [options]
Options:
--input-file <input-file> Input BOM filename.
--no-input Use this option to indicate that there is no input BOM.
--output-file <output-file> Output BOM filename, will write to stdout if no value provided.
--input-format <autodetect|json|protobuf|xml> Specify input file format.
--output-format <autodetect|json|protobuf|xml> Specify output file format.
--base-path <base-path> Base path for directory to process (defaults to current working directory if omitted).
--include <include> Apache Ant style path and file patterns to specify what to include (defaults to all files, separate patterns with a space).
--exclude <exclude> Apache Ant style path and file patterns to specify what to exclude (defaults to none, separate patterns with a space).
Gerando um BOM de código-fonte, excluindo o diretório do repositório Git:
cyclonedx-cli add files --no-input --output-format json --exclude /.git/**
Adicionando arquivos de saída de build, do diretório bin, a um BOM existente:
cyclonedx-cli add files --input-file bom.json --output-format json --base-path bin
analyze
Analyze a BOM file
Usage:
cyclonedx analyze [options]
Options:
--input-file <input-file> Input BOM filename, will read from stdin if no value provided.
--input-format <autodetect|json|protobuf|xml> Specify input file format.
--output-format <json|text> Specify output format (defaults to text).
--multiple-component-versions Report components that have multiple versions in use.
Relatando componentes que são incluídos várias vezes com versões diferentes:
cyclonedx-cli analyze --input-file sbom.xml --multiple-component-versions
convert
Convert between different BOM formats
Usage:
cyclonedx convert [options]
Options:
--input-file <input-file> Input BOM filename, will read from stdin if no value provided.
--output-file <output-file> Output BOM filename, will write to stdout if no value provided.
--input-format <autodetect|csv|json|protobuf|spdxjson|xml> Specify input file format.
--output-format <autodetect|csv|json|protobuf|spdxjson|xml> Specify output file format.
--output-version <v1_0|v1_1|v1_2|v1_3|v1_4|v1_5|v1_6|v1_7> Specify output BOM specification version. (ignored for CSV and SPDX formats)
Convertendo do formato XML para JSON:
cyclonedx-cli convert --input-file sbom.xml --output-file sbom.json
Convertendo do formato XML para JSON e enviando a saída via pipe para outras ferramentas:
cyclonedx-cli convert --input-file sbom.xml --output-format json | grep "somthing"
O formato CSV é uma representação limitada da lista de componentes em um BOM.
A intenção é fornecer uma maneira simples para os usuários produzirem e consumirem BOMs para casos de uso simples. Incluindo casos de uso simples de migração de dados.
Os únicos campos obrigatórios são os campos name e version do componente. Os demais podem ser deixados em branco ou as colunas omitidas.
A conversão entre os formatos SPDX e CycloneDX pode resultar na perda de algumas informações. A funcionalidade de conversão é fornecida pela biblioteca CycloneDX.Spdx.Interop, que faz parte do projeto da biblioteca CycloneDX .NET.
Para mais detalhes sobre quais informações são perdidas, consulte a página do projeto CycloneDX .NET Library.
diff
Generate a BOM diff
Usage:
cyclonedx diff <from-file> <to-file> [options]
Arguments:
<from-file> From BOM filename.
<to-file> To BOM filename.
Options:
--from-format <autodetect|json|protobuf|xml> Specify from file format.
--to-format <autodetect|json|protobuf|xml> Specify to file format.
--output-format <json|text> Specify output format (defaults to text).
--component-versions Report component versions that have been added, removed or modified.
Relatando componentes com alterações de versão:
cyclonedx-cli diff sbom-from.xml sbom-to.xml --component-versions
keygen
Generates an RSA public/private key pair for BOM signing
Usage:
cyclonedx keygen [options]
Options:
--private-key-file <private-key-file> Filename for generated private key file (defaults to "private.key")
--public-key-file <public-key-file> Filename for generated public key file (defaults to "public.key")
merge
Merge two or more BOMs
Usage:
cyclonedx merge [options]
Options:
--input-files <input-files> Input BOM filenames (separate filenames with a space).
--output-file <output-file> Output BOM filename, will write to stdout if no value provided.
--input-format <autodetect|json|protobuf|xml> Specify input file format.
--output-format <autodetect|json|protobuf|xml> Specify output file format.
--output-version <v1_0|v1_1|v1_2|v1_3|v1_4|v1_5|v1_6|v1_7> Specify output BOM specification version.
--hierarchical Perform a hierarchical merge.
--group <group> Provide the group of software the merged BOM describes.
--name <name> Provide the name of software the merged BOM describes (required for hierarchical merging).
--version <version> Provide the version of software the merged BOM describes (required for hierarchical merging).
Nota: Para realizar uma mesclagem hierárquica, todos os BOMs precisam ter o assunto do BOM descrito no elemento de componente dos metadados.
Mesclar dois BOMs formatados em XML:
cyclonedx-cli merge --input-files sbom1.xml sbom2.xml --output-file sbom_all.xml
Mesclando dois BOMs e enviando a saída via pipe para outras ferramentas:
cyclonedx-cli merge --input-files sbom1.xml sbom2.xml --output-format json | grep "something"
Assina um BOM ou arquivo
bom
Sign the entire BOM document
Usage:
cyclonedx sign bom <bom-file> [options]
Arguments:
<bom-file> BOM filename
Options:
--key-file <key-file> Signing key filename (RSA private key in PEM format, defaults to "private.key")
file
Sign arbitrary files and generate a PKCS1 RSA SHA256 signature file
Usage:
cyclonedx sign file <file> [options]
Arguments:
<file> Filename of the file the signature will be created for
Options:
--key-file <key-file> Signing key filename (RSA private key in PEM format, defaults to "private.key")
--signature-file <signature-file> Filename of the generated signature file (defaults to the filename with ".sig" appended)
validate
Validate a BOM
Usage:
cyclonedx validate [options]
Options:
--input-file <input-file> Input BOM filename, will read from stdin if no value provided.
--input-format <autodetect|json|xml> Specify input file format.
--input-version <v1_0|v1_1|v1_2|v1_3|v1_4|v1_5|v1_6|v1_7> Specify input file specification version (defaults to v1.7)
--fail-on-errors Fail on validation errors (return a non-zero exit code)
Valide o BOM e retorne um código de saída diferente de zero (útil para "quebrar" automaticamente um build, etc)
cyclonedx-cli validate --input-file sbom.xml --fail-on-errors
Verifica assinaturas de BOMs e arquivos
all
Verify all signatures in a BOM
Usage:
cyclonedx verify all <bom-file> [options]
Arguments:
<bom-file> BOM filename
Options:
--key-file <key-file> Public key filename (RSA public key in PEM format, defaults to "public.key")
file
Verifies a PKCS1 RSA SHA256 signature file for an arbitrary file
Usage:
cyclonedx verify file <file> [options]
Arguments:
<file> File the signature file is for
Options:
--key-file <key-file> Public key filename (RSA public key in PEM format, defaults to "public.key")
--signature-file <signature-file> Signature file to be verified (defaults to the filename with ".sig" appended)
A ferramenta CLI CycloneDX também pode ser executada usando docker docker run cyclonedx/cyclonedx-cli.
Para Linux e MacOS, a CLI pode ser instalada por meio do CycloneDX Homebrew tap:
brew install cyclonedx/cyclonedx/cyclonedx-cli
Builds com suporte oficial estão disponíveis para estas plataformas:
Builds com suporte da comunidade estão disponíveis para estas plataformas:
As dependências de runtime do .NET Core são necessárias.
Para Windows, elas devem estar pré-instaladas.
Para Ubuntu, são: libc6 libgcc1 libgssapi-krb5-2 libicu66 libssl1.1 libstdc++6 zlib1g.
gron transforma JSON em atribuições discretas para facilitar a busca (grep) pelo que você deseja e ver o 'caminho' absoluto até ele.
Para sua conveniência, o gron está incluído na imagem Docker da CLI CycloneDX.
Exemplo de uso que lista todos os nomes e versões de componentes
$ gron bom-1.2.json | grep -E "(components\[[[:digit:]]*\].name)|(components\[[[:digit:]]*\].version)"
json.components[0].name = "tomcat-catalina";
json.components[0].version = "9.0.14";
json.components[1].name = "mylibrary";
json.components[1].version = "1.0.0";
Ou o mesmo usando um BOM em formato XML
$ cyclonedx convert --input-file bom.xml --output-format json | gron | grep -E "(components\[[[:digit:]]*\].name)|(components\[[[:digit:]]*\].version)"
json.components[0].name = "tomcat-catalina";
json.components[0].version = "9.0.14";
json.components[1].name = "mylibrary";
json.components[1].version = "1.0.0";
Para mais detalhes sobre o uso do gron, consulte a página do projeto gron.
Para mais detalhes sobre o uso do grep, consulte a página de manual do grep.
A permissão para modificar e redistribuir é concedida sob os termos da licença Apache 2.0. Consulte o arquivo LICENSE para obter a licença completa.
Pull requests são bem-vindos. Mas leia primeiro as diretrizes de contribuição do CycloneDX.
Para compilar e testar a solução localmente, você deve ter o .NET 8 instalado. Comandos padrão como dotnet build e dotnet test funcionam.
É geralmente esperado que pull requests incluam testes relevantes. Os testes são executados automaticamente no Windows, MacOS e Linux para cada pull request. Avisos de build quebrarão o build.
Por favor, informe-nos se estiver tendo problemas para depurar um teste que está falhando em uma plataforma à qual você não tem acesso.