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

fix: capture content written to stdout outside of report #2324

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

kzantow
Copy link
Contributor

@kzantow kzantow commented Nov 14, 2023

This PR adds handling to capture everything written to stdout. Syft has a guarantee (maybe an implicit one, for now) that all the content written to stdout is part of the report generated by the tool, such as ensuring JSON is valid JSON. Unfortunately, some libraries may write to stdout directly, such as this. In order to guarantee stdout only includes contents for the report, this PR captures this non-report output and trace logs it instead.

NOTE: although this PR uses the TRACE logging level, the behavior with a TUI when set to WARN would look like this:

$ syft -o json --platform windows/amd64 registry:mcr.microsoft.com/windows/servercore:ltsc2019 >stdout
 ✔ Parsed image                                                                                                 sha256:c632661e39bb365cf34bfdd943baa4ce5ba1ebdd713d790d1af0b9da20ae0bea
 ⠸ Cataloging packages             [0 packages]  
[0135]  WARN unhandled metadata table 38 File offset 0x944426 cols 5
[0136]  WARN unhandled metadata table 38 File offset 0xafdd82 cols 5
[0137]  WARN unhandled metadata table 38 File offset 0x1e720 cols 1
[0137]  WARN unhandled metadata table 38 File offset 0x45a cols 1

cmd/syft/cli/cli.go Outdated Show resolved Hide resolved
Signed-off-by: Keith Zantow <kzantow@gmail.com>
@wagoodman wagoodman added the bug Something isn't working label Nov 16, 2023
@wagoodman wagoodman merged commit 1c787f4 into main Nov 16, 2023
10 checks passed
@wagoodman wagoodman deleted the fix/errors-to-stdout branch November 16, 2023 22:45
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants