Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ The command line options are aligned to the standard Conan options.

```text
$ cyclonedx-conan --help
usage: command.py [-h] [-if INSTALL_FOLDER] [-db [DRY_BUILD]] [-b [BUILD]] [-r REMOTE] [-u] [-l LOCKFILE] [--lockfile-out LOCKFILE_OUT]
[-e ENV_HOST] [-e:b ENV_BUILD] [-e:h ENV_HOST] [-o OPTIONS_HOST] [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST]
[-pr PROFILE_HOST] [-pr:b PROFILE_BUILD] [-pr:h PROFILE_HOST] [-s SETTINGS_HOST] [-s:b SETTINGS_BUILD]
[-s:h SETTINGS_HOST] [-c CONF_HOST] [-c:b CONF_BUILD] [-c:h CONF_HOST]
usage: command.py [-h] [-if INSTALL_FOLDER] [-db [DRY_BUILD]] [--output FILE_PATH] [-b [BUILD]] [-r REMOTE] [-u] [-l LOCKFILE]
[--lockfile-out LOCKFILE_OUT] [-e ENV_HOST] [-e:b ENV_BUILD] [-e:h ENV_HOST] [-o OPTIONS_HOST] [-o:b OPTIONS_BUILD]
[-o:h OPTIONS_HOST] [-pr PROFILE_HOST] [-pr:b PROFILE_BUILD] [-pr:h PROFILE_HOST] [-s SETTINGS_HOST]
[-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST] [-c CONF_HOST] [-c:b CONF_BUILD] [-c:h CONF_HOST]
path_or_reference

CycloneDX SBOM Generator
Expand All @@ -63,6 +63,8 @@ optional arguments:
setting/option it will raise an error.
-db [DRY_BUILD], --dry-build [DRY_BUILD]
Apply the --build argument to output the information, as it would be done by the install command
--output FILE_PATH
Output file path for your SBOM (set to '-' to output to STDOUT)
-b [BUILD], --build [BUILD]
Given a build policy, return an ordered list of packages that would be built from sources during the install
command
Expand Down
13 changes: 11 additions & 2 deletions src/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def get_arg_parser() -> argparse.ArgumentParser:
dry_build_help = ("Apply the --build argument to output the information, "
"as it would be done by the install command")
parser.add_argument("-db", "--dry-build", action=Extender, nargs="?", help=dry_build_help)
output_help='Output file path for your SBOM (set to \'-\' to output to STDOUT)'
parser.add_argument(
'--output', action='store', metavar='FILE_PATH', default="-", required=False,
help=output_help, dest='output_file'
)
build_help = ("Given a build policy, return an ordered list of packages that would be built"
" from sources during the install command")

Expand Down Expand Up @@ -144,8 +149,12 @@ def execute(self):
dependencies['dependsOn'].append(str(dep_purl))
bom['dependencies'].append(dependencies)

print(json.dumps(bom, indent=2))

output = json.dumps(bom, indent=2)
if self._arguments.output_file == '-' or not self._arguments.output_file:
print(output)
else:
with open(self._arguments.output_file, "w") as file:
file.write(output)

def get_purl(remote, ref):
qualifiers = {
Expand Down