@codacy/tools-bandit-1 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @codacy/tools-bandit-1
2
2
 
3
3
  ## Table of Contents
4
+
4
5
  - [Overview](#overview)
5
6
  - [Updating patterns](#updating-patterns)
6
7
  - [Updating the Bandit version](#updating-the-bandit-version)
@@ -13,14 +14,14 @@
13
14
 
14
15
  Python security linter using the [Bandit](https://bandit.readthedocs.io/) binary. Uses the CLI execution strategy -- spawns `bandit` from a managed Python venv via `spawnTool()` and parses its JSON output.
15
16
 
16
- | Property | Value |
17
- |----------|-------|
18
- | Tool ID | `Bandit` |
19
- | Codacy UUID | `89b6fc6a-9137-4cf3-8b9f-dcc3bedfa738` |
20
- | Strategy | CLI |
21
- | Languages | Python |
22
- | Binary | `bandit` (pip-installed in venv) |
23
- | File patterns | `**/*.py` |
17
+ | Property | Value |
18
+ | ------------- | -------------------------------------- |
19
+ | Tool ID | `Bandit` |
20
+ | Codacy UUID | `89b6fc6a-9137-4cf3-8b9f-dcc3bedfa738` |
21
+ | Strategy | CLI |
22
+ | Languages | Python |
23
+ | Binary | `bandit` (pip-installed in venv) |
24
+ | File patterns | `**/*.py` |
24
25
 
25
26
  ## Updating patterns
26
27
 
@@ -50,12 +51,32 @@ pnpm test # Run tests (requires bandit in PATH or venv)
50
51
  ```
51
52
 
52
53
  To install bandit locally for testing:
54
+
53
55
  ```bash
54
56
  pip install bandit==1.8.3
55
57
  ```
56
58
 
57
59
  ## Notes for maintainers
58
60
 
61
+ - **Preset mappings (`src/pattern-mappings.json`)**: 18 of the 78 checks are gated on a
62
+ detected PyPI dependency, because they only ever fire against one library's API. Ten were
63
+ default-on and now stay out of a repo that does not declare the library — `B201` (Flask),
64
+ `B701` (Jinja2), `B702` (Mako), `B601` (Paramiko), `B320`/`B410` (lxml), `B506` (PyYAML),
65
+ `B113`/`B501` (requests) and `B308` (Django). Eight were default-off and are now reachable
66
+ at all: `B610`/`B611`/`B703` (Django SQLi/XSS), `B507` (Paramiko host keys), `B508`/`B509`
67
+ (PySNMP), `B413`/`B414` (PyCrypto vs. PyCryptodome — separate projects, so separate
68
+ entities). Left universal on purpose: the stdlib checks (`B301`–`B307`, `B324`) and `B412`,
69
+ whose httpoxy CGI handler has no manifest to read.
70
+
71
+ Two of these need a second key, because gating gets its evidence from **direct**
72
+ declarations only:
73
+ - `B701` is claimed by `flask` as well as `jinja2`. Flask hard-depends on Jinja2
74
+ (`Flask` → `jinja2>=3.1.2`), so a real Flask app usually never lists Jinja2 itself, and
75
+ gating on `jinja2` alone dropped a High-severity autoescape check from most Flask repos.
76
+ - `B501` is claimed by `httpx` as well as `requests`. Bandit's own
77
+ `crypto_request_no_cert_validation` plugin inspects both libraries, so an httpx-only repo
78
+ would otherwise lose the `verify=False` check.
79
+
59
80
  - Bandit requires Python 3 as a runtime. The adapter uses an isolated venv at `~/.codacy/runtimes/bandit-1/venv/`.
60
81
  - Exit code 0 = no findings, 1 = findings found (normal), >1 = error.
61
82
  - `col_offset` in bandit output is 0-based; the adapter adds 1 for the 1-based Issue model.
package/dist/index.js CHANGED
@@ -746,6 +746,24 @@ var patterns_default = [
746
746
  }
747
747
  ];
748
748
 
749
+ // src/pattern-mappings.json
750
+ var pattern_mappings_default = {
751
+ flask: { prefixes: ["Bandit_B201", "Bandit_B701"] },
752
+ django: {
753
+ prefixes: ["Bandit_B308", "Bandit_B610", "Bandit_B611", "Bandit_B703"]
754
+ },
755
+ requests: { prefixes: ["Bandit_B113", "Bandit_B501"] },
756
+ httpx: { prefixes: ["Bandit_B113", "Bandit_B501"] },
757
+ jinja2: { prefixes: ["Bandit_B701"] },
758
+ mako: { prefixes: ["Bandit_B702"] },
759
+ paramiko: { prefixes: ["Bandit_B507", "Bandit_B601"] },
760
+ lxml: { prefixes: ["Bandit_B320", "Bandit_B410"] },
761
+ pyyaml: { prefixes: ["Bandit_B506"] },
762
+ pycrypto: { prefixes: ["Bandit_B413"] },
763
+ pycryptodome: { prefixes: ["Bandit_B414"] },
764
+ pysnmp: { prefixes: ["Bandit_B508", "Bandit_B509"] }
765
+ };
766
+
749
767
  // src/metadata.ts
750
768
  var descriptor = {
751
769
  id: "Bandit",
@@ -755,7 +773,8 @@ var descriptor = {
755
773
  filePatterns: ["**/*.py"],
756
774
  supportedOS: ["linux", "darwin", "win32"],
757
775
  supportedArch: ["x64", "arm64"],
758
- supportedRunners: ["local", "container"]
776
+ supportedRunners: ["local", "container"],
777
+ frameworkMappings: pattern_mappings_default
759
778
  };
760
779
 
761
780
  // src/adapter.ts
package/dist/metadata.js CHANGED
@@ -23,6 +23,26 @@ __export(metadata_exports, {
23
23
  descriptor: () => descriptor
24
24
  });
25
25
  module.exports = __toCommonJS(metadata_exports);
26
+
27
+ // src/pattern-mappings.json
28
+ var pattern_mappings_default = {
29
+ flask: { prefixes: ["Bandit_B201", "Bandit_B701"] },
30
+ django: {
31
+ prefixes: ["Bandit_B308", "Bandit_B610", "Bandit_B611", "Bandit_B703"]
32
+ },
33
+ requests: { prefixes: ["Bandit_B113", "Bandit_B501"] },
34
+ httpx: { prefixes: ["Bandit_B113", "Bandit_B501"] },
35
+ jinja2: { prefixes: ["Bandit_B701"] },
36
+ mako: { prefixes: ["Bandit_B702"] },
37
+ paramiko: { prefixes: ["Bandit_B507", "Bandit_B601"] },
38
+ lxml: { prefixes: ["Bandit_B320", "Bandit_B410"] },
39
+ pyyaml: { prefixes: ["Bandit_B506"] },
40
+ pycrypto: { prefixes: ["Bandit_B413"] },
41
+ pycryptodome: { prefixes: ["Bandit_B414"] },
42
+ pysnmp: { prefixes: ["Bandit_B508", "Bandit_B509"] }
43
+ };
44
+
45
+ // src/metadata.ts
26
46
  var descriptor = {
27
47
  id: "Bandit",
28
48
  displayName: "Bandit",
@@ -31,7 +51,8 @@ var descriptor = {
31
51
  filePatterns: ["**/*.py"],
32
52
  supportedOS: ["linux", "darwin", "win32"],
33
53
  supportedArch: ["x64", "arm64"],
34
- supportedRunners: ["local", "container"]
54
+ supportedRunners: ["local", "container"],
55
+ frameworkMappings: pattern_mappings_default
35
56
  };
36
57
  // Annotate the CommonJS export names for ESM import in node:
37
58
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-bandit-1",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Bandit adapter — CLI-mode Python security linter",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "dependencies": {
11
- "@codacy/tooling": "0.18.0"
11
+ "@codacy/tooling": "0.19.0"
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",