checkmate5 4.3.0.dev2__py3-none-any.whl → 5.1.0.dev2__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.
Files changed (56) hide show
  1. checkmate/settings/defaults.py +1 -36
  2. {checkmate5-4.3.0.dev2.dist-info → checkmate5-5.1.0.dev2.dist-info}/METADATA +1 -1
  3. {checkmate5-4.3.0.dev2.dist-info → checkmate5-5.1.0.dev2.dist-info}/RECORD +7 -56
  4. checkmate/contrib/plugins/all/opengrep/__init__.py +0 -0
  5. checkmate/contrib/plugins/all/opengrep/analyzer.py +0 -150
  6. checkmate/contrib/plugins/all/opengrep/issues_data.py +0 -5
  7. checkmate/contrib/plugins/all/opengrep/opengrep_manylinux_x86 +0 -0
  8. checkmate/contrib/plugins/all/opengrep/setup.py +0 -13
  9. checkmate/contrib/plugins/cve/__init__.py +0 -0
  10. checkmate/contrib/plugins/cve/text4shell/__init__.py +0 -0
  11. checkmate/contrib/plugins/cve/text4shell/analyzer.py +0 -64
  12. checkmate/contrib/plugins/cve/text4shell/issues_data.py +0 -8
  13. checkmate/contrib/plugins/cve/text4shell/setup.py +0 -13
  14. checkmate/contrib/plugins/golang/__init__.py +0 -0
  15. checkmate/contrib/plugins/golang/gostaticcheck/__init__.py +0 -0
  16. checkmate/contrib/plugins/golang/gostaticcheck/analyzer.py +0 -94
  17. checkmate/contrib/plugins/golang/gostaticcheck/issues_data.py +0 -1246
  18. checkmate/contrib/plugins/golang/gostaticcheck/setup.py +0 -13
  19. checkmate/contrib/plugins/iac/__init__.py +0 -0
  20. checkmate/contrib/plugins/iac/kubescape/__init__.py +0 -0
  21. checkmate/contrib/plugins/iac/kubescape/analyzer.py +0 -115
  22. checkmate/contrib/plugins/iac/kubescape/issues_data.py +0 -636
  23. checkmate/contrib/plugins/iac/kubescape/setup.py +0 -14
  24. checkmate/contrib/plugins/iac/tfsec/__init__.py +0 -0
  25. checkmate/contrib/plugins/iac/tfsec/analyzer.py +0 -92
  26. checkmate/contrib/plugins/iac/tfsec/issues_data.py +0 -1917
  27. checkmate/contrib/plugins/iac/tfsec/setup.py +0 -13
  28. checkmate/contrib/plugins/java/__init__.py +0 -0
  29. checkmate/contrib/plugins/java/semgrepjava/__init__.py +0 -0
  30. checkmate/contrib/plugins/java/semgrepjava/analyzer.py +0 -96
  31. checkmate/contrib/plugins/java/semgrepjava/issues_data.py +0 -5
  32. checkmate/contrib/plugins/java/semgrepjava/setup.py +0 -13
  33. checkmate/contrib/plugins/javascript/__init__.py +0 -0
  34. checkmate/contrib/plugins/javascript/semgrepeslint/__init__.py +0 -0
  35. checkmate/contrib/plugins/javascript/semgrepeslint/analyzer.py +0 -95
  36. checkmate/contrib/plugins/javascript/semgrepeslint/issues_data.py +0 -6
  37. checkmate/contrib/plugins/javascript/semgrepeslint/setup.py +0 -13
  38. checkmate/contrib/plugins/perl/__init__.py +0 -0
  39. checkmate/contrib/plugins/perl/graudit/__init__.py +0 -0
  40. checkmate/contrib/plugins/perl/graudit/analyzer.py +0 -70
  41. checkmate/contrib/plugins/perl/graudit/issues_data.py +0 -8
  42. checkmate/contrib/plugins/perl/graudit/setup.py +0 -13
  43. checkmate/contrib/plugins/python/__init__.py +0 -0
  44. checkmate/contrib/plugins/python/bandit/__init__.py +0 -0
  45. checkmate/contrib/plugins/python/bandit/analyzer.py +0 -74
  46. checkmate/contrib/plugins/python/bandit/issues_data.py +0 -426
  47. checkmate/contrib/plugins/python/bandit/setup.py +0 -13
  48. checkmate/contrib/plugins/ruby/__init__.py +0 -0
  49. checkmate/contrib/plugins/ruby/brakeman/__init__.py +0 -0
  50. checkmate/contrib/plugins/ruby/brakeman/analyzer.py +0 -96
  51. checkmate/contrib/plugins/ruby/brakeman/issues_data.py +0 -518
  52. checkmate/contrib/plugins/ruby/brakeman/setup.py +0 -13
  53. {checkmate5-4.3.0.dev2.dist-info → checkmate5-5.1.0.dev2.dist-info}/WHEEL +0 -0
  54. {checkmate5-4.3.0.dev2.dist-info → checkmate5-5.1.0.dev2.dist-info}/entry_points.txt +0 -0
  55. {checkmate5-4.3.0.dev2.dist-info → checkmate5-5.1.0.dev2.dist-info}/licenses/LICENSE.txt +0 -0
  56. {checkmate5-4.3.0.dev2.dist-info → checkmate5-5.1.0.dev2.dist-info}/top_level.txt +0 -0
