You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+22
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ If you've already contributed to other open source projects, contributing to the
17
17
-[Using pre-commit to run linters automatically](#using-pre-commit-to-run-linters-automatically)
18
18
-[Running isort by itself](#running-isort-by-itself)
19
19
-[Running black by itself](#running-black-by-itself)
20
+
-[Running bandit by itself](#running-bandit-by-itself)
20
21
-[Other linting tools](#other-linting-tools)
21
22
-[Making a new branch & pull request](#making-a-new-branch--pull-request)
22
23
-[Commit message tips](#commit-message-tips)
@@ -160,6 +161,7 @@ CVE Binary Tool uses a few tools to improve code quality and readability:
160
161
-`black` provides automatic style formatting. This will give you basic [PEP8](https://www.python.org/dev/peps/pep-0008/) compliance. (PEP8 is where the default python style guide is defined.)
161
162
-`flake8` provides additional code "linting" for more complex errors like unused imports.
162
163
-`pyupgrade` helps us be forward compatible with new versions of python.
164
+
-`bandit` is more of a static analysis tool than a linter and helps us find potential security flaws in the code.
163
165
164
166
We provide a `dev-requirements.txt` file which includes all the precise versions of tools as they'll be used in GitHub Actions. You an install them all using pip:
165
167
@@ -206,6 +208,26 @@ files you've changed because you won't have to scroll through a pile of
206
208
auto-formatting changes to find your own modifications. However, you can also
207
209
specify a whole folder using ```./```
208
210
211
+
### Running bandit by itself
212
+
213
+
We have a configuration file for bandit called `bandit.conf` that you should use. This disables a few of the checkers and disables scanning of the test directory.
214
+
215
+
To run it on all the code we scan, use the following:
216
+
217
+
```bash
218
+
bandit -c bandit.conf -r cve_bin_tool/
219
+
```
220
+
221
+
You can also run it on individual files:
222
+
223
+
```bash
224
+
bandit -c bandit.conf filename.py
225
+
```
226
+
227
+
If you run it without the config file, it will run a few extra checkers and will run on test code, so you'll get additional warnings.
228
+
229
+
Bandit helps you target manual code review, but bandit issues aren't always things that need to be fixed, just reviewed. If you have a bandit finding that doesn't actually need a fix, you can mark it as reviewed using a `# nosec` comment. If possible, include details as to why the bandit results are ok for future reviewers. For example, we have comments like `#nosec uses static https url above` in cases where bandit prompted us to review the variable being passed to urlopen().
230
+
209
231
### Other linting tools
210
232
211
233
As well as `black` for automatically making sure code adheres to the style guide, we use `flake8` to help us find things like unused imports. The [flake8 documentation](https://flake8.pycqa.org/en/latest/user/index.html) covers what you need to know about running it.
0 commit comments