codeaudit 1.9.0__py3-none-any.whl → 1.9.2__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2025-present Maikel Mardjan
2
2
  #
3
3
  # SPDX-License-Identifier: GPL-3.0-or-later
4
- __version__ = "1.9.0"
4
+ __version__ = "1.9.2"
@@ -139,11 +139,7 @@ def filescan(input_path, nosec=False):
139
139
  scan_output = _codeaudit_directory_scan(input_path, nosec_flag=nosec)
140
140
  output |= scan_output
141
141
  return output
142
- elif (
143
- file_path.suffix.lower() == ".py"
144
- and file_path.is_file()
145
- and is_ast_parsable(input_path)
146
- ): # check on parseable single Python file
142
+ elif is_ast_parsable(input_path): # check on parseable single Python file
147
143
  # do a file check
148
144
  file_information = overview_per_file(input_path)
149
145
  module_information = get_modules(input_path) # modules per file
@@ -464,11 +460,7 @@ def get_overview(input_path):
464
460
  else:
465
461
  output_msg = f"Directory path {input_path} contains no Python files."
466
462
  return {"Error": output_msg}
467
- elif (
468
- file_path.suffix.lower() == ".py"
469
- and file_path.is_file()
470
- and is_ast_parsable(input_path)
471
- ):
463
+ elif is_ast_parsable(input_path):
472
464
  security_statistics = overview_per_file(input_path)
473
465
  return security_statistics
474
466
  else:
codeaudit/corecli.py CHANGED
@@ -73,7 +73,7 @@ def display_help():
73
73
  summary = docstring.split("\n", 1)[0]
74
74
  print(f" {command:<20} {summary}")
75
75
  print(
76
- "\nUse the Python Code Audit documentation (https://codeaudit.nocomplexity.com) to audit and secure your Python programmes. Explore further essential open-source security tools at https://simplifysecurity.nocomplexity.com/\n"
76
+ "\nUse the Python Code Audit documentation (https://codeaudit.nocomplexity.com) to audit and secure your Python programmes. Explore further essential open-source security tools at https://pythonsecurity.nocomplexity.com/\n"
77
77
  )
78
78
 
79
79
 
@@ -18,6 +18,8 @@ import sys
18
18
  import warnings
19
19
  from pathlib import Path
20
20
 
21
+ from fileaudit.python_check import validate_python
22
+
21
23
 
22
24
  def read_in_source_file(file_path):
23
25
  # Ensure file_path is a Path object
@@ -97,24 +99,16 @@ def get_filename_from_path(file_path):
97
99
 
98
100
  def is_ast_parsable(file_path):
99
101
  """
100
- Checks whether a Python file can be parsed using the AST module.
102
+ Checks whether a Python file can be validated and parsed.
103
+ Uses the extensive security checker for valid Python files of the module https://github.com/nocomplexity/fileaudit
101
104
 
102
105
  Args:
103
- file_path (str): Path to the Python source file.
106
+ file_path (str | Path): Path to the Python source file.
104
107
 
105
108
  Returns:
106
- bool: True if the file can be parsed without syntax errors, False otherwise.
109
+ bool: True if the file passes Python validation, False otherwise.
107
110
  """
108
- try:
109
- with open(file_path, "r", encoding="utf-8") as f:
110
- source = f.read()
111
-
112
- with warnings.catch_warnings():
113
- warnings.simplefilter("ignore", category=SyntaxWarning)
114
- ast.parse(source, filename=file_path)
115
- return True
116
- except (SyntaxError, UnicodeDecodeError, ValueError) as e:
117
- return False
111
+ return validate_python(Path(file_path))
118
112
 
119
113
 
120
114
  def has_python_files(input_path):
@@ -14,6 +14,7 @@ Public API functions for Python Code Audit aka codeaudit on pypi.org
14
14
  """
15
15
 
16
16
  import gzip
17
+ import os
17
18
  import json
18
19
  import tarfile
19
20
  import tempfile
@@ -84,10 +85,35 @@ def get_pypi_download_info(package_name):
84
85
 
85
86
 
86
87
  def is_valid_tar_gz(path):
87
- """Return True if the given path is a valid .tar.gz file.
88
- Default values for validate_tar_gz are used! So note that NOT all tar.gz files will be accepted. Use PyPI tar.gz instead if possible.
88
+ """Return True only if the path points to a valid .tar.gz archive.
89
+
90
+ Archives must pass custom validation limits:
91
+ - Maximum file size: 15 MiB
92
+ - Maximum number of tar members: 12,000
89
93
  """