@@ -15,45 +15,10 @@ hooks = defaultdict(list)
15
15
 
16
16
  plugins = {
17
17
  'git': 'checkmate.contrib.plugins.git',
18
- 'bandit': 'checkmate.contrib.plugins.python.bandit',
19
- 'gostaticcheck': 'checkmate.contrib.plugins.golang.gostaticcheck',
20
- 'aigraphcodescan': 'checkmate.contrib.plugins.all.aigraphcodescan',
21
- 'brakeman': 'checkmate.contrib.plugins.ruby.brakeman',
22
- 'tfsec': 'checkmate.contrib.plugins.iac.tfsec',
23
- 'kubescape': 'checkmate.contrib.plugins.iac.kubescape',
24
- 'opengrep': 'checkmate.contrib.plugins.all.opengrep',
25
-
18
+ 'aigraphcodescan': 'checkmate.contrib.plugins.all.aigraphcodescan'
26
19
  }
27
20
 
28
21
  language_patterns = {
29
- 'perl': {
30
- 'name': 'Perl',
31
- 'patterns': [u'\.pl$'],
32
- },
33
- 'python': {
34
- 'name': 'Python',
35
- 'patterns': [u'\.py$'],
36
- },
37
- 'javascript': {
38
- 'name': 'Javascript',
39
- 'patterns': [u'\.js$', u'\.ts$'],
40
- },
41
- 'java': {
42
- 'name': 'Java',
43
- 'patterns': [u'\.java$'],
44
- },
45
- 'ruby': {
46
- 'name': 'Ruby',
47
- 'patterns': [u'\.rb$'],
48
- },
49
- 'golang': {
50
- 'name': 'Golang',
51
- 'patterns': [u'\.go$'],
52
- },
53
- 'iac': {
54
- 'name': 'IaC',
55
- 'patterns': [u'\.yml$', u'\.yaml$', u'Dockerfile$', u'\.tf$'],
56
- },
57
22
  'all': {
58
23
  'name': 'All',
59
24
  'patterns': [u'.*\.*$'],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkmate5
3
- Version: 4.3.0.dev2
3
+ Version: 5.1.0.dev2
4
4
  Summary: A meta-code checker written in Python.
5
5
  Author: Andreas Dewes
6
6
  License: AGPL-3.0
@@ -6,16 +6,6 @@ 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=7_-rPDpSXuU9IemJ6aU5a5V7-_u8Y3ZSAMQ10tgcRdw,6502
11
- checkmate/contrib/plugins/all/opengrep/issues_data.py,sha256=XKspT10LzjPgE_euavpZGqR34evbvL-ctsIJn7_lrKw,44
12
- checkmate/contrib/plugins/all/opengrep/opengrep_manylinux_x86,sha256=OcYISWcyhsWIZ9A_XDOn1GJ-BNzLc8nuOCUshlx-aVU,45796896
13
- checkmate/contrib/plugins/all/opengrep/setup.py,sha256=axjstT1Dy3_2zVi_Gs8wFST-LOR08ZWzEghat0Kcv9M,305
14
- checkmate/contrib/plugins/cve/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- checkmate/contrib/plugins/cve/text4shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- checkmate/contrib/plugins/cve/text4shell/analyzer.py,sha256=RgYq1dIGLLRdn8GeehXbjmyaE5nJDh0qRfeI22xTO2g,1850
17
- checkmate/contrib/plugins/cve/text4shell/issues_data.py,sha256=OmErk-rWhiz4NePNOHM6Gv3Ev4owaSyxj08X77EXqUw,158
18
- checkmate/contrib/plugins/cve/text4shell/setup.py,sha256=rRwlaETY7YLs6P8_ImOPiWdEIiClTozb4acQ0o9gipQ,315
19
9
  checkmate/contrib/plugins/git/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
10
  checkmate/contrib/plugins/git/models.py,sha256=zo46lX6JykFlyZBIAgh8fNKqttp5lbec_heOiFB_Bc4,6424
21
11
  checkmate/contrib/plugins/git/setup.py,sha256=Rl9FJAEWzI4h3bqbiolc6CGvJuM2hr2qOA5-x2EPN1A,730
@@ -31,45 +21,6 @@ checkmate/contrib/plugins/git/lib/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zN
31
21
  checkmate/contrib/plugins/git/lib/repository.py,sha256=0sXDuyirzwciWlhNiSBQvg2eH5ONB0v4_SJjy8ygIek,20940
32
22
  checkmate/contrib/plugins/git/lib/repository_pygit2.py,sha256=UReXa4UpxOCJ51ufOFVQdiBJ6vFUaH8GeVoiono3aOI,19981
33
23
  checkmate/contrib/plugins/git/lib/ssh,sha256=tAZ8WPDoLcRSZHo_uhyq_MG69AY3SJo7P4N9fZ3UzuU,37
34
- checkmate/contrib/plugins/golang/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- checkmate/contrib/plugins/golang/gostaticcheck/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- checkmate/contrib/plugins/golang/gostaticcheck/analyzer.py,sha256=dDp7zmX1oNWiR2p10z8x0ekvXql0S3ubbe-_elzZcM0,3050
37
- checkmate/contrib/plugins/golang/gostaticcheck/issues_data.py,sha256=lw7lD0sMmitaQ1DCinty3wS-4YkvvqH4aQIzfoeJ78Y,62133
38
- checkmate/contrib/plugins/golang/gostaticcheck/setup.py,sha256=SF1kzWWXZouAGYZdVKWWIAqkqKtp0rg0C0jYzt_DCs4,333
39
- checkmate/contrib/plugins/iac/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- checkmate/contrib/plugins/iac/kubescape/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- checkmate/contrib/plugins/iac/kubescape/analyzer.py,sha256=RjUeOK0lOfOai0S0css8VvGSf0Olfzg8bblw0arJ89E,4104
42
- checkmate/contrib/plugins/iac/kubescape/issues_data.py,sha256=YN5brCMeGFhKbQ75IUEnL3thTdcxp3EuytijmG5TNG0,31049
43
- checkmate/contrib/plugins/iac/kubescape/setup.py,sha256=HeN1AXIEjEqcbCwzxS2Nv72oS6RmwPQPhccH45Kh5xk,311
44
- checkmate/contrib/plugins/iac/tfsec/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
- checkmate/contrib/plugins/iac/tfsec/analyzer.py,sha256=FBDIj9PuWj_BmCRBDA8oPLMEKW_BkrpAd5LBEzcIzmg,3115
46
- checkmate/contrib/plugins/iac/tfsec/issues_data.py,sha256=QZFvLdNccGBwjNbpvz4mSFNsCucnL7JoktDJuyQb7rY,53291
47
- checkmate/contrib/plugins/iac/tfsec/setup.py,sha256=_6VJxDw5vDc6gZV7TzhAp0bsCegldsuWlJ20OVDFkAs,290
48
- checkmate/contrib/plugins/java/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
- checkmate/contrib/plugins/java/semgrepjava/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
- checkmate/contrib/plugins/java/semgrepjava/analyzer.py,sha256=d1CgggHrBBcfY4UGDMhfuAXJxVwc1YX6Duz9fXdd23M,3404
51
- checkmate/contrib/plugins/java/semgrepjava/issues_data.py,sha256=XKspT10LzjPgE_euavpZGqR34evbvL-ctsIJn7_lrKw,44
52
- checkmate/contrib/plugins/java/semgrepjava/setup.py,sha256=Sad2LgvJmnML7VhLIaw7Rw6tvdtWTaL3LuOFlpTklQ8,321
53
- checkmate/contrib/plugins/javascript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
- checkmate/contrib/plugins/javascript/semgrepeslint/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- checkmate/contrib/plugins/javascript/semgrepeslint/analyzer.py,sha256=kPX0Xq6m37Htz4iPQjEhu_1tpjS5Lr10TeikGUAVsrY,3358
56
- checkmate/contrib/plugins/javascript/semgrepeslint/issues_data.py,sha256=8AJMdTw9-JTM_4GFxenoC_JC7-PsbCUXpvqkYdeH_hY,45
57
- checkmate/contrib/plugins/javascript/semgrepeslint/setup.py,sha256=sveGHib3haDHVewSbArKsUENuyVJSfrLVawhd-41ZlE,337
58
- checkmate/contrib/plugins/perl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
- checkmate/contrib/plugins/perl/graudit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
- checkmate/contrib/plugins/perl/graudit/analyzer.py,sha256=TZWLXZujFcpY27rI8nIW6G0NksIggAD0JD_TzRqk_CI,2097
61
- checkmate/contrib/plugins/perl/graudit/issues_data.py,sha256=pf5p5uLlQMz8H0F6qcPpsFXQPzfCypQ0ilUUusAY684,163
62
- checkmate/contrib/plugins/perl/graudit/setup.py,sha256=2xeda6e0DEYa3z3kWMvrYPEFfC7rj26VsQU79CakCpg,301
63
- checkmate/contrib/plugins/python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- checkmate/contrib/plugins/python/bandit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
- checkmate/contrib/plugins/python/bandit/analyzer.py,sha256=GNzUgk7BCWMFC2sdYnFC48AYZ39t-Z_HuJF-EdiuSn4,2435
66
- checkmate/contrib/plugins/python/bandit/issues_data.py,sha256=JFXDVbUK68XQXAt6Ef_Y5lImoGF7L2mZER5l-G6k_Gw,18081
67
- checkmate/contrib/plugins/python/bandit/setup.py,sha256=LL8RRyw9OWRVTEhjKXHjqPp9FZLylvXC8JZrnxJTE-8,298
68
- checkmate/contrib/plugins/ruby/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
- checkmate/contrib/plugins/ruby/brakeman/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
- checkmate/contrib/plugins/ruby/brakeman/analyzer.py,sha256=suMOP7l0ncHfe-0t96y0g2koUQYXPrWiawCxvYJHn5Q,3401
71
- checkmate/contrib/plugins/ruby/brakeman/issues_data.py,sha256=M4W2XvswJBKf1igiJGvCoRMhKUuPzSFpggOpien8jrQ,11776
72
- checkmate/contrib/plugins/ruby/brakeman/setup.py,sha256=yWGmcWvymUw-x2S0kHMmfWAP5xMfMK8vzpR_g-zAOkg,306
73
24
  checkmate/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
25
  checkmate/helpers/exceptions.py,sha256=20Y7rW_eUJ-2Lu_KucXkAM8y2_SCFsF_iDU25GtlVXY,212
75
26
  checkmate/helpers/facts.py,sha256=1ycdKqRkTyAKTI_hSi1LkCnb1YUqoo7cI-cSDlH8FoY,734
@@ -115,10 +66,10 @@ checkmate/scripts/__init__.py,sha256=XAi0y8z1NviyGvLB68Oxnzr6Nw5AP8xgbcSSnc1Zcvw
115
66
  checkmate/scripts/manage.py,sha256=vb4L171yfctLbZpQxn_kZ1hQLtCDqdQQGiq7BJlnQ2A,4494
116
67
  checkmate/settings/__init__.py,sha256=z32hPz-kGS-tTGa6dWCFjrrrbS_eagLd-YrqBP3gjWI,33
117
68
  checkmate/settings/base.py,sha256=3WBXZITqoWepIja96bo5JTi-TDpQALPTCugL0E8z-yE,4551
118
- checkmate/settings/defaults.py,sha256=nkEvDEqr3fhoy8ewvMX2ehyGtbdtkqxyqFJInol8wPg,2794
119
- checkmate5-4.3.0.dev2.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
120
- checkmate5-4.3.0.dev2.dist-info/METADATA,sha256=7LxAxvT6JiZCB6PYt10dhRRWxlyBJY-0n_9BKJ2Mplw,1286
121
- checkmate5-4.3.0.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
122
- checkmate5-4.3.0.dev2.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
123
- checkmate5-4.3.0.dev2.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
124
- checkmate5-4.3.0.dev2.dist-info/RECORD,,
69
+ checkmate/settings/defaults.py,sha256=qZqK82L4Qb96JkUP7J240rL_SPa3CNi3emZBh2LvSf4,1825
70
+ checkmate5-5.1.0.dev2.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
71
+ checkmate5-5.1.0.dev2.dist-info/METADATA,sha256=KuETC4HpXKVN7OtYUoUHE0GGW2cMMQRP8PyjJHrKyYw,1286
72
+ checkmate5-5.1.0.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
73
+ checkmate5-5.1.0.dev2.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
74
+ checkmate5-5.1.0.dev2.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
75
+ checkmate5-5.1.0.dev2.dist-info/RECORD,,
File without changes
@@ -1,150 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- from checkmate.lib.analysis.base import BaseAnalyzer
4
-
5
- import logging
6
- import os
7
- import tempfile
8
- import json
9
- import subprocess
10
-
11
- logger = logging.getLogger(__name__)
12
-
13
-
14
- class OpengrepAnalyzer(BaseAnalyzer):
15
- def __init__(self, *args, **kwargs):
16
- super(OpengrepAnalyzer, self).__init__(*args, **kwargs)
17
- try:
18
- result = subprocess.check_output(
19
- ["opengrep", "--version"], stderr=subprocess.DEVNULL
20
- ).strip()
21
- except subprocess.CalledProcessError:
22
- logger.error(
23
- "Cannot initialize opengrep analyzer: Executable is missing, please install it."
24
- )
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
- # This block handles directory creation. Note: It's often safer to use
35
- # Python's tempfile module for secure temporary file/directory handling
36
- # instead of constructing paths manually in /tmp/.
37
- if not os.path.exists(os.path.dirname(tmpdir + "/" + file_revision.path)):
38
- try:
39
- os.makedirs(os.path.dirname(tmpdir + "/" + file_revision.path))
40
- except OSError as exc: # Guard against race condition
41
- # Import 'errno' is missing for this check (import errno)
42
- if exc.errno != 17: # 17 corresponds to errno.EEXIST
43
- raise
44
-
45
- # Opened file handle. It's crucial to ensure this is closed properly.
46
- # Using tempfile.NamedTemporaryFile for the entire process is generally
47
- # safer and handles cleanup more robustly.
48
- f = open(tmpdir + "/" + file_revision.path, "wb")
49
-
50
- # This variable 'fout' is created but not used in the provided logic.
51
- # It can likely be removed.
52
- fout = tempfile.NamedTemporaryFile(suffix=".json", delete=False)
53
- result = {}
54
-
55
- try:
56
- # The 'with f:' block ensures the file is properly closed,
57
- # but 'f' was already opened outside this block.
58
- # For best practice, open the file directly within the 'with' statement.
59
- with f:
60
- try:
61
- f.write(file_revision.get_file_content())
62
- except UnicodeDecodeError:
63
- # Handle cases where the file content might not be decodable as text.
64
- # This often occurs with binary files.
65
- pass
66
-
67
- # Get the file extension from the temporary file's name.
68
- file_name = f.name
69
- _, file_extension = os.path.splitext(file_name)
70
-
71
- # Remove the leading dot from the extension (e.g., '.php' becomes 'php').
72
- if file_extension:
73
- file_extension = file_extension[1:]
74
-
75
- # Construct the base rule path.
76
- base_rules_path = "/root/opengrep-rules"
77
-
78
- # Determine the specific rule folder based on the extension.
79
- if file_extension:
80
- rules_folder = file_extension.lower() # Convert to lowercase for consistency
81
- rules_path = os.path.join(base_rules_path, rules_folder)
82
- else:
83
- rules_path = base_rules_path # Use the base path if no extension
84
-
85
- # Execute the opengrep command.
86
- try:
87
- result = subprocess.check_output(
88
- [
89
- "opengrep",
90
- "scan",
91
- "-f",
92
- rules_path, # Dynamically set the rules path
93
- "--no-git-ignore",
94
- "--json",
95
- f.name,
96
- ],
97
- stderr=subprocess.DEVNULL,
98
- ).strip()
99
- except subprocess.CalledProcessError as e:
100
- # Handle cases where opengrep command fails (e.g., non-zero exit code).
101
- print(f"Opengrep command failed with error: {e}")
102
- print(f"Output: {e.output.decode(errors='ignore')}") # Decode output for printing
103
- except FileNotFoundError:
104
- # Handle cases where 'opengrep' command itself is not found.
105
- print("Error: 'opengrep' command not found. Make sure it's in your PATH.")
106
-
107
- # Process the JSON result from opengrep.
108
- # This 'try' block was originally at a different indentation level.
109
- # It should ideally be part of the main analysis flow, possibly
110
- # after the subprocess call.
111
- try:
112
- json_result = json.loads(result)
113
-
114
- for issue in json_result["results"]:
115
- location = (
116
- ((issue["start"]["line"], None), (issue["start"]["line"], None)),
117
- )
118
- val = issue["check_id"]
119
- val = val.replace("root.", "")
120
- val = val.title().replace("_", "")
121
-
122
- issues.append(
123
- {
124
- "code": val,
125
- "location": location,
126
- "data": issue["extra"]["message"],
127
- "file": file_revision.path,
128
- "line": issue["start"]["line"],
129
- "fingerprint": self.get_fingerprint_from_code(
130
- file_revision, location, extra_data=issue["extra"]["message"]
131
- ),
132
- }
133
- )
134
- except: # This is a bare except, which catches all exceptions.
135
- # It's better to catch specific exceptions, like json.JSONDecodeError,
136
- # and log errors instead of silently passing.
137
- pass
138
-
139
- except Exception as e:
140
- # Catch any other unexpected errors during file writing or processing.
141
- print(f"An unexpected error occurred: {e}")
142
-
143
- finally:
144
- # The 'finally' block must align with its 'try' block.
145
- # Ensure the temporary file 'f' is closed and deleted here if it was opened.
146
- # In your original code, 'f' was opened, but there was no explicit close
147
- # or deletion in the finally block for the manual file creation.
148
- # Using tempfile.NamedTemporaryFile with its own 'with' context usually
149
- # handles this automatically.
150
- return {"issues": issues}
@@ -1,5 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- issues_data = {
5
- }
@@ -1,13 +0,0 @@
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
- }
File without changes
File without changes
@@ -1,64 +0,0 @@
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 Text4shellAnalyzer(BaseAnalyzer):
16
-
17
- def __init__(self, *args, **kwargs):
18
- super(Text4shellAnalyzer, self).__init__(*args, **kwargs)
19
-
20
- def summarize(self, items):
21
- pass
22
-
23
- def analyze(self, file_revision):
24
- issues = []
25
- tmpdir = "/tmp/"+file_revision.project.pk
26
- f = open(tmpdir+"/"+file_revision.path, "wb")
27
- try:
28
- with f:
29
- f.write(file_revision.get_file_content())
30
- try:
31
- result = subprocess.check_output(["python3","/root/text4shell-ce/scan_commons_text_versions.py",
32
- f.name,
33
- "-quiet"]
34
- )
35
- except subprocess.CalledProcessError as e:
36
- pass
37
-
38
- try:
39
- json_result = json.loads(result)
40
- except ValueError:
41
- json_result = {}
42
- pass
43
-
44
- try:
45
- line = "1"
46
- line = int(line)
47
- location = (((line, line),
48
- (line, None)),)
49
-
50
- issues.append({
51
- 'code': "I001",
52
- 'location': location,
53
- 'data': json_result["I001"],
54
- 'file': file_revision.path,
55
- 'line': line,
56
- 'fingerprint': self.get_fingerprint_from_code(file_revision, location, extra_data=json_result["I001"])
57
- })
58
-
59
- except KeyError:
60
- pass
61
-
62
- finally:
63
- os.unlink(f.name)
64
- return {'issues': issues}
@@ -1,8 +0,0 @@
1
- issues_data = {
2
- "I001": {
3
- "title": "Text4Shell",
4
- "description": "%(issue.data)s",
5
- "severity": 3,
6
- "categories": []
7
- }
8
- }
@@ -1,13 +0,0 @@
1
- from .analyzer import Text4shellAnalyzer
2
- from .issues_data import issues_data
3
-
4
- analyzers = {
5
- 'text4shell':
6
- {
7
- 'name': 'text4shell',
8
- 'title': 'text4shell',
9
- 'class': Text4shellAnalyzer,
10
- 'language': 'cve',
11
- 'issues_data': issues_data,
12
- },
13
- }
File without changes
@@ -1,94 +0,0 @@
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
-
13
- logger = logging.getLogger(__name__)
14
-
15
-
16
- class GostaticcheckAnalyzer(BaseAnalyzer):
17
-
18
- def __init__(self, *args, **kwargs):
19
- super(GostaticcheckAnalyzer, self).__init__(*args, **kwargs)
20
-
21
- def summarize(self, items):
22
- pass
23
-
24
- def analyze(self, file_revision):
25
- issues = []
26
- tmpdir = "/tmp/"+file_revision.project.pk
27
-
28
- if not os.path.exists(os.path.dirname(tmpdir+"/"+file_revision.path)):
29
- try:
30
- os.makedirs(os.path.dirname(tmpdir+"/"+file_revision.path))
31
- except OSError as exc: # Guard against race condition
32
- if exc.errno != errno.EEXIST:
33
- raise
34
-
35
- result = subprocess.check_output(["rsync -r . "+tmpdir+" --exclude .git"],shell=True).strip()
36
-
37
- f = open(tmpdir+"/"+file_revision.path, "wb")
38
-
39
- result = {}
40
- try:
41
- with f:
42
- try:
43
- f.write(file_revision.get_file_content())
44
- except UnicodeDecodeError:
45
- pass
46
- os.chdir(tmpdir)
47
- os.environ["PATH"] = "/root/.go/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/:/usr/local/go/bin/"
48
-
49
- try:
50
- result = subprocess.check_output(["/root/bin/staticcheck",
51
- "-f", "json",
52
- f.name],
53
- stderr=subprocess.DEVNULL).strip()
54
- except subprocess.CalledProcessError as e:
55
- if e.returncode == 2:
56
- result = e.output
57
- elif e.returncode == 1:
58
- result = e.output
59
- pass
60
- else:
61
- result = []
62
-
63
- for line in result.splitlines():
64
- try:
65
- json_result = json.loads(line)
66
- except ValueError:
67
- json_result = []
68
- pass
69
- try:
70
- issue = json_result
71
- value = issue['location']['line']
72
-
73
- location = (((value,None),
74
- (value,None)),)
75
-
76
-
77
-
78
- if ".go" in file_revision.path:
79
- issues.append({
80
- 'code': issue['code'],
81
- 'location': location,
82
- 'data': issue['message'],
83
- 'file': file_revision.path,
84
- 'line': value,
85
- 'fingerprint': self.get_fingerprint_from_code(file_revision, location, extra_data=issue['message'])
86
- })
87
-
88
- except:
89
- pass
90
-
91
- finally:
92
- pass
93
- return {'issues': issues}
94
-