Skip to content

Should exit with non-zero code when scanning fails #1326

Open

Description

@kevinoid

Describe the bug

When bandit is unable to scan one or more files (e.g. due to Python 3.14 as in #1219 or non-UTF-8 characters as in #882) it still exits with exit code 0, which is misleading and makes it more difficult to check the result programmatically (e.g. to fail a build in CI systems).

Reproduction steps

1. Run bandit using Python 3.14 in any project.
2. Observe that the "Files skipped" section of the output lists all .py files with "(exception while scanning file)" and the exit code is 0.

Expected behavior

bandit would exit with a non-zero exit code to indicate failure. (Perhaps code 2 to distinguish internal errors from failed tests which set exit code 1?)

Bandit version

1.8.3 (Default)

Python version

3.13 (Default)

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions