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

Add support for multiple output files in different formats #732

Merged
merged 24 commits into from
Jan 6, 2022

Conversation

kzantow
Copy link
Contributor

@kzantow kzantow commented Jan 3, 2022

This PR adds support for multiple -o / --output options (and similarly in yaml). It continues to support the yaml syntax with a single option of output: 'json'. Additionally, each output option can specify a file by appending =<file>. For example, to output a Syft JSON and SPDX JSON, one could use: syft -o json=my.syft.json -o spdx-json=my.spdx.json

TODO:

  • refactor all references to presenter
  • add tests

Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
README.md Show resolved Hide resolved
cmd/packages.go Outdated Show resolved Hide resolved
cmd/packages.go Outdated Show resolved Hide resolved
)

flags.StringP(
"file", "", "",
"file to write the report output to (default is STDOUT)",
"file to write the default report output to (default is STDOUT)",
Copy link
Contributor Author

@kzantow kzantow Jan 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be deprecated? if so, how would that be done? just updates to this and the readme?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is -o intended to replace --file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know, but the functionality is redundant. it would seem outputting a table to a file is fairly useless, so generally a user would have to do -o spdx-json --file <output-file>, for example. But this is already covered by the -o spdx-json=<output-file>...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point on redundancy.

My take: I think it makes sense to leave the --file flag as it's not harming anything by leaving it. We probably don't need to add a deprecation notice if we aren't removing it (we could always decide to remove it in the future).

syft/event/parsers/parsers.go Outdated Show resolved Hide resolved
kzantow added 11 commits January 4, 2022 10:47
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
@kzantow kzantow marked this pull request as ready for review January 6, 2022 00:34
@kzantow kzantow requested a review from a team January 6, 2022 14:26
internal/output/writer.go Outdated Show resolved Hide resolved
cmd/output_writer_test.go Outdated Show resolved Hide resolved
cmd/power_user.go Outdated Show resolved Hide resolved
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I only had minor code comments --can you also add a CLI test to test the wiring of multiple -o options and assert the formats were written correctly? I think we have some helpers that could get repurposed for this.

Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍 nice work!

@kzantow kzantow merged commit 5e5312c into anchore:main Jan 6, 2022
@kzantow kzantow deleted the multiple-sbom-outputs branch January 6, 2022 22:52
@kzantow kzantow linked an issue Jan 6, 2022 that may be closed by this pull request
@seabass-labrax
Copy link

Great addition; thanks! 😃

spiffcs added a commit that referenced this pull request Jan 19, 2022
…hub.com/hectorj2f/syft into hectorj2f/add_dependencies_to_cyclonedx

* 'hectorj2f/add_dependencies_to_cyclonedx' of https://github.com/hectorj2f/syft: (29 commits)
  Improve CycloneDX format output (#710)
  Add additional PHP metadata (#753)
  Update Syft formats for SyftJson (#752)
  Add support for "file" source type in syftjson unmarshaling (#750)
  remove contains file from spdx dependency generation
  support .sar for java ecosystem (#748)
  Start developer documentation (#746)
  Align SPDX export more with SPDX 2.2 specification (#743)
  Replace distro type (#742)
  update goreleaser with windows checksums (#740)
  bump stereoscope version to remove old containerd (#741)
  Add support for multiple output files in different formats (#732)
  Add support for searching for jars within archives (#734)
  683 windows filepath (#735)
  Fix CPE encode/decode when it contains special chars (#714)
  support .par for java ecosystems (#727)
  Add arm64 support to install script (#729)
  Revert "bump goreleaser to v1.2 (#720)" (#731)
  Add a version flag (#722)
  Add lpkg as java package format (#694)
  ...
fengshunli pushed a commit to fengshunli/syft that referenced this pull request Jan 24, 2022
spiffcs pushed a commit that referenced this pull request Jan 24, 2022
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support generating multiple BOM files in different formats within a run
3 participants