bandit icon indicating copy to clipboard operation
bandit copied to clipboard

Run checks in threads to speed up execution and analysis

Open ericwb opened this issue 6 years ago • 1 comments

Source blueprint: https://blueprints.launchpad.net/bandit/+spec/use-threading-when-running-checks

Many static analysis tools offer parallelization of execution to make checking large amounts of code faster. Flake8, for example, added the -j flag so that files would be checked in parallel. When running bandit against large amounts of code, e.g., openstack/glance, the checks take quite a while. For over 7500 files, the checks take several minutes.

I propose that we add a similar flag (to -j/--jobs) with similar behaviour to the flag in Flake8.

For example,

$ bandit -j 4 -r glance/

Would use 4 threads, while

$ bandit -j auto -r glance

Would use the number of CPUs present and could be the default.

ericwb avatar Apr 12 '19 14:04 ericwb

Workaround: run a command for each file with GNU parallel

andrew222651 avatar Dec 31 '21 03:12 andrew222651