checkmate5 4.1.0.dev43__py3-none-any.whl → 4.1.0.dev44__py3-none-any.whl

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.
File without changes
@@ -0,0 +1,95 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ from checkmate.lib.analysis.base import BaseAnalyzer
5
+
6
+ import logging
7
+ import os
8
+ import tempfile
9
+ import json
10
+
11
+ import subprocess
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+
16
+ class OpengrepAnalyzer(BaseAnalyzer):
17
+
18
+ def __init__(self, *args, **kwargs):
19
+ super(OpengrepAnalyzer, self).__init__(*args, **kwargs)
20
+ try:
21
+ result = subprocess.check_output(
22
+ ["opengrep", "--version"],stderr=subprocess.DEVNULL).strip()
23
+ except subprocess.CalledProcessError:
24
+ logger.error(
25
+ "Cannot initialize opengrep analyzer: Executable is missing, please install it.")
26
+ raise
27
+
28
+ def summarize(self, items):
29
+ pass
30
+
31
+ def analyze(self, file_revision):
32
+ issues = []
33
+ tmpdir = "/tmp/"+file_revision.project.pk
34
+
35
+ if not os.path.exists(os.path.dirname(tmpdir+"/"+file_revision.path)):
36
+ try:
37
+ os.makedirs(os.path.dirname(tmpdir+"/"+file_revision.path))
38
+ except OSError as exc: # Guard against race condition
39
+ if exc.errno != errno.EEXIST:
40
+ raise
41
+ f = open(tmpdir+"/"+file_revision.path, "wb")
42
+
43
+ fout = tempfile.NamedTemporaryFile(suffix=".json", delete=False)
44
+ result = {}
45
+ try:
46
+ with f:
47
+ try:
48
+ f.write(file_revision.get_file_content())
49
+ except UnicodeDecodeError:
50
+ pass
51
+ try:
52
+ result = subprocess.check_output(["opengrep",
53
+ "scan",
54
+ "-f",
55
+ "/root/opengrep-rules"
56
+ "--no-git-ignore",
57
+ "--json",
58
+ f.name],
59
+ stderr=subprocess.DEVNULL).strip()
60
+
61
+ except subprocess.CalledProcessError as e:
62
+ if e.returncode == 4:
63
+ result = e.output
64
+ elif e.returncode == 3:
65
+ result = []
66
+ pass
67
+ else:
68
+ result = e.output
69
+ pass
70
+
71
+
72
+ try:
73
+ json_result = json.loads(result)
74
+
75
+ for issue in json_result['results']:
76
+
77
+ location = (((issue['start']['line'], None),
78
+ (issue['start']['line'], None)),)
79
+ val = issue['check_id']
80
+ val = val.replace("root.","")
81
+ val = val.title().replace("_","")
82
+
83
+ issues.append({
84
+ 'code': val,
85
+ 'location': location,
86
+ 'data': issue['extra']['message'],
87
+ 'file': file_revision.path,
88
+ 'line': issue['start']['line'],
89
+ 'fingerprint': self.get_fingerprint_from_code(file_revision, location, extra_data=issue['extra']['message'])
90
+ })
91
+ except:
92
+ pass
93
+
94
+ finally:
95
+ return {'issues': issues}
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ issues_data = {
5
+ }
@@ -0,0 +1,13 @@
1
+ from .analyzer import OpengrepAnalyzer
2
+ from .issues_data import issues_data
3
+
4
+ analyzers = {
5
+ 'opengrep':
6
+ {
7
+ 'name': 'opengrep',
8
+ 'title': 'opengrep',
9
+ 'class': OpengrepAnalyzer,
10
+ 'language': 'all',
11
+ 'issues_data': issues_data,
12
+ },
13
+ }
@@ -21,6 +21,7 @@ plugins = {
21
21
  'brakeman': 'checkmate.contrib.plugins.ruby.brakeman',
22
22
  'tfsec': 'checkmate.contrib.plugins.iac.tfsec',
23
23
  'kubescape': 'checkmate.contrib.plugins.iac.kubescape',
24
+ 'opengrep': 'checkmate.contrib.plugins.all.opengrep',
24
25
 
25
26
  }
