codeaudit 1.9.2__py3-none-any.whl → 1.9.3__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.
- codeaudit/__about__.py +1 -1
- codeaudit/altairplots.py +7 -29
- codeaudit/api_interfaces.py +29 -11
- codeaudit/api_reporting.py +23 -7
- codeaudit/data/sastchecks.csv +1 -1
- {codeaudit-1.9.2.dist-info → codeaudit-1.9.3.dist-info}/METADATA +3 -2
- {codeaudit-1.9.2.dist-info → codeaudit-1.9.3.dist-info}/RECORD +10 -10
- {codeaudit-1.9.2.dist-info → codeaudit-1.9.3.dist-info}/WHEEL +1 -1
- {codeaudit-1.9.2.dist-info → codeaudit-1.9.3.dist-info}/entry_points.txt +0 -0
- {codeaudit-1.9.2.dist-info → codeaudit-1.9.3.dist-info}/licenses/LICENSE.txt +0 -0
codeaudit/__about__.py
CHANGED
codeaudit/altairplots.py
CHANGED
|
@@ -18,7 +18,8 @@ import pandas as pd
|
|
|
18
18
|
|
|
19
19
|
from collections import Counter
|
|
20
20
|
from pathlib import Path
|
|
21
|
-
|
|
21
|
+
from codeaudit.api_interfaces import get_weakness_counts
|
|
22
|
+
from codeaudit.api_reporting import total_weaknesses
|
|
22
23
|
|
|
23
24
|
def module_count_barchart(scanresult):
|
|
24
25
|
"""Create a bar chart showing module counts by category.
|
|
@@ -689,20 +690,8 @@ def weaknesses_overview(scanresult):
|
|
|
689
690
|
.mark_text()
|
|
690
691
|
.encode(text="msg:N")
|
|
691
692
|
)
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
counter = Counter()
|
|
695
|
-
for file_info in file_security_info.values():
|
|
696
|
-
if not isinstance(file_info, dict):
|
|
697
|
-
continue
|
|
698
|
-
sast_result = file_info.get("sast_result")
|
|
699
|
-
if not isinstance(sast_result, dict):
|
|
700
|
-
continue
|
|
701
|
-
for finding in sast_result.values():
|
|
702
|
-
if isinstance(finding, dict):
|
|
703
|
-
validation = finding.get("validation")
|
|
704
|
-
if validation and isinstance(validation, str):
|
|
705
|
-
counter[validation] += 1
|
|
693
|
+
# --- Count every validation across all files ---
|
|
694
|
+
counter = Counter(get_weakness_counts(scanresult))
|
|
706
695
|
|
|
707
696
|
if not counter:
|
|
708
697
|
return (
|
|
@@ -875,7 +864,7 @@ def sast_files_overview(scanresult):
|
|
|
875
864
|
"base_name": base_name,
|
|
876
865
|
"parent_folder": parent_folder,
|
|
877
866
|
"full_path": str(filepath),
|
|
878
|
-
"issues":
|
|
867
|
+
"issues": total_weaknesses(scanresult),
|
|
879
868
|
"complexity": file_info.get("Complexity_Score", 0),
|
|
880
869
|
}
|
|
881
870
|
)
|
|
@@ -977,19 +966,8 @@ def weaknesses_radial_overview(scanresult):
|
|
|
977
966
|
)
|
|
978
967
|
|
|
979
968
|
# --- Count every 'validation' across all files ---
|
|
980
|
-
counter = Counter()
|
|
981
|
-
|
|
982
|
-
if not isinstance(file_info, dict):
|
|
983
|
-
continue
|
|
984
|
-
sast_result = file_info.get("sast_result")
|
|
985
|
-
if not isinstance(sast_result, dict):
|
|
986
|
-
continue
|
|
987
|
-
for finding in sast_result.values():
|
|
988
|
-
if isinstance(finding, dict):
|
|
989
|
-
validation = finding.get("validation")
|
|
990
|
-
if validation and isinstance(validation, str):
|
|
991
|
-
counter[validation] += 1
|
|
992
|
-
|
|
969
|
+
counter = Counter(get_weakness_counts(scanresult))
|
|
970
|
+
|
|
993
971
|
if not counter:
|
|
994
972
|
return (
|
|
995
973
|
alt.Chart(
|
codeaudit/api_interfaces.py
CHANGED
|
@@ -315,38 +315,56 @@ def read_input_file(filename, safe_directory="data_folder"):
|
|
|
315
315
|
|
|
316
316
|
def get_weakness_counts(input_file, nosec=False):
|
|
317
317
|
"""
|
|
318
|
-
|
|
318
|
+
Count SAST weaknesses.
|
|
319
|
+
|
|
320
|
+
Accepts either:
|
|
321
|
+
- A scan result dictionary.
|
|
322
|
+
- A file/package path that will be scanned.
|
|
319
323
|
"""
|
|
320
|
-
|
|
321
|
-
|
|
324
|
+
|
|
325
|
+
# Accept an existing scan result or scan a file/package
|
|
326
|
+
if isinstance(input_file, dict):
|
|
327
|
+
scan_result = input_file
|
|
328
|
+
else:
|
|
329
|
+
scan_result = filescan(input_file, nosec)
|
|
322
330
|
|
|
323
331
|
if not isinstance(scan_result, dict):
|
|
324
|
-
raise ValueError("
|
|
332
|
+
raise ValueError("Invalid scan result")
|
|
325
333
|
|
|
326
334
|
if "Error" in scan_result:
|
|
327
335
|
raise ValueError(scan_result["Error"])
|
|
328
336
|
|
|
329
337
|
file_security_info = scan_result.get("file_security_info")
|
|
338
|
+
|
|
330
339
|
if not isinstance(file_security_info, dict):
|
|
331
340
|
return {}
|
|
332
341
|
|
|
333
342
|
counter = Counter()
|
|
334
343
|
|
|
335
344
|
for file_info in file_security_info.values():
|
|
345
|
+
|
|
336
346
|
if not isinstance(file_info, dict):
|
|
337
347
|
continue
|
|
338
348
|
|
|
339
349
|
sast_result = file_info.get("sast_result", {})
|
|
350
|
+
|
|
340
351
|
if not isinstance(sast_result, dict):
|
|
341
352
|
continue
|
|
342
353
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if isinstance(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
354
|
+
for finding in sast_result.values():
|
|
355
|
+
|
|
356
|
+
# Support individual findings and lists of findings
|
|
357
|
+
findings = finding if isinstance(finding, list) else [finding]
|
|
358
|
+
|
|
359
|
+
for issue in findings:
|
|
360
|
+
|
|
361
|
+
if not isinstance(issue, dict):
|
|
362
|
+
continue
|
|
363
|
+
|
|
364
|
+
weakness_type = issue.get("validation", "Unknown")
|
|
365
|
+
|
|
366
|
+
if isinstance(weakness_type, str) and weakness_type:
|
|
367
|
+
counter[weakness_type] += 1
|
|
350
368
|
|
|
351
369
|
return dict(counter)
|
|
352
370
|
|
codeaudit/api_reporting.py
CHANGED
|
@@ -19,17 +19,33 @@ So all results are returned as Pandas Dataframe. This makes things easier for fu
|
|
|
19
19
|
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
def total_weaknesses(scan_result):
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
"""Count all individual weaknesses in a scan result.
|
|
24
|
+
|
|
25
|
+
Walks through each file's SAST findings and adds up every
|
|
26
|
+
individual weakness found.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
scan_result (dict): Scan output with a "file_security_info" key
|
|
30
|
+
mapping file names to their per-file results. Each file's
|
|
31
|
+
"sast_result" maps check names to either a single finding
|
|
32
|
+
or a list of findings.
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
Returns:
|
|
35
|
+
int: Total number of individual weaknesses across all files.
|
|
36
|
+
"""
|
|
29
37
|
total = 0
|
|
30
38
|
|
|
31
|
-
|
|
39
|
+
file_security_info = scan_result.get("file_security_info", {})
|
|
40
|
+
|
|
41
|
+
for file_info in file_security_info.values():
|
|
32
42
|
sast_result = file_info.get("sast_result", {})
|
|
33
|
-
|
|
43
|
+
|
|
44
|
+
for finding in sast_result.values():
|
|
45
|
+
if isinstance(finding, list):
|
|
46
|
+
total += len(finding)
|
|
47
|
+
else:
|
|
48
|
+
total += 1
|
|
34
49
|
|
|
35
50
|
return total
|
|
51
|
+
|
codeaudit/data/sastchecks.csv
CHANGED
|
@@ -9,7 +9,7 @@ Directory Creation,os.mknod,Low,Direct file system calls require careful input v
|
|
|
9
9
|
Directory Creation,os.makedev,Low,Direct file system calls require careful input validation to prevent vulnerabilities.
|
|
10
10
|
OS Forking,os.fork,Low,"On macOS use of this function is unsafe when mixed with using higher-level system APIs, and that includes using urllib.request."
|
|
11
11
|
Dangerous Built-in: eval,eval,High,This function can execute arbitrary code. Never safe with untrusted input.
|
|
12
|
-
Input Function,input,
|
|
12
|
+
Input Function,input,High,User input must be strictly sanitized and validated to prevent injection vulnerabilities.
|
|
13
13
|
Overly Broad Exception Handling,pass,Low,Using `pass` in an `except` block can silently ignore critical security exceptions.
|
|
14
14
|
Overly Broad Exception Handling,continue,Low,Skipping over exceptions can mask critical errors and security risks.
|
|
15
15
|
Dangerous Built-in: exec,exec,High,This function can execute arbitrary code and should be used only with validated constructs.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: codeaudit
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.3
|
|
4
4
|
Summary: A modern Python security source code analyzer (SAST) based on distrust.
|
|
5
5
|
Project-URL: Homepage, https://codeaudit.nocomplexity.com
|
|
6
6
|
Project-URL: Documentation, https://github.com/nocomplexity/codeaudit#readme
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
22
|
Classifier: Topic :: Security
|
|
22
23
|
Classifier: Topic :: Software Development :: Quality Assurance
|
|
23
24
|
Requires-Python: >=3.12
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
codeaudit/__about__.py,sha256=
|
|
1
|
+
codeaudit/__about__.py,sha256=nlCTz8cZKQ_lQkUGmTqOtBkb9ZCNmkdh5Rfk-vdyGe0,122
|
|
2
2
|
codeaudit/__init__.py,sha256=vrz_p2yfDBQD-LBiT2hS0Nl6Da896DjCF4tBeg-3zmU,163
|
|
3
|
-
codeaudit/altairplots.py,sha256=
|
|
3
|
+
codeaudit/altairplots.py,sha256=mKM2JApYE5yDwV4qygAK1eDj3ykZ-YgXFnekH7iWyo0,35131
|
|
4
4
|
codeaudit/api_helpers.py,sha256=-B7XneWSfmYPfHnYRI149DtYTLjRf2Np3l0Tu6rNDQI,3810
|
|
5
|
-
codeaudit/api_interfaces.py,sha256=
|
|
6
|
-
codeaudit/api_reporting.py,sha256=
|
|
5
|
+
codeaudit/api_interfaces.py,sha256=pAn823GLa3Et76fOCQ_Lqh1wVLq_uCPjG7oJURPdl-Y,31337
|
|
6
|
+
codeaudit/api_reporting.py,sha256=cHAv5FkwGzTfNI-4n5qNR-t7ZegpqBZjw1kUq8lpaVI,2054
|
|
7
7
|
codeaudit/checkmodules.py,sha256=gDQXD1D79zUPgbTtATy-CG7FQuZYLjrukbmXSF-eL08,6505
|
|
8
8
|
codeaudit/ci_workflowscan.py,sha256=ccA_38wTXPyGfWuGgaU9hGtt-HuX3f6cTh_EkaGRaWA,14285
|
|
9
9
|
codeaudit/complexitycheck.py,sha256=7ILf2wYho6DDiC-Q3ZjuJGbUZb1TaGfkTkWKtLO8_RU,4236
|
|
@@ -19,10 +19,10 @@ codeaudit/security_checks.py,sha256=7nTlolMtI5MW-fhnOQonsp9W6-1QI1KDvNYO-NL5Am0,
|
|
|
19
19
|
codeaudit/simple.css,sha256=H7KT61oXJkVr9qXVrC5ME_Zph9jI-uR2IxOsXG1xs5k,4013
|
|
20
20
|
codeaudit/suppression.py,sha256=8ZX8NAoWxJjgP3ZruvuQz5G_XFmPvyjOAYF84Q6bT2M,7755
|
|
21
21
|
codeaudit/totals.py,sha256=i7Y5gXEk52p93Mo_usK2VATq1LmtBkFVKNGvT8AjJzw,6401
|
|
22
|
-
codeaudit/data/sastchecks.csv,sha256=
|
|
22
|
+
codeaudit/data/sastchecks.csv,sha256=9hhZun778xfQPRKl_b-i-HJ-KfDW0SmvBYh0FUL1Mws,11101
|
|
23
23
|
codeaudit/data/secretslist.txt,sha256=Vb-kuliUcuQHWAeuxIq3hZ-RNeKNXPNYIWoQe5SCTW4,1962
|
|
24
|
-
codeaudit-1.9.
|
|
25
|
-
codeaudit-1.9.
|
|
26
|
-
codeaudit-1.9.
|
|
27
|
-
codeaudit-1.9.
|
|
28
|
-
codeaudit-1.9.
|
|
24
|
+
codeaudit-1.9.3.dist-info/METADATA,sha256=oiQ7armvgM3rp72-niELtWPt77OzCNmGgVf4R_p-XPc,9074
|
|
25
|
+
codeaudit-1.9.3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
26
|
+
codeaudit-1.9.3.dist-info/entry_points.txt,sha256=LSpeBIiwDjyffyx_YQIUzmBOnmdCJ_V42onGC_5Nv5E,53
|
|
27
|
+
codeaudit-1.9.3.dist-info/licenses/LICENSE.txt,sha256=-5gWaMGKJ54oX8TYP7oeg2zITdTapzyWl9PP0tispuA,34674
|
|
28
|
+
codeaudit-1.9.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|