@codacy/tools-bandit-1 0.19.0 → 0.21.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
@@ -77,6 +77,16 @@ pip install bandit==1.8.3
77
77
  `crypto_request_no_cert_validation` plugin inspects both libraries, so an httpx-only repo
78
78
  would otherwise lose the `verify=False` check.
79
79
 
80
+ Three of these gates are inert, and **deliberately kept anyway**: `B320`, `B410` (lxml) and
81
+ `B414` (pycryptodome) are still in Codacy's pattern catalog but Bandit 1.8.3 no longer
82
+ registers the checks, so they can never fire (`blacklists/calls.py`: "skipped B320 as the
83
+ check for a call to lxml.etree has been removed"; `blacklists/imports.py`: the same for
84
+ `B410`; `B414` is simply absent from `gen_blacklist()`). `mapping-drift.test.ts` cannot see
85
+ this — it compares against Codacy's catalog, not the installed tool. Dropping the mappings
86
+ would make three default-on High/Security patterns universal again and write them into every
87
+ Python repo's config, so the gate is the lesser evil until the catalog catches up. See
88
+ `docs/tech-debt.md`.
89
+
80
90
  - Bandit requires Python 3 as a runtime. The adapter uses an isolated venv at `~/.codacy/runtimes/bandit-1/venv/`.
81
91
  - Exit code 0 = no findings, 1 = findings found (normal), >1 = error.
82
92
  - `col_offset` in bandit output is 0-based; the adapter adds 1 for the 1-based Issue model.
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ var patterns_default = [
47
47
  category: "Security",
48
48
  severityLevel: "High",
49
49
  title: "Avoid Use of Assert Statements",
50
- enabled: false,
50
+ enabled: true,
51
51
  languages: ["Python"],
52
52
  parameters: []
53
53
  },
@@ -92,7 +92,7 @@ var patterns_default = [
92
92
  category: "Security",
93
93
  severityLevel: "High",
94
94
  title: "Detect Hardcoded Password Function Arguments",
95
- enabled: false,
95
+ enabled: true,
96
96
  languages: ["Python"],
97
97
  parameters: []
98
98
  },
@@ -114,15 +114,6 @@ var patterns_default = [
114
114
  languages: ["Python"],
115
115
  parameters: []
116
116
  },