90
- return bool(validate_tar_gz(path, max_tar_members=3000))
94
+ try:
95
+ path = os.fspath(path)
96
+
97
+ return (
98
+ path.endswith(".tar.gz")
99
+ and validate_tar_gz(
100
+ path,
101
+ max_file_size=15 * 1024 * 1024,
102
+ max_tar_members=12000,
103
+ )
104
+ and tarfile.is_tarfile(path)
105
+ )
106
+ except (OSError, ValueError, TypeError, AttributeError, tarfile.TarError):
107
+ return False
108
+
109
+
110
+ # def is_valid_tar_gz(path):
111
+ # """Return True if the given path is a valid .tar.gz file.
112
+ # Custom validation values for validate_tar_gz are used. So note that NOT all tar.gz files will be accepted. Use PyPI package scan instead if possible.
113
+ # """
114
+ # return bool(
115
+ # validate_tar_gz(path, max_file_size=15 * 1024 * 1024, max_tar_members=12000)
116
+ # )
91
117
 
92
118
 
93
119
  def get_targz_package_source(
codeaudit/reporting.py CHANGED
@@ -160,7 +160,7 @@ def overview_report(directory, filename=DEFAULT_OUTPUT_FILE):
160
160
  print(f"ERROR: Directory '{directory}' contains no Python files.")
161
161
  exit(1)
162
162
  elif file_path.name.endswith(".tar.gz") and validate_tar_gz(
163
- directory
163
+ directory, max_file_size=15 * 1024 * 1024, max_tar_members=12000
164
164
  ): # for local tar.gz or remote tar.gz scans
165
165
  package_name = directory
166
166
  advice = f'<p>&#128073; To perform a SAST scan on the source code, run:<pre><code class="language-python">codeaudit filescan {directory}</code></pre></p>'
@@ -379,11 +379,7 @@ def scan_report(input_path, filename=DEFAULT_OUTPUT_FILE, nosec=False):
379
379
  directory_scan_report(
380
380
  input_path, nosec_flag=nosec, filename=filename
381
381
  ) # create a package aka directory scan report
382
- elif (
383
- file_path.suffix == ".py"
384
- and file_path.is_file()
385
- and is_ast_parsable(input_path)
386
- ):
382
+ elif is_ast_parsable(input_path):
387
383
  # create a sast file check report
388
384
  if not nosec: # no filtering on reviewed items with markers in code
389
385
  scan_output = perform_validations(
@@ -410,7 +406,7 @@ def scan_report(input_path, filename=DEFAULT_OUTPUT_FILE, nosec=False):
410
406
  create_htmlfile(html_output, filename)
411
407
 
412
408
  elif file_path.name.endswith(".tar.gz") and validate_tar_gz(
413
- input_path
409
+ input_path, max_file_size=15 * 1024 * 1024, max_tar_members=12000
414
410
  ): # for local tar.gz or remote tar.gz scans
415
411
  src_dir, tmp_handle = get_targz_package_source(input_path)
416
412
  directory_scan_report(
@@ -744,9 +740,7 @@ def report_module_information(inputfile, reportname=DEFAULT_OUTPUT_FILE):
744
740
  "See codeaudit modulescan -h or check the manual https://codeaudit.nocomplexity.com"
745
741
  )
746
742
  exit(1)
747
- elif (
748
- file_path.suffix == ".py" and file_path.is_file() and is_ast_parsable(inputfile)
749
- ):
743
+ elif is_ast_parsable(inputfile):
750
744
  source = read_in_source_file(inputfile)
751
745
  used_modules = get_imported_modules(source)
752
746
  # Initial call to print 0% progress
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeaudit
3
- Version: 1.9.0
3
+ Version: 1.9.2
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
@@ -35,7 +35,7 @@ Description-Content-Type: text/markdown
35
35
 
36
36
  # Codeaudit
37
37
 
38
- ![CodeauditLogo](https://github.com/nocomplexity/codeaudit/raw/main/docs/images/codeauditlogo.png)
38
+ [![CodeauditLogo](https://github.com/nocomplexity/codeaudit/raw/main/docs/images/codeauditlogo.png)](https://codeaudit.nocomplexity.com/)
39
39
 
40
40
  [![PythonCodeAudit Badge](https://img.shields.io/badge/Python%20Code%20Audit-Security%20Verified-FF0000?style=flat-square)](https://github.com/nocomplexity/codeaudit)
41
41
  [![PyPI - Version](https://img.shields.io/pypi/v/codeaudit.svg)](https://pypi.org/project/codeaudit)
@@ -43,6 +43,7 @@ Description-Content-Type: text/markdown
43
43
  [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/10970/badge)](https://www.bestpractices.dev/projects/10970)
44
44
  [![Documentation](https://img.shields.io/badge/Python%20Code%20Audit%20Handbook-Available-blue)](https://nocomplexity.com/documents/codeaudit/intro.html)
45
45
  [![License](https://img.shields.io/badge/License-GPLv3-FFD700)](https://nocomplexity.com/documents/codeaudit/license.html)
46
+ [![Try WebAssembly Version](https://img.shields.io/badge/Try_Live-In%20Your%20Browser-8A2BE2)](https://nocomplexity.com/codeauditapp/dashboardapp.html)
46
47
  [![PyPI Downloads](https://static.pepy.tech/badge/codeaudit)](https://pepy.tech/projects/codeaudit)
47
48
 
48
49
  Python Code Audit - A modern Python security source code analyzer based on distrust.
@@ -51,6 +52,15 @@ Python Code Audit is a static application security testing (SAST) tool designed
51
52
 
52
53
  This tool is designed for anyone who uses or creates Python programs and wants to understand and mitigate potential security risks.
53
54
 
55
+ > [!TIP]
56
+ > **Try it instantly — no installs, no setup, no excuses.**
57
+ >
58
+ > 👉 [Launch the browser version](https://nocomplexity.com/codeauditapp/dashboardapp.html)
59
+
60
+ It runs **100% locally** in your browser via WebAssembly (WASM). See the full power of **Python Code Audit** within 60 seconds.
61
+ No downloads. No dependencies. Just click and run a security audit on any Python package on PyPI!
62
+
63
+
54
64
  This tool is created for:
55
65
 
56
66
  - Python Users who want to assess the security risks in the Python code they use.
@@ -82,14 +92,6 @@ Python Code Audit has the following features:
82
92
 
83
93
  ## Installation
84
94
 
85
- > [!TIP]
86
- > Try it instantly—no installs, no setup, no excuses.
87
- >
88
- > 👉 Launch the browser version [here](https://nocomplexity.com/codeauditapp/dashboardapp.html)
89
-
90
- It runs 100% locally in your browser using WebAssembly (WASM). See the power of the tool in under 60 seconds.
91
- No downloads. No dependencies. Just click and do a security audit on Python Code.
92
-
93
95
  Loved the browser version? Unlock the full power. For advanced security code inspections, CI/CD integration, and all professional features, install the complete Python package:
94
96
 
95
97
  ```console
@@ -1,28 +1,28 @@
1
- codeaudit/__about__.py,sha256=z7EdWJDFqKqCMcBy6GVd_I8v3wA4k6JYY69ubBlHBps,122
1
+ codeaudit/__about__.py,sha256=lEwjjJlm2CvFjGxH6luX5N-xGFvuupCM1jTTMibyA_w,122
2
2
  codeaudit/__init__.py,sha256=vrz_p2yfDBQD-LBiT2hS0Nl6Da896DjCF4tBeg-3zmU,163
3
3
  codeaudit/altairplots.py,sha256=WsLmKqZ_sEysAv7q668WDnOlENk7YyHax24AwRihHC8,35906
4
4
  codeaudit/api_helpers.py,sha256=-B7XneWSfmYPfHnYRI149DtYTLjRf2Np3l0Tu6rNDQI,3810
5
- codeaudit/api_interfaces.py,sha256=J6rxn6vCYGjm7bvHW8eHH10Zc9SkKYtD3RXVD4V6XaY,31381
5
+ codeaudit/api_interfaces.py,sha256=yCkoIIWaHuF7QCxz2Z2ufbIGcvCrUEdolQirg-zfjxk,31193
6
6
  codeaudit/api_reporting.py,sha256=WRXPsS0t9ljdD_6gN5uN-t0xqNOuE9k5oqSmxaYWTf8,1585
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
10
- codeaudit/corecli.py,sha256=a_SR6c7TuZuDgQHDmsLp3j9mTavnbhr07gTcBJI5MVM,3960
10
+ codeaudit/corecli.py,sha256=LRYPGhuPIpYwc_-fNq0wQITAPIoa6nIY0doHejS6q38,3958
11
11
  codeaudit/dashboard_reports.py,sha256=A9e76T65ye158HQeqJHpuGzaaqx_oOnc5ChFfTXMz1A,17814
12
- codeaudit/filehelpfunctions.py,sha256=-TDLnkkNq_jDl8bcvPCdFINeriZEk2sihCh1jGhE3tI,4377
12
+ codeaudit/filehelpfunctions.py,sha256=oYdCoAMeNlik7KeaQ7tHs-lM0jdXjEfWykW0M9wtcE8,4221
13
13
  codeaudit/htmlhelpfunctions.py,sha256=z8vRqw9esLnk9Bsb7moOTLus5DSO34mQb4TYQfX6vd0,3247
14
14
  codeaudit/issuevalidations.py,sha256=55QL-cZqdU7SH2ZiHniKtphsgeXZrEOoFJeRZyp1X5E,6437
15
15
  codeaudit/privacy_lint.py,sha256=5t7Od16JNnb8SIGlEQy52c8vCxswnGO3SQbe-ilvqww,12439
16
- codeaudit/pypi_package_scan.py,sha256=6T5zvAMxcrXwIoLydRH7rIsJ-0H-eq2n0XkNg9MDVVQ,8795
17
- codeaudit/reporting.py,sha256=KgVsR7kMqEQoW6yTg8NO61YnKHu0L_IH7oX18S-gBYg,43007
16
+ codeaudit/pypi_package_scan.py,sha256=iqpFcG3-UHeGrOrDwNIP8SQOnEpLmcXYj9fKq3bepO8,9518
17
+ codeaudit/reporting.py,sha256=ZCc-NY4h9WwY7_Nfm6WjPyfWQ8s6eArNA0_hn9pF4vQ,42961
18
18
  codeaudit/security_checks.py,sha256=7nTlolMtI5MW-fhnOQonsp9W6-1QI1KDvNYO-NL5Am0,2149
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
22
  codeaudit/data/sastchecks.csv,sha256=qljGNtwDff-GypMhiSK2KYABWUzpOH5aetrzFbU7PDA,11100
23
23
  codeaudit/data/secretslist.txt,sha256=Vb-kuliUcuQHWAeuxIq3hZ-RNeKNXPNYIWoQe5SCTW4,1962
24
- codeaudit-1.9.0.dist-info/METADATA,sha256=EwPxbKAncvhreAaxpav07QG3UYuhdySfH78igjEiTak,8795
25
- codeaudit-1.9.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
26
- codeaudit-1.9.0.dist-info/entry_points.txt,sha256=LSpeBIiwDjyffyx_YQIUzmBOnmdCJ_V42onGC_5Nv5E,53
27
- codeaudit-1.9.0.dist-info/licenses/LICENSE.txt,sha256=-5gWaMGKJ54oX8TYP7oeg2zITdTapzyWl9PP0tispuA,34674
28
- codeaudit-1.9.0.dist-info/RECORD,,
24
+ codeaudit-1.9.2.dist-info/METADATA,sha256=w4M3E7DmLwvLMfFgA0wdlhtQmmzMvWY6vcoiJXNuphc,9023
25
+ codeaudit-1.9.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
26
+ codeaudit-1.9.2.dist-info/entry_points.txt,sha256=LSpeBIiwDjyffyx_YQIUzmBOnmdCJ_V42onGC_5Nv5E,53
27
+ codeaudit-1.9.2.dist-info/licenses/LICENSE.txt,sha256=-5gWaMGKJ54oX8TYP7oeg2zITdTapzyWl9PP0tispuA,34674
28
+ codeaudit-1.9.2.dist-info/RECORD,,