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
+33-2Lines changed: 33 additions & 2 deletions
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)
@@ -150,7 +151,7 @@ The CVE Binary Tool has a set of tests that can be run using `pytest` command.
150
151
151
152
We have done our best to make tests stable and ensure that they pass at all times, but occasionally tests may fail due to factors outside your control (common causes: internet connectivity, rate limiting by NVD or new vulnerability data changing our test expectations). If a test doesn't pass, you should look at it to see if any changes you made caused the failure. If you're not sure, submit your code as a pull request and mention the issue and someone will try to help you sort it out.
152
153
153
-
When you submit your code as a pull request, the whole test suite will be run on windows and linux using the versions of python we support, including longer tests. We don't expect you to do all that yourself; usually trying for one version of python on whatever local OS you have is good enough and you can let Github Actions do the rest!
154
+
When you submit your code as a pull request, the whole test suite will be run on windows and linux using the versions of python we support, including longer tests. We don't expect you to do all that yourself; usually trying for one version of python on whatever local OS you have is good enough and you can let GitHub Actions do the rest!
154
155
155
156
## Running linters
156
157
@@ -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.
@@ -230,6 +252,13 @@ git pull
230
252
git checkout -b my_new_branch
231
253
```
232
254
255
+
>Note: If you accidentally check something in to main and want to reset it to match our main branch, you can save your work using `checkout -b` and then do a `git reset` to fix it:
256
+
>```
257
+
>git checkout -b saved_branch
258
+
>git reset --hard origin/main
259
+
>```
260
+
>You do not need to do the `checkout` step if you don't want to save the changes you made.
261
+
233
262
When you're ready to share that branch to make a pull request, make sure you've checked in all the files you're working on. You can get a list of the files you modified using `git status` and see what modifications you made using `git diff`
234
263
235
264
Use `git add FILENAME` to add the files you want to put in your pull request, and use `git commit` to check them in. Try to use [a clear commit message](https://chris.beams.io/posts/git-commit/) and use the [Conventional Commits](https://www.conventionalcommits.org/) format.
@@ -266,7 +295,7 @@ Here's a quick checklist to help you make sure your pull request is ready to go:
266
295
4. Have I added or updated any documentation if I changed or added a feature?
267
296
- New features are often documented in [MANUAL.md](https://github.com/intel/cve-bin-tool/blob/main/doc/MANUAL.md). (See [Making documentation](#making-documentation) for more information.)
268
297
5. Have I used [Conventional Commits](https://www.conventionalcommits.org/) to format the title of my pull request?
269
-
6. If I closed a bug, have I linked it using one of [Github's keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)? (e.g. include the text `fixed #1234`)
298
+
6. If I closed a bug, have I linked it using one of [GitHub's keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)? (e.g. include the text `fixed #1234`)
270
299
7. Have I checked on the results from GitHub Actions?
271
300
- GitHub Actions will run all the tests, linters and a spell check for you. If you can, try to make sure everything is running cleanly with no errors before leaving it for a human code reviewer!
272
301
- As of this writing, tests take less than 20 minutes to run once they start, but they can be queued for a while before they start. Go get a cup of tea or work on something else while you wait!
@@ -279,6 +308,8 @@ Someone will review your code and try to provide feedback in the comments on Git
279
308
280
309
If something needs fixing or we have questions, we'll work back and forth with you to get that sorted. We usually do most of the chatting directly in the pull request comments on GitHub, but if you're stuck you can also stop by our [Gitter chat room](https://gitter.im/cve-bin-tool/community) to talk with folk outside of the bug.
281
310
311
+
>Another useful tool is `git rebase`, which allows you to change the "base" that your code uses. We most often use it as `git rebase origin/main` which can be useful if a change in the main tree is affecting your code's ability to merge. Rebasing is a bit much for an intro document, but [there's a git rebase tutorial here](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase) that you may find useful if it comes up.
312
+
282
313
Once any issues are resolved, we'll merge your code. Yay!
283
314
284
315
In rare cases, the code won't work for us and we'll let you know. Sometimes this happens because someone else has already submitted a fix for the same bug, (Issues marked [good first issue](https://github.com/intel/cve-bin-tool/labels/good%20first%20issue) can be in high demand!) or because you worked on a checker that didn't have a good signature. Don't worry, these things happens, no one thinks less of you for trying!
specify NVD API key (used to improve NVD rate limit)
109
111
110
112
Input:
111
113
directory directory to scan
@@ -178,7 +180,7 @@ in the terminal and provide it as an input by running `cve-bin-tool -L pkg-list`
178
180
You can use `--config` option to provide configuration file for the tool. You can still override options specified in config file with command line arguments. See our sample config files in the
0 commit comments