26
27
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkmate5
3
- Version: 4.1.0.dev43
3
+ Version: 4.1.0.dev44
4
4
  Summary: A meta-code checker written in Python.
5
5
  Author: Andreas Dewes
6
6
  License: AGPL-3.0
@@ -6,6 +6,10 @@ checkmate/contrib/plugins/all/aigraphcodescan/__init__.py,sha256=47DEQpj8HBSa-_T
6
6
  checkmate/contrib/plugins/all/aigraphcodescan/analyzer.py,sha256=5CLYKjtKqxmtq5s9PYYrW8qnSN6eG55HoqWHQ4Kf7Nc,3189
7
7
  checkmate/contrib/plugins/all/aigraphcodescan/issues_data.py,sha256=pUC6pC33TEpgRProHoAJPvEr7wYaWgQvDXruWCTO_NE,252
8
8
  checkmate/contrib/plugins/all/aigraphcodescan/setup.py,sha256=ojrkDPRHVOC3mK34alu1d994uc0VpixFXsOJuZmr0pY,340
9
+ checkmate/contrib/plugins/all/opengrep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ checkmate/contrib/plugins/all/opengrep/analyzer.py,sha256=WhoTaagC8IAbWtf0VX2aBb3NIGC94ls_x41mybpdX_Y,3312
11
+ checkmate/contrib/plugins/all/opengrep/issues_data.py,sha256=XKspT10LzjPgE_euavpZGqR34evbvL-ctsIJn7_lrKw,44
12
+ checkmate/contrib/plugins/all/opengrep/setup.py,sha256=axjstT1Dy3_2zVi_Gs8wFST-LOR08ZWzEghat0Kcv9M,305
9
13
  checkmate/contrib/plugins/cve/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
14
  checkmate/contrib/plugins/cve/text4shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
15
  checkmate/contrib/plugins/cve/text4shell/analyzer.py,sha256=RgYq1dIGLLRdn8GeehXbjmyaE5nJDh0qRfeI22xTO2g,1850
@@ -110,10 +114,10 @@ checkmate/scripts/__init__.py,sha256=XAi0y8z1NviyGvLB68Oxnzr6Nw5AP8xgbcSSnc1Zcvw
110
114
  checkmate/scripts/manage.py,sha256=vb4L171yfctLbZpQxn_kZ1hQLtCDqdQQGiq7BJlnQ2A,4494
111
115
  checkmate/settings/__init__.py,sha256=z32hPz-kGS-tTGa6dWCFjrrrbS_eagLd-YrqBP3gjWI,33
112
116
  checkmate/settings/base.py,sha256=3WBXZITqoWepIja96bo5JTi-TDpQALPTCugL0E8z-yE,4551
113
- checkmate/settings/defaults.py,sha256=JaR9H5fciWy4PMX3oqIeaui7HDzjWSIhsXZD3tj4mSc,2736
114
- checkmate5-4.1.0.dev43.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
115
- checkmate5-4.1.0.dev43.dist-info/METADATA,sha256=10L_s4YCJSToO_TZu5NtzluPV9Lnooz2xoKPuwIYc3k,1286
116
- checkmate5-4.1.0.dev43.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
117
- checkmate5-4.1.0.dev43.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
118
- checkmate5-4.1.0.dev43.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
119
- checkmate5-4.1.0.dev43.dist-info/RECORD,,
117
+ checkmate/settings/defaults.py,sha256=nkEvDEqr3fhoy8ewvMX2ehyGtbdtkqxyqFJInol8wPg,2794
118
+ checkmate5-4.1.0.dev44.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
119
+ checkmate5-4.1.0.dev44.dist-info/METADATA,sha256=QTdZMt2b0vB4-RKiQkHnznoUuIhB3QEHAZO4jcGhNZw,1286
120
+ checkmate5-4.1.0.dev44.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
121
+ checkmate5-4.1.0.dev44.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
122
+ checkmate5-4.1.0.dev44.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
123
+ checkmate5-4.1.0.dev44.dist-info/RECORD,,