8
8
DOCUMENTATION_PATH = "../docs/repositories/security-monitor.md"
9
9
ENDPOINT_URL_TOOLS = "https://api.codacy.com/api/v3/tools"
10
10
ENDPOINT_URL_CODE_PATTERNS = Template ("https://api.codacy.com/api/v3/tools/${toolUuid}/patterns" )
11
- IGNORED_TOOL_UUIDS = ["647dddc1-17c4-4840-acea-4c2c2bbecb45" , # Codacy Scalameta Pro
12
- "31677b6d-4ae0-4f56-8041-606a8d7a8e61" , # Pylint 2 (Python 3)
13
- "cf05f3aa-fd23-4586-8cce-5368917ec3e5" ] # ESLint 7 (deprecated)
11
+ IGNORED_TOOL_UUIDS = ["34225275-f79e-4b85-8126-c7512c987c0d" , # Pylint 1.9 (legacy)
12
+ "cf05f3aa-fd23-4586-8cce-5368917ec3e5" ] # ESLint 7 (deprecated)
14
13
15
14
16
15
def check_security_tools ():
@@ -24,16 +23,25 @@ def check_security_tools():
24
23
continue
25
24
tool_name = tool ["name" ]
26
25
tool_short_name = tool ["shortName" ]
26
+ # Hack to ensure that Pylint is detected
27
+ if tool_short_name == "pylintpython3" :
28
+ tool_name = "Pylint"
27
29
tool_languages = tool ["languages" ]
28
- code_patterns = requests .get (ENDPOINT_URL_CODE_PATTERNS .substitute (toolUuid = tool ["uuid" ])).json ()["data" ]
30
+ r = requests .get (ENDPOINT_URL_CODE_PATTERNS .substitute (toolUuid = tool ["uuid" ]))
31
+ code_patterns = r .json ()["data" ]
32
+ cursor = r .json ()["pagination" ].get ("cursor" , False )
33
+ while cursor :
34
+ r = requests .get (ENDPOINT_URL_CODE_PATTERNS .substitute (toolUuid = tool ["uuid" ]) + f"?cursor={ cursor } " )
35
+ code_patterns += r .json ()["data" ]
36
+ cursor = r .json ()["pagination" ].get ("cursor" , False )
29
37
for code_pattern in code_patterns :
30
38
if code_pattern ["category" ] == "Security" :
31
39
if tool_name .lower () in documentation or tool_short_name .lower () in documentation :
32
- print (emoji .emojize (f":check_mark_button: { tool_name } is included "
33
- f"( { ', ' . join ( map ( str , tool_languages )) } ) " ))
40
+ print (emoji .emojize (f":check_mark_button: { tool_name } ( { ', ' . join ( map ( str , tool_languages )) } ) "
41
+ f"is included, checked { len ( code_patterns ) } patterns " ))
34
42
else :
35
- print (emoji .emojize (f":cross_mark: { tool_name } ISN'T included "
36
- f"( { ', ' . join ( map ( str , tool_languages )) } ) " ))
43
+ print (emoji .emojize (f":cross_mark: { tool_name } ( { ', ' . join ( map ( str , tool_languages )) } ) "
44
+ f"ISN'T included, checked { len ( code_patterns ) } patterns " ))
37
45
count += 1
38
46
break
39
47
if count :
0 commit comments