checkmate5 4.0.67__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.
- checkmate/__init__.py +21 -0
- checkmate/__main__.py +25 -0
- checkmate/contrib/__init__.py +21 -0
- checkmate/contrib/plugins/__init__.py +0 -0
- checkmate/contrib/plugins/all/gptanalyzer/__init__.py +0 -0
- checkmate/contrib/plugins/all/gptanalyzer/analyzer.py +99 -0
- checkmate/contrib/plugins/all/gptanalyzer/issues_data.py +6 -0
- checkmate/contrib/plugins/all/gptanalyzer/setup.py +13 -0
- checkmate/contrib/plugins/cve/__init__.py +0 -0
- checkmate/contrib/plugins/cve/text4shell/__init__.py +0 -0
- checkmate/contrib/plugins/cve/text4shell/analyzer.py +64 -0
- checkmate/contrib/plugins/cve/text4shell/issues_data.py +8 -0
- checkmate/contrib/plugins/cve/text4shell/setup.py +13 -0
- checkmate/contrib/plugins/git/__init__.py +0 -0
- checkmate/contrib/plugins/git/commands/__init__.py +6 -0
- checkmate/contrib/plugins/git/commands/analyze.py +364 -0
- checkmate/contrib/plugins/git/commands/base.py +16 -0
- checkmate/contrib/plugins/git/commands/diff.py +199 -0
- checkmate/contrib/plugins/git/commands/init.py +59 -0
- checkmate/contrib/plugins/git/commands/update_stats.py +41 -0
- checkmate/contrib/plugins/git/hooks/__init__.py +0 -0
- checkmate/contrib/plugins/git/hooks/project.py +19 -0
- checkmate/contrib/plugins/git/lib/__init__.py +1 -0
- checkmate/contrib/plugins/git/lib/repository.py +557 -0
- checkmate/contrib/plugins/git/lib/repository_pygit2.py +531 -0
- checkmate/contrib/plugins/git/models.py +178 -0
- checkmate/contrib/plugins/git/setup.py +27 -0
- checkmate/contrib/plugins/golang/__init__.py +0 -0
- checkmate/contrib/plugins/golang/gostaticcheck/__init__.py +0 -0
- checkmate/contrib/plugins/golang/gostaticcheck/analyzer.py +94 -0
- checkmate/contrib/plugins/golang/gostaticcheck/issues_data.py +1246 -0
- checkmate/contrib/plugins/golang/gostaticcheck/setup.py +13 -0
- checkmate/contrib/plugins/iac/__init__.py +0 -0
- checkmate/contrib/plugins/iac/kubescape/__init__.py +0 -0
- checkmate/contrib/plugins/iac/kubescape/analyzer.py +115 -0
- checkmate/contrib/plugins/iac/kubescape/issues_data.py +636 -0
- checkmate/contrib/plugins/iac/kubescape/setup.py +14 -0
- checkmate/contrib/plugins/iac/tfsec/__init__.py +0 -0
- checkmate/contrib/plugins/iac/tfsec/analyzer.py +92 -0
- checkmate/contrib/plugins/iac/tfsec/issues_data.py +1917 -0
- checkmate/contrib/plugins/iac/tfsec/setup.py +13 -0
- checkmate/contrib/plugins/java/__init__.py +0 -0
- checkmate/contrib/plugins/java/semgrepjava/__init__.py +0 -0
- checkmate/contrib/plugins/java/semgrepjava/analyzer.py +96 -0
- checkmate/contrib/plugins/java/semgrepjava/issues_data.py +5 -0
- checkmate/contrib/plugins/java/semgrepjava/setup.py +13 -0
- checkmate/contrib/plugins/javascript/__init__.py +0 -0
- checkmate/contrib/plugins/javascript/semgrepeslint/__init__.py +0 -0
- checkmate/contrib/plugins/javascript/semgrepeslint/analyzer.py +95 -0
- checkmate/contrib/plugins/javascript/semgrepeslint/issues_data.py +6 -0
- checkmate/contrib/plugins/javascript/semgrepeslint/setup.py +13 -0
- checkmate/contrib/plugins/perl/__init__.py +0 -0
- checkmate/contrib/plugins/perl/graudit/__init__.py +0 -0
- checkmate/contrib/plugins/perl/graudit/analyzer.py +70 -0
- checkmate/contrib/plugins/perl/graudit/issues_data.py +8 -0
- checkmate/contrib/plugins/perl/graudit/setup.py +13 -0
- checkmate/contrib/plugins/python/__init__.py +0 -0
- checkmate/contrib/plugins/python/bandit/__init__.py +0 -0
- checkmate/contrib/plugins/python/bandit/analyzer.py +74 -0
- checkmate/contrib/plugins/python/bandit/issues_data.py +426 -0
- checkmate/contrib/plugins/python/bandit/setup.py +13 -0
- checkmate/contrib/plugins/ruby/__init__.py +0 -0
- checkmate/contrib/plugins/ruby/brakeman/__init__.py +0 -0
- checkmate/contrib/plugins/ruby/brakeman/analyzer.py +96 -0
- checkmate/contrib/plugins/ruby/brakeman/issues_data.py +518 -0
- checkmate/contrib/plugins/ruby/brakeman/setup.py +13 -0
- checkmate/helpers/__init__.py +0 -0
- checkmate/helpers/facts.py +26 -0
- checkmate/helpers/hashing.py +68 -0
- checkmate/helpers/issue.py +101 -0
- checkmate/helpers/settings.py +14 -0
- checkmate/lib/__init__.py +1 -0
- checkmate/lib/analysis/__init__.py +3 -0
- checkmate/lib/analysis/base.py +103 -0
- checkmate/lib/code/__init__.py +3 -0
- checkmate/lib/code/environment.py +809 -0
- checkmate/lib/models.py +515 -0
- checkmate/lib/stats/__init__.py +1 -0
- checkmate/lib/stats/helpers.py +19 -0
- checkmate/lib/stats/mapreduce.py +29 -0
- checkmate/management/__init__.py +1 -0
- checkmate/management/commands/__init__.py +18 -0
- checkmate/management/commands/alembic.py +32 -0
- checkmate/management/commands/analyze.py +42 -0
- checkmate/management/commands/analyzers.py +1 -0
- checkmate/management/commands/base.py +66 -0
- checkmate/management/commands/compare.py +0 -0
- checkmate/management/commands/export.py +0 -0
- checkmate/management/commands/info.py +0 -0
- checkmate/management/commands/init.py +103 -0
- checkmate/management/commands/issues.py +478 -0
- checkmate/management/commands/props/__init__.py +1 -0
- checkmate/management/commands/props/delete.py +29 -0
- checkmate/management/commands/props/get.py +30 -0
- checkmate/management/commands/props/set.py +29 -0
- checkmate/management/commands/reset.py +53 -0
- checkmate/management/commands/shell.py +19 -0
- checkmate/management/commands/snapshots.py +22 -0
- checkmate/management/commands/stats.py +21 -0
- checkmate/management/commands/summary.py +19 -0
- checkmate/management/commands/sync.py +63 -0
- checkmate/management/commands/trend.py +1 -0
- checkmate/management/commands/watch.py +27 -0
- checkmate/management/decorators.py +1 -0
- checkmate/management/helpers.py +140 -0
- checkmate/scripts/__init__.py +18 -0
- checkmate/scripts/manage.py +121 -0
- checkmate/settings/__init__.py +2 -0
- checkmate/settings/base.py +127 -0
- checkmate/settings/defaults.py +133 -0
- checkmate5-4.0.67.dist-info/LICENSE.txt +4095 -0
- checkmate5-4.0.67.dist-info/METADATA +15 -0
- checkmate5-4.0.67.dist-info/RECORD +116 -0
- checkmate5-4.0.67.dist-info/WHEEL +5 -0
- checkmate5-4.0.67.dist-info/entry_points.txt +2 -0
- checkmate5-4.0.67.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .analyzer import GostaticcheckAnalyzer
|
|
2
|
+
from .issues_data import issues_data
|
|
3
|
+
|
|
4
|
+
analyzers = {
|
|
5
|
+
'gostaticcheck':
|
|
6
|
+
{
|
|
7
|
+
'name': 'gostaticcheck',
|
|
8
|
+
'title': 'gostaticcheck',
|
|
9
|
+
'class': GostaticcheckAnalyzer,
|
|
10
|
+
'language': 'golang',
|
|
11
|
+
'issues_data': issues_data,
|
|
12
|
+
},
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
import subprocess
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class KubescapeAnalyzer(BaseAnalyzer):
|
|
16
|
+
|
|
17
|
+
def __init__(self, *args, **kwargs):
|
|
18
|
+
super(KubescapeAnalyzer, self).__init__(*args, **kwargs)
|
|
19
|
+
try:
|
|
20
|
+
result = subprocess.check_output(
|
|
21
|
+
["kubescape", "version"],stderr=subprocess.DEVNULL).strip()
|
|
22
|
+
except subprocess.CalledProcessError:
|
|
23
|
+
logger.error(
|
|
24
|
+
"Cannot initialize kubescape analyzer: Executable is missing, please install it.")
|
|
25
|
+
raise
|
|
26
|
+
|
|
27
|
+
def summarize(self, items):
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
def analyze(self, file_revision):
|
|
31
|
+
issues = []
|
|
32
|
+
tmpdir = "/tmp/"+file_revision.project.pk
|
|
33
|
+
|
|
34
|
+
if not os.path.exists(os.path.dirname(tmpdir+"/"+file_revision.path)):
|
|
35
|
+
try:
|
|
36
|
+
os.makedirs(os.path.dirname(tmpdir+"/"+file_revision.path))
|
|
37
|
+
except OSError as exc: # Guard against race condition
|
|
38
|
+
if exc.errno != errno.EEXIST:
|
|
39
|
+
raise
|
|
40
|
+
|
|
41
|
+
result = subprocess.check_output(["rsync -r . "+tmpdir+" --exclude .git"],shell=True).strip()
|
|
42
|
+
|
|
43
|
+
f = open(tmpdir+"/"+file_revision.path, "wb")
|
|
44
|
+
|
|
45
|
+
fout = tempfile.NamedTemporaryFile(suffix=".json", delete=False)
|
|
46
|
+
result = {}
|
|
47
|
+
try:
|
|
48
|
+
with f:
|
|
49
|
+
try:
|
|
50
|
+
f.write(file_revision.get_file_content())
|
|
51
|
+
except UnicodeDecodeError:
|
|
52
|
+
pass
|
|
53
|
+
try:
|
|
54
|
+
result = subprocess.check_output(["kubescape",
|
|
55
|
+
"scan",
|
|
56
|
+
f.name,
|
|
57
|
+
"--format",
|
|
58
|
+
"json",
|
|
59
|
+
"--format-version",
|
|
60
|
+
"v2",
|
|
61
|
+
"--output",
|
|
62
|
+
fout.name],
|
|
63
|
+
stderr=subprocess.DEVNULL).strip()
|
|
64
|
+
except subprocess.CalledProcessError as e:
|
|
65
|
+
if e.returncode == 1:
|
|
66
|
+
result = e.output
|
|
67
|
+
pass
|
|
68
|
+
elif e.returncode == 3:
|
|
69
|
+
result = []
|
|
70
|
+
pass
|
|
71
|
+
else:
|
|
72
|
+
#print((e.returncode))
|
|
73
|
+
result = e.output
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
with open(fout.name, "r") as f:
|
|
77
|
+
try:
|
|
78
|
+
result = json.load(f)
|
|
79
|
+
except ValueError as e:
|
|
80
|
+
result['warnings'] = []
|
|
81
|
+
pass
|
|
82
|
+
json_result = result
|
|
83
|
+
|
|
84
|
+
try:
|
|
85
|
+
|
|
86
|
+
for issue in json_result['results']:
|
|
87
|
+
for control in issue['controls']:
|
|
88
|
+
controlkey = control['controlID']
|
|
89
|
+
sev = json_result['summaryDetails']['controls'][controlkey]['scoreFactor']
|
|
90
|
+
if sev>=7:
|
|
91
|
+
severity = "High"
|
|
92
|
+
elif sev>=4 and sev>=6:
|
|
93
|
+
severity = "Medium"
|
|
94
|
+
else:
|
|
95
|
+
severity = "Warning"
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
line = 1
|
|
99
|
+
location = (((line, None),
|
|
100
|
+
(line, None)),)
|
|
101
|
+
|
|
102
|
+
issues.append({
|
|
103
|
+
'code': control['controlID'],
|
|
104
|
+
'severity': severity,
|
|
105
|
+
'location': location,
|
|
106
|
+
'data': control['name'],
|
|
107
|
+
'file': file_revision.path,
|
|
108
|
+
'line': line,
|
|
109
|
+
'fingerprint': self.get_fingerprint_from_code(file_revision, location, extra_data=control['name'])
|
|
110
|
+
})
|
|
111
|
+
except:
|
|
112
|
+
pass
|
|
113
|
+
|
|
114
|
+
finally:
|
|
115
|
+
return {'issues': issues}
|