117
- {
118
- id: "Bandit_B109",
119
- category: "Security",
120
- severityLevel: "Warning",
121
- title: "Detect Password Based Config Options Not Marked Secret",
122
- enabled: true,
123
- languages: ["Python"],
124
- parameters: []
125
- },
126
117
  {
127
118
  id: "Bandit_B110",
128
119
  category: "Security",
@@ -132,15 +123,6 @@ var patterns_default = [
132
123
  languages: ["Python"],
133
124
  parameters: []
134
125
  },
135
- {
136
- id: "Bandit_B111",
137
- category: "Security",
138
- severityLevel: "Warning",
139
- title: "Detect use of rootwrap running as root",
140
- enabled: true,
141
- languages: ["Python"],
142
- parameters: []
143
- },
144
126
  {
145
127
  id: "Bandit_B112",
146
128
  category: "Security",
@@ -157,7 +139,8 @@ var patterns_default = [
157
139
  title: "Enforce timeout parameter in requests calls",
158
140
  enabled: true,
159
141
  languages: ["Python"],
160
- parameters: []
142
+ parameters: [],
143
+ tags: ["lib:httpx", "lib:requests"]
161
144
  },
162
145
  {
163
146
  id: "Bandit_B201",
@@ -166,7 +149,8 @@ var patterns_default = [
166
149
  title: "Avoid Running Flask App with Debug Mode Enabled",
167
150
  enabled: true,
168
151
  languages: ["Python"],
169
- parameters: []
152
+ parameters: [],
153
+ tags: ["fwk:flask"]
170
154
  },
171
155
  {
172
156
  id: "Bandit_B202",
@@ -247,13 +231,14 @@ var patterns_default = [
247
231
  title: "Avoid use of mark_safe()",
248
232
  enabled: true,
249
233
  languages: ["Python"],
250
- parameters: []
234
+ parameters: [],
235
+ tags: ["fwk:django"]
251
236
  },
252
237
  {
253
238
  id: "Bandit_B309",
254
239
  category: "Security",
255
- severityLevel: "Warning",
256
- title: "Avoid Use of HTTPSConnection on Older Python Versions",
240
+ severityLevel: "High",
241
+ title: "Avoid usage of httplib.http.client HTTPSConnection on old Python versions",
257
242
  enabled: true,
258
243
  languages: ["Python"],
259
244
  parameters: []
@@ -351,8 +336,8 @@ var patterns_default = [
351
336
  {
352
337
  id: "Bandit_B320",
353
338
  category: "Security",
354
- severityLevel: "Warning",
355
- title: "Avoid Using Vulnerable lxml.etree XML Parsing Methods",
339
+ severityLevel: "High",
340
+ title: "Avoid unsafe lxml.etree usage",
356
341
  enabled: true,
357
342
  languages: ["Python"],
358
343
  parameters: []
@@ -370,8 +355,8 @@ var patterns_default = [
370
355
  id: "Bandit_B322",
371
356
  category: "Security",
372
357
  severityLevel: "High",
373
- title: "Avoid using input() in Python 2",
374
- enabled: false,
358
+ title: "Avoid use of input() in Python 2",
359
+ enabled: true,
375
360
  languages: ["Python"],
376
361
  parameters: []
377
362
  },
@@ -380,7 +365,7 @@ var patterns_default = [
380
365
  category: "Security",
381
366
  severityLevel: "Warning",
382
367
  title: "Avoid Using Unverified SSL Context",
383
- enabled: false,
368
+ enabled: true,
384
369
  languages: ["Python"],
385
370
  parameters: []
386
371
  },
@@ -389,16 +374,16 @@ var patterns_default = [
389
374
  category: "Security",
390
375
  severityLevel: "High",
391
376
  title: "Avoid Use of Insecure Hash Functions in hashlib",
392
- enabled: false,
377
+ enabled: true,
393
378
  languages: ["Python"],
394
379
  parameters: []
395
380
  },
396
381
  {
397
382
  id: "Bandit_B325",
398
383
  category: "Security",
399
- severityLevel: "Warning",
400
- title: "Avoid use of os.tempnam() and os.tmpnam()",
401
- enabled: false,
384
+ severityLevel: "High",
385
+ title: "Avoid use of os.tempnam/os.tmpnam",
386
+ enabled: true,
402
387
  languages: ["Python"],
403
388
  parameters: []
404
389
  },
@@ -486,8 +471,8 @@ var patterns_default = [
486
471
  {
487
472
  id: "Bandit_B410",
488
473
  category: "Security",
489
- severityLevel: "Warning",
490
- title: "Avoid Using Vulnerable XML Parsing Libraries (lxml)",
474
+ severityLevel: "High",
475
+ title: "Avoid importing lxml for untrusted XML parsing",
491
476
  enabled: true,
492
477
  languages: ["Python"],
493
478
  parameters: []
@@ -506,7 +491,7 @@ var patterns_default = [
506
491
  category: "Security",
507
492
  severityLevel: "High",
508
493
  title: "Avoid importing CGI handlers vulnerable to httpoxy",
509
- enabled: false,
494
+ enabled: true,
510
495
  languages: ["Python"],
511
496
  parameters: []
512
497
  },
@@ -515,16 +500,26 @@ var patterns_default = [
515
500
  category: "Security",
516
501
  severityLevel: "High",
517
502
  title: "Avoid Importing PyCrypto Library",
518
- enabled: false,
503
+ enabled: true,
519
504
  languages: ["Python"],
520
- parameters: []
505
+ parameters: [],
506
+ tags: ["lib:pycrypto"]
521
507
  },
522
508
  {
523
509
  id: "Bandit_B414",
524
510
  category: "Security",
525
511
  severityLevel: "High",
526
- title: "Avoid Importing PyCryptodome Modules",
527
- enabled: false,
512
+ title: "Avoid importing pycryptodome (Cryptodome.*)",
513
+ enabled: true,
514
+ languages: ["Python"],
515
+ parameters: []
516
+ },
517
+ {
518
+ id: "Bandit_B415",
519
+ category: "Security",
520
+ severityLevel: "High",
521
+ title: "Avoid importing IPMI-related module (pyghmi)",
522
+ enabled: true,
528
523
  languages: ["Python"],
529
524
  parameters: []
530
525
  },
@@ -535,7 +530,8 @@ var patterns_default = [
535
530
  title: "Avoid disabling SSL certificate validation in requests",
536
531
  enabled: true,
537
532
  languages: ["Python"],
538
- parameters: []
533
+ parameters: [],
534
+ tags: ["lib:httpx", "lib:requests"]
539
535
  },
540
536
  {
541
537
  id: "Bandit_B502",
@@ -580,34 +576,38 @@ var patterns_default = [
580
576
  title: "Avoid Unsafe Use of yaml.load",
581
577
  enabled: true,
582
578
  languages: ["Python"],
583
- parameters: []
579
+ parameters: [],
580
+ tags: ["lib:pyyaml"]
584
581
  },
585
582
  {
586
583
  id: "Bandit_B507",
587
584
  category: "Security",
588
585
  severityLevel: "High",
589
586
  title: "Avoid Disabling SSH Host Key Verification",
590
- enabled: false,
587
+ enabled: true,
591
588
  languages: ["Python"],
592
- parameters: []
589
+ parameters: [],
590
+ tags: ["lib:paramiko"]
593
591
  },
594
592
  {
595
593
  id: "Bandit_B508",
596
594
  category: "Security",
597
595
  severityLevel: "Warning",
598
596
  title: "Avoid using insecure SNMP versions",
599
- enabled: false,
597
+ enabled: true,
600
598
  languages: ["Python"],
601
- parameters: []
599
+ parameters: [],
600
+ tags: ["lib:pysnmp"]
602
601
  },
603
602
  {
604
603
  id: "Bandit_B509",
605
604
  category: "Security",
606
605
  severityLevel: "Warning",
607
606
  title: "Avoid Weak SNMP Cryptography",
608
- enabled: false,
607
+ enabled: true,
609
608
  languages: ["Python"],
610
- parameters: []
609
+ parameters: [],
610
+ tags: ["lib:pysnmp"]
611
611
  },
612
612
  {
613
613
  id: "Bandit_B601",
@@ -616,7 +616,8 @@ var patterns_default = [
616
616
  title: "Detect Shell Injection Vulnerabilities in Paramiko exec_command",
617
617
  enabled: true,
618
618
  languages: ["Python"],
619
- parameters: []
619
+ parameters: [],
620
+ tags: ["lib:paramiko"]
620
621
  },
621
622
  {
622
623
  id: "Bandit_B602",
@@ -650,7 +651,7 @@ var patterns_default = [
650
651
  category: "Security",
651
652
  severityLevel: "Warning",
652
653
  title: "Avoid starting a process with a shell",
653
- enabled: false,
654
+ enabled: true,
654
655
  languages: ["Python"],
655
656
  parameters: []
656
657
  },
@@ -668,7 +669,7 @@ var patterns_default = [
668
669
  category: "Security",
669
670
  severityLevel: "Warning",
670
671
  title: "Avoid starting a process with a partial executable path",
671
- enabled: false,
672
+ enabled: true,
672
673
  languages: ["Python"],
673
674
  parameters: []
674
675
  },
@@ -695,28 +696,59 @@ var patterns_default = [
695
696
  category: "Security",
696
697
  severityLevel: "Warning",
697
698
  title: "Avoid Potential SQL Injection in Django extra() Function",
698
- enabled: false,
699
+ enabled: true,
699
700
  languages: ["Python"],
700
- parameters: []
701
+ parameters: [],
702
+ tags: ["fwk:django"]
701
703
  },
702
704
  {
703
705
  id: "Bandit_B611",
704
706
  category: "Security",
705
707
  severityLevel: "Warning",
706
708
  title: "Avoid Use of RawSQL Function in Django",
707
- enabled: false,
709
+ enabled: true,
708
710
  languages: ["Python"],
709
- parameters: []
711
+ parameters: [],
712
+ tags: ["fwk:django"]
710
713
  },
711
714
  {
712
715
  id: "Bandit_B612",
713
716
  category: "Security",
714
717
  severityLevel: "Warning",
715
718
  title: "Avoid insecure use of logging.config.listen",
716
- enabled: false,
719
+ enabled: true,
717
720
  languages: ["Python"],
718
721
  parameters: []
719
722
  },
723
+ {
724
+ id: "Bandit_B613",
725
+ category: "Security",
726
+ severityLevel: "High",
727
+ title: "Detect use of Unicode bidirectional (TrojanSource) control characters",
728
+ enabled: true,
729
+ languages: ["Python"],
730
+ parameters: []
731
+ },
732
+ {
733
+ id: "Bandit_B614",
734
+ category: "Security",
735
+ severityLevel: "High",
736
+ title: "Avoid unsafe PyTorch load",
737
+ enabled: true,
738
+ languages: ["Python"],
739
+ parameters: [],
740
+ tags: ["cwe502"]
741
+ },
742
+ {
743
+ id: "Bandit_B615",
744
+ category: "Security",
745
+ severityLevel: "Warning",
746
+ title: "Avoid unsafe Hugging Face Hub downloads (pin revisions)",
747
+ enabled: true,
748
+ languages: ["Python"],
749
+ parameters: [],
750
+ tags: ["huggingface", "supplychain"]
751
+ },
720
752
  {
721
753
  id: "Bandit_B701",
722
754
  category: "Security",
@@ -724,7 +756,8 @@ var patterns_default = [
724
756
  title: "Avoid disabling autoescaping in Jinja2 templates",
725
757
  enabled: true,
726
758
  languages: ["Python"],
727
- parameters: []
759
+ parameters: [],
760
+ tags: ["fwk:flask", "lib:jinja2"]
728
761
  },
729
762
  {
730
763
  id: "Bandit_B702",
@@ -733,14 +766,25 @@ var patterns_default = [
733
766
  title: "Detect Use of Mako Templates",
734
767
  enabled: true,
735
768
  languages: ["Python"],
736
- parameters: []
769
+ parameters: [],
770
+ tags: ["lib:mako"]
737
771
  },
738
772
  {
739
773
  id: "Bandit_B703",
740
774
  category: "Security",
741
775
  severityLevel: "Warning",
742
776
  title: "Avoid Potential XSS with django mark_safe Function",
743
- enabled: false,
777
+ enabled: true,
778
+ languages: ["Python"],
779
+ parameters: [],
780
+ tags: ["fwk:django"]
781
+ },
782
+ {
783
+ id: "Bandit_B704",
784
+ category: "Security",
785
+ severityLevel: "High",
786
+ title: "Avoid markupsafe.Markup on untrusted data",
787
+ enabled: true,
744
788
  languages: ["Python"],
745
789
  parameters: []
746
790
  }
@@ -768,7 +812,7 @@ var pattern_mappings_default = {
768
812
  var descriptor = {
769
813
  id: "Bandit",
770
814
  displayName: "Bandit",
771
- preferredVersion: "1.8.3",
815
+ preferredVersion: "1.9.4",
772
816
  languages: ["Python"],
773
817
  filePatterns: ["**/*.py"],
774
818
  supportedOS: ["linux", "darwin", "win32"],
@@ -780,7 +824,7 @@ var descriptor = {
780
824
  // src/adapter.ts
781
825
  var TOOL_ID = "Bandit";
782
826
  var ADAPTER_ID = "bandit-1";
783
- var PIP_PACKAGES = ["bandit==1.8.3"];
827
+ var PIP_PACKAGES = ["bandit==1.9.4"];
784
828
  var PYTHON_VERSION_RANGE = ">=3.8.0 <3.14.0";
785
829
  var PATTERN_META = new Map(
786
830
  patterns_default.map((p) => [
@@ -804,7 +848,14 @@ function mapConfidence(confidence) {
804
848
  return 1;
805
849
  }
806
850
  }
807
- var CONFIG_FILE_CANDIDATES = [".bandit", "bandit.yml", "pyproject.toml"];
851
+ var CONFIG_FILE_CANDIDATES = [
852
+ ".bandit",
853
+ "bandit.yml",
854
+ "pyproject.toml",
855
+ "bandit.yaml",
856
+ "bandit.toml",
857
+ "bandit.ini"
858
+ ];
808
859
  var PYPROJECT_BANDIT_SECTION = /^\[tool\.bandit(\.[\w-]+)*\]/m;
809
860
  async function pyprojectHasBanditSection(pyprojectPath) {
810
861
  try {
@@ -834,7 +885,7 @@ function buildMessage(result) {
834
885
  var adapter = {
835
886
  ...descriptor,
836
887
  patternsMetadata: patterns_default,
837
- compatibleVersions: ">=1.7.0",
888
+ compatibleVersions: ">=1.9.0",
838
889
  website: "https://bandit.readthedocs.io/",
839
890
  prerequisites: [
840
891
  {
@@ -851,7 +902,7 @@ var adapter = {
851
902
  * 1. Codacy-managed venv (`~/.codacy/runtimes/bandit-1/venv/bin/bandit`)
852
903
  * 2. Global PATH (`bandit`)
853
904
  *
854
- * Parses the version from `bandit --version` output like `bandit 1.8.3`.
905
+ * Parses the version from `bandit --version` output like `bandit 1.9.4`.
855
906
  */
856
907
  async checkAvailability(ctx) {
857
908
  ctx.logger.debug("Checking availability", { toolId: TOOL_ID });
@@ -923,7 +974,7 @@ var adapter = {
923
974
  * Installs bandit into an isolated Python virtual environment.
924
975
  *
925
976
  * Uses findPython -> ensureVenv -> pipInstall to create a dedicated venv
926
- * at `~/.codacy/runtimes/bandit-1/venv/` and install `bandit==1.8.3`.
977
+ * at `~/.codacy/runtimes/bandit-1/venv/` and install `bandit==1.9.4`.
927
978
  */
928
979
  async install(ctx) {
929
980
  ctx.logger.info("Starting install", { toolId: TOOL_ID });
@@ -935,7 +986,7 @@ var adapter = {
935
986
  toolId: TOOL_ID,
936
987
  phase: "requirementCheck",
937
988
  kind: "MissingPrerequisite",
938
- message: `Python (${PYTHON_VERSION_RANGE}) could not be found or downloaded. Bandit 1.8.x is incompatible with Python 3.14+.`,
989
+ message: `Python (${PYTHON_VERSION_RANGE}) could not be found or downloaded. Bandit 1.9.x is incompatible with Python 3.14+.`,
939
990
  level: "error"
940
991
  }
941
992
  };
@@ -969,7 +1020,7 @@ var adapter = {
969
1020
  /**
970
1021
  * Checks for bandit configuration files in the repository root.
971
1022
  *
972
- * Looks for `.bandit`, `bandit.yml`, or `pyproject.toml` (in that order).
1023
+ * Looks for `.bandit`, `bandit.yml`, `bandit.yaml`, `bandit.toml`, `bandit.ini`, or `pyproject.toml` (in that order).
973
1024
  * `pyproject.toml` only counts if it actually has a `[tool.bandit]` table —
974
1025
  * unlike the other two candidates, its mere existence says nothing about
975
1026
  * whether Bandit is configured (see {@link pyprojectHasBanditSection}).
@@ -980,7 +1031,7 @@ var adapter = {
980
1031
  const candidatePath = import_path.default.join(ctx.repositoryRoot, candidate);
981
1032
  try {
982
1033
  await import_promises.default.access(candidatePath);
983
- if (candidate === "pyproject.toml" && !await pyprojectHasBanditSection(candidatePath)) {
1034
+ if ((candidate === "pyproject.toml" || candidate === "bandit.toml") && !await pyprojectHasBanditSection(candidatePath)) {
984
1035
  continue;
985
1036
  }
986
1037
  ctx.logger.debug("Found local config", { toolId: TOOL_ID, path: candidatePath });
@@ -1023,7 +1074,7 @@ var adapter = {
1023
1074
  const useLocal = codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile;
1024
1075
  if (useLocal) {
1025
1076
  const configPath = codacyConfig.localConfigurationFile;
1026
- if (configPath.endsWith(".bandit")) {
1077
+ if (configPath.endsWith(".bandit") || configPath.endsWith(".ini")) {
1027
1078
  args.push("--ini", configPath);
1028
1079
  } else {
1029
1080
  args.push("-c", configPath);
package/dist/metadata.js CHANGED
@@ -46,7 +46,7 @@ var pattern_mappings_default = {
46
46
  var descriptor = {
47
47
  id: "Bandit",
48
48
  displayName: "Bandit",
49
- preferredVersion: "1.8.3",
49
+ preferredVersion: "1.9.4",
50
50
  languages: ["Python"],
51
51
  filePatterns: ["**/*.py"],
52
52
  supportedOS: ["linux", "darwin", "win32"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-bandit-1",
3
- "version": "0.19.0",
3
+ "version": "0.21.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.19.0"
11
+ "@codacy/tooling": "0.21.0"
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",