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

Broken JSON on standard output #1000

Open
muszalski opened this issue Mar 13, 2023 · 4 comments
Open

Broken JSON on standard output #1000

muszalski opened this issue Mar 13, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@muszalski
Copy link

Describe the bug

Hi!

When JSON format is requested the standard output starts with:

Working... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:08

which breaks JSON.

Reproduction steps

1. Run `bandit -r . -f json` or `bandit -r . -f json -o -`
2. Check first line of the output - there is `Working...`

Expected behavior

Valid JSON on output

Bandit version

1.7.5 (Default)

Python version

3.11 (Default)

Additional context

No response

@muszalski muszalski added the bug Something isn't working label Mar 13, 2023
@OClark23
Copy link

@muszalski try: bandit -r . -f json -q > output.json

@FHu-HMS
Copy link

FHu-HMS commented Apr 27, 2023

This also caused me trouble yesterday. Why not redirect this message to stderr? The 'settings' information is also output via stderr after all.

@ericwb
Copy link
Member

ericwb commented Dec 9, 2023

FYI, you won't see the "Working ..." part if you use the -o argument. For example:
bandit -r examples/ -f json -o test.json

You can also pass -q to use quiet mode which skips the use of the progress statement.

@ericwb
Copy link
Member

ericwb commented Dec 9, 2023

Not sure if there is a preferred way to fix this. Redirecting the progress to stderr doesn't
necessarily make sense since I do think this is acceptable output for stdout. And there are
workarounds using -o or -q to avoid the issue. But I can leave the issue open for now,
maybe there is a more ideal solution.

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

No branches or pull requests

4 participants