codeaudit 1.3.0__tar.gz → 1.4.1__tar.gz

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 (160) hide show
  1. {codeaudit-1.3.0 → codeaudit-1.4.1}/CHANGELOG.md +36 -0
  2. {codeaudit-1.3.0 → codeaudit-1.4.1}/PKG-INFO +10 -16
  3. {codeaudit-1.3.0 → codeaudit-1.4.1}/README.md +9 -15
  4. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/CLIcommands.ipynb +2 -2
  5. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/_toc.yml +1 -1
  6. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/base64_check.md +14 -5
  7. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/builtinfunctions_check.md +58 -1
  8. codeaudit-1.4.1/docs/checks/random_check.md +67 -0
  9. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/zipfile_check.md +7 -2
  10. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/codeauditcommands.md +12 -12
  11. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/codeauditoverview.md +15 -4
  12. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/complexitycheck.md +30 -7
  13. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/demoscan.json +2 -2
  14. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/filescan.md +5 -0
  15. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/help.md +1 -1
  16. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/howtoscan.md +9 -2
  17. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/intro.md +1 -1
  18. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/project_philosophy.md +3 -1
  19. codeaudit-1.4.1/docs/securecoding.md +116 -0
  20. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/userguide.md +1 -1
  21. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/whysast.md +2 -2
  22. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/__about__.py +1 -1
  23. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/altairplots.py +26 -0
  24. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/api_interfaces.py +1 -1
  25. codeaudit-1.4.1/src/codeaudit/api_reporting.py +36 -0
  26. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/codeaudit.py +2 -2
  27. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/data/sastchecks.csv +2 -0
  28. codeaudit-1.4.1/src/codeaudit/pypi_package_scan.py +112 -0
  29. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/reporting.py +77 -26
  30. codeaudit-1.4.1/tests/test_pypiscan.py +69 -0
  31. codeaudit-1.4.1/tests/test_zstd.py +23 -0
  32. codeaudit-1.4.1/tests/validationfiles/zstd.py +11 -0
  33. codeaudit-1.3.0/docs/checks/random_check.md +0 -15
  34. {codeaudit-1.3.0 → codeaudit-1.4.1}/.gitignore +0 -0
  35. {codeaudit-1.3.0 → codeaudit-1.4.1}/CONTRIBUTE.md +0 -0
  36. {codeaudit-1.3.0 → codeaudit-1.4.1}/LICENSE.txt +0 -0
  37. {codeaudit-1.3.0 → codeaudit-1.4.1}/SECURITY.md +0 -0
  38. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/CONTRIBUTE.md +0 -0
  39. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/_config.yml +0 -0
  40. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/_static/nocxstyle.css +0 -0
  41. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/about.md +0 -0
  42. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/apidocs/api_intro.md +0 -0
  43. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/apidocs/codeaudit.rst +0 -0
  44. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/apidocs/modules.rst +0 -0
  45. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/astlines.md +0 -0
  46. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/astlines2.md +0 -0
  47. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/changelog.md +0 -0
  48. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/assert_check.md +0 -0
  49. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/binding_check.md +0 -0
  50. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/chmod_check.md +0 -0
  51. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/directorycreation_check.md +0 -0
  52. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/dynamicimport_check.md +0 -0
  53. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/exception_check.md +0 -0
  54. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/hash_check.md +0 -0
  55. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/httpserver_check.md +0 -0
  56. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/input_check.md +0 -0
  57. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/loggingconf_check.md +0 -0
  58. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/marshal_check.md +0 -0
  59. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/mktemp_check.md +0 -0
  60. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/multiprocessing_check.md +0 -0
  61. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/pickle_check.md +0 -0
  62. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/shelve_check.md +0 -0
  63. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/shutil_check.md +0 -0
  64. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/subprocess_check.md +0 -0
  65. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/syscalls_check.md +0 -0
  66. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/systemcalls_check.md +0 -0
  67. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/tarfile_extract_check.md +0 -0
  68. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checks/xml_check.md +0 -0
  69. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/checksinformation.md +0 -0
  70. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/codeauditchecks.md +0 -0
  71. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/ca_api_example_basic.ipynb +0 -0
  72. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/ca_api_example_json.ipynb +0 -0
  73. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/ca_api_example_overview.ipynb +0 -0
  74. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/checks.html +0 -0
  75. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/demofile.py +0 -0
  76. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/directoryscan.html +0 -0
  77. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/filescan.html +0 -0
  78. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/modulescan.html +0 -0
  79. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/examples/overview.html +0 -0
  80. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/features.md +0 -0
  81. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/filescan.png +0 -0
  82. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/handling_errors.md +0 -0
  83. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/images/OO.png +0 -0
  84. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/images/ROI_logo.png +0 -0
  85. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/images/YourLogoHere.png +0 -0
  86. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/images/codeauditlogo.png +0 -0
  87. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/images/nocxbanner.png +0 -0
  88. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/images/overview_linkaudit.png +0 -0
  89. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/implementedvalidations.md +0 -0
  90. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/issues.md +0 -0
  91. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/license.md +0 -0
  92. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/makeitbetter.md +0 -0
  93. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/modulescan.md +0 -0
  94. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/overviewplot.png +0 -0
  95. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/pca_overview.png +0 -0
  96. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/sponsors.md +0 -0
  97. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/warnings.md +0 -0
  98. {codeaudit-1.3.0 → codeaudit-1.4.1}/docs/whatissast.md +0 -0
  99. {codeaudit-1.3.0 → codeaudit-1.4.1}/filescan.png +0 -0
  100. {codeaudit-1.3.0 → codeaudit-1.4.1}/pyproject.toml +0 -0
  101. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/__init__.py +0 -0
  102. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/checkmodules.py +0 -0
  103. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/complexitycheck.py +0 -0
  104. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/filehelpfunctions.py +0 -0
  105. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/htmlhelpfunctions.py +0 -0
  106. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/issuevalidations.py +0 -0
  107. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/security_checks.py +0 -0
  108. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/simple.css +0 -0
  109. {codeaudit-1.3.0 → codeaudit-1.4.1}/src/codeaudit/totals.py +0 -0
  110. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/__init__.py +0 -0
  111. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/count_lines_file1.py +0 -0
  112. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_apicalls.py +0 -0
  113. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_basicpatterns.py +0 -0
  114. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_chmod.py +0 -0
  115. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_constructspart2.py +0 -0
  116. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_correctexceptionuse.py +0 -0
  117. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_count_commentlines.py +0 -0
  118. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_directorycreation.py +0 -0
  119. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_directorycreation2.py +0 -0
  120. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_hashstrenght.py +0 -0
  121. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_modulecheck.py +0 -0
  122. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_obfuscatingbuiltins.py +0 -0
  123. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_oschecks.py +0 -0
  124. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_random.py +0 -0
  125. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_standardlibconstructs.py +0 -0
  126. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/test_totalscheck.py +0 -0
  127. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/allshit.py +0 -0
  128. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/assert.py +0 -0
  129. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/base64.py +0 -0
  130. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/chmod_things.py +0 -0
  131. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/complexitycheck.py +0 -0
  132. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/correctcounts.py +0 -0
  133. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/directorycreation.py +0 -0
  134. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/directorycreation2.py +0 -0
  135. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/dunderexec_with_parsing_error.py +0 -0
  136. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/exception.py +0 -0
  137. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/file3.py +0 -0
  138. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/file_with_warnings.py +0 -0
  139. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/gzip.py +0 -0
  140. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/hashcheck.py +0 -0
  141. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/httpserver.py +0 -0
  142. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/inputstatement.py +0 -0
  143. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/marshal.py +0 -0
  144. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/modulecheck.py +0 -0
  145. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/multiprocessing.py +0 -0
  146. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/obfuscating.py +0 -0
  147. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/oschecks.py +0 -0
  148. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/pickle.py +0 -0
  149. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/python2_file_willnotwork.py +0 -0
  150. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/random.py +0 -0
  151. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/shelve.py +0 -0
  152. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/shutil.py +0 -0
  153. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/subprocess.py +0 -0
  154. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/syslibrary.py +0 -0
  155. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/tarfilevalidation.py +0 -0
  156. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/tempcheck.py +0 -0
  157. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/validation1.py +0 -0
  158. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/validation2.py +0 -0
  159. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/xml.py +0 -0
  160. {codeaudit-1.3.0 → codeaudit-1.4.1}/tests/validationfiles/zipfile.py +0 -0
@@ -1,6 +1,42 @@
1
1
  # Change Log
2
2
 
3
+ ## Version 1.4.1: Bug fixes
3
4
 
5
+ 🚀 New Features & Enhancements
6
+ * Remote PyPI Auditing: The codeaudit overview command now supports packages hosted directly on PyPI.org.
7
+
8
+
9
+ 🛠 Bug Fixes
10
+ * Improved sdist Resilience: Enhanced error handling for scenarios where a package exists on PyPI but a source distribution (sdist) is unavailable.
11
+
12
+
13
+ 📝 Documentation & UI Updates
14
+ * CLI Improvements: Refined terminal text and messaging for better clarity during operation.
15
+ * Manual Update: The user manual has been updated to reflect new command capabilities and workflows.
16
+
17
+
18
+ ## Version 1.4: Changes and Updates
19
+
20
+
21
+ 🚀 New Features and Enhancements
22
+ Direct PyPI Package Scanning: You can now directly scan packages hosted on PyPI from the command line interface (CLI).
23
+
24
+ * Usage: Use the existing codeaudit filescan command followed by the package name.
25
+
26
+ Example: `codeaudit filescan [package_name]`
27
+
28
+ Consult the [documentation](https://nocomplexity.com/documents/codeaudit/intro.html#) for full details.
29
+
30
+ * HTML Report Text Improvement: The text content and clarity of the generated HTML reports have been enhanced for better readability.
31
+
32
+ 🛡️ Security Validation Updates
33
+ New Weakness Detection (Python 3.14+): Added a new validation rule to detect potential weaknesses when using the newly added compression.zstd module (available in Python 3.14 and later).
34
+
35
+ The scanner now specifically flags cases where compression.zstd is used for decompressing or opening a zstd compressed archive.
36
+
37
+ 🐛 Bug Fixes and Documentation
38
+ * Documentation Correction: Corrected and improved the help text for the API call get_construct_counts().
39
+ And many small improvements on the manual to assist you better with outlining risks on found weaknesses and possible mitigations.
4
40
 
5
41
 
6
42
  ## Version 1.3: Changes and Updates
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeaudit
3
- Version: 1.3.0
3
+ Version: 1.4.1
4
4
  Summary: Simplified static security checks for Python
5
5
  Project-URL: Documentation, https://github.com/nocomplexity/codeaudit#readme
6
6
  Project-URL: Issues, https://github.com/nocomplexity/codeaudit/issues
@@ -74,17 +74,12 @@ Python Code Audit has the following features:
74
74
 
75
75
  ## Installation
76
76
 
77
- ```console
78
- pip install codeaudit
79
- ```
80
-
81
- or use:
82
-
83
77
  ```console
84
78
  pip install -U codeaudit
85
79
  ```
86
80
 
87
- If you have installed Python `codeaudit` in the past and want to make sure you use the latest new validations and features.
81
+ If you have installed **Python Code Audit** previously and want to ensure you are using the latest validations and features, simply run this command again. Python Code Audit is frequently updated with new checks.
82
+
88
83
 
89
84
  ## Usage
90
85
 
@@ -106,34 +101,33 @@ This will show all commands:
106
101
  Python Code Audit - A modern Python security source code analyzer based on distrust.
107
102
 
108
103
  Commands to evaluate Python source code:
109
- Usage: codeaudit COMMAND [PATH or FILE] [OUTPUTFILE]
104
+ Usage: codeaudit COMMAND <directory|package> [report.html]
110
105
 
111
- Depending on the command, a directory or file name must be specified. The output is a static HTML file to be examined in a browser. Specifying a name for the output file is optional.
106
+ Depending on the command, you must specify a local directory, a Python file, or a package name hosted on PyPI.org.Reporting: The results are generated as a static HTML report for viewing in a web browser.
112
107
 
113
108
  Commands:
114
- overview Reports Complexity and statistics per Python file from a directory.
115
- filescan Scans Python files or directories(packages) for vulnerabilities and reports potential issues.
109
+ overview Reports complexity and security statistics of a Python project or package on PyPI.org.
110
+ filescan Scans Python code or packages on PyPI.org for security weaknesses.
116
111
  modulescan Reports module vulnerability information.
117
112
  checks Creates an HTML report of all implemented security checks.
118
113
  version Prints the module version. Or use codeaudit [-v] [--v] [-version] or [--version].
119
114
 
120
115
  Use the Codeaudit documentation to check the security of Python programs and make your Python programs more secure!
121
116
  Check https://simplifysecurity.nocomplexity.com/
122
-
123
117
  ```
124
118
 
125
119
  ## Example
126
120
 
127
- By running the `codeaudit filescan` command, detailed security information is determined for a Python file based on more than **70 validations** implemented.
121
+ By running the `codeaudit filescan` command, detailed security information is determined for a Python file based on more than **80 validations** implemented.
128
122
 
129
123
  The `codeaudit filescan` command shows all **potential** security issues that are detected in the source file in a HTML-report.
130
124
 
131
125
  Per line a the in construct that can cause a security risks is shown, along with the relevant code lines where the issue is detected.
132
126
 
133
- To scan a Python file on possible security issues, do:
127
+ To scan a Python package on PyPI.org on possible security issues, do:
134
128
 
135
129
  ```bash
136
- codeaudit filescan ../codeaudit/tests/validationfiles/allshit.py
130
+ codeaudit filescan <package-name> [reportname.html]
137
131
 
138
132
  =====================================================================
139
133
  Codeaudit report file created!
@@ -46,17 +46,12 @@ Python Code Audit has the following features:
46
46
 
47
47
  ## Installation
48
48
 
49
- ```console
50
- pip install codeaudit
51
- ```
52
-
53
- or use:
54
-
55
49
  ```console
56
50
  pip install -U codeaudit
57
51
  ```
58
52
 
59
- If you have installed Python `codeaudit` in the past and want to make sure you use the latest new validations and features.
53
+ If you have installed **Python Code Audit** previously and want to ensure you are using the latest validations and features, simply run this command again. Python Code Audit is frequently updated with new checks.
54
+
60
55
 
61
56
  ## Usage
62
57
 
@@ -78,34 +73,33 @@ This will show all commands:
78
73
  Python Code Audit - A modern Python security source code analyzer based on distrust.
79
74
 
80
75
  Commands to evaluate Python source code:
81
- Usage: codeaudit COMMAND [PATH or FILE] [OUTPUTFILE]
76
+ Usage: codeaudit COMMAND <directory|package> [report.html]
82
77
 
83
- Depending on the command, a directory or file name must be specified. The output is a static HTML file to be examined in a browser. Specifying a name for the output file is optional.
78
+ Depending on the command, you must specify a local directory, a Python file, or a package name hosted on PyPI.org.Reporting: The results are generated as a static HTML report for viewing in a web browser.
84
79
 
85
80
  Commands:
86
- overview Reports Complexity and statistics per Python file from a directory.
87
- filescan Scans Python files or directories(packages) for vulnerabilities and reports potential issues.
81
+ overview Reports complexity and security statistics of a Python project or package on PyPI.org.
82
+ filescan Scans Python code or packages on PyPI.org for security weaknesses.
88
83
  modulescan Reports module vulnerability information.
89
84
  checks Creates an HTML report of all implemented security checks.
90
85
  version Prints the module version. Or use codeaudit [-v] [--v] [-version] or [--version].
91
86
 
92
87
  Use the Codeaudit documentation to check the security of Python programs and make your Python programs more secure!
93
88
  Check https://simplifysecurity.nocomplexity.com/
94
-
95
89
  ```
96
90
 
97
91
  ## Example
98
92
 
99
- By running the `codeaudit filescan` command, detailed security information is determined for a Python file based on more than **70 validations** implemented.
93
+ By running the `codeaudit filescan` command, detailed security information is determined for a Python file based on more than **80 validations** implemented.
100
94
 
101
95
  The `codeaudit filescan` command shows all **potential** security issues that are detected in the source file in a HTML-report.
102
96
 
103
97
  Per line a the in construct that can cause a security risks is shown, along with the relevant code lines where the issue is detected.
104
98
 
105
- To scan a Python file on possible security issues, do:
99
+ To scan a Python package on PyPI.org on possible security issues, do:
106
100
 
107
101
  ```bash
108
- codeaudit filescan ../codeaudit/tests/validationfiles/allshit.py
102
+ codeaudit filescan <package-name> [reportname.html]
109
103
 
110
104
  =====================================================================
111
105
  Codeaudit report file created!
@@ -90,7 +90,7 @@
90
90
  },
91
91
  {
92
92
  "cell_type": "code",
93
- "execution_count": 16,
93
+ "execution_count": null,
94
94
  "id": "bf6afe56-e0f7-4fa2-a3a5-968bad11bf9c",
95
95
  "metadata": {},
96
96
  "outputs": [],
@@ -101,7 +101,7 @@
101
101
  " \"checks\" : 'report_implemented_tests',\n",
102
102
  " \"version\" : 'display_version'} \n",
103
103
  "for key, value in commands.items(): \n",
104
- " output += f'## Code Audit {key}\\n' # newlines matter when creating markdown\n",
104
+ " output += f'## codeaudit {key}\\n' # newlines matter when creating markdown\n",
105
105
  " output += '```text\\n' # raw display \n",
106
106
  " func_name = value\n",
107
107
  " output += getattr(codeaudit, func_name).__doc__\n",
@@ -47,7 +47,7 @@ parts:
47
47
  - file: checks/xml_check
48
48
  - file: checks/zipfile_check
49
49
  - file: checks/shutil_check
50
-
50
+ - file: securecoding
51
51
 
52
52
  - caption: Architecture
53
53
  chapters:
@@ -1,11 +1,19 @@
1
1
  # Base64 Statements
2
2
 
3
- Codeaudit checks on use of:
4
- * Base64 Encoding / Decoding
3
+ Python Code Audit checks for obfuscated text, particularly content encoded with `base64`:
5
4
 
6
- The `base64` module requires specific security considerations.
5
+ * `base64` Encoding / Decoding.
7
6
 
8
- It’s recommended to review the security considerations for any code deployed to production using `base64` encoding.
7
+
8
+ ## Rationale
9
+
10
+
11
+ Obfuscation is a long-standing and straightforward technique often used to conceal malicious code within Python projects. This technique allows attackers to easily hide malware within Python programs.
12
+
13
+ The presence of obfuscated content is atypical in well-structured, non-malicious Python code and is a significant indicator of potential security risks.
14
+
15
+
16
+ It’s recommended to review any code deployed to production using `base64` encoding. **Python Code Audit** does this automatically.
9
17
 
10
18
  Security considerations section from RFC 4648 (section 12):
11
19
 
@@ -50,4 +58,5 @@ Security Considerations
50
58
  ## More information
51
59
 
52
60
  * https://docs.python.org/3/library/base64.html#base64-security
53
- * https://datatracker.ietf.org/doc/html/rfc4648.html#page-14
61
+ * https://datatracker.ietf.org/doc/html/rfc4648.html#page-14
62
+ * [Base64 Malleability in Practice](https://eprint.iacr.org/2022/361.pdf)
@@ -127,12 +127,69 @@ Using this construct can still crash the Python interpreter due to stack depth l
127
127
 
128
128
  * Avoid using `eval`,`exec` and `compile`: Find a secure way by design, so rethink your design again from a security perspective. There is always a better and safer solution.
129
129
 
130
+ * Use a battle-tested safe expression evaluator.
131
+
132
+ * Rethink the architecture to eliminate exec(), which introduces unnecessary risk.
133
+
134
+ * For in-browser sandboxing, use Pyodide (e.g., via JupyterLite)(https://jupyterlite.readthedocs.io/en/latest/ ).
135
+
136
+ * Call Functions or Methods by Name (String Input)
137
+ If a function needs to be called based on a string name (e.g., from user input), store the functions in a dictionary and look them up by key. Avoid:
138
+ ```python
139
+ func_name = input("Enter function to run: ")
140
+ exec(f"{func_name}()")
141
+ ```
142
+
143
+ Recommended Alternative (Dictionary of Functions):
144
+
145
+ ```python
146
+ def greet():
147
+ print("Hello!")
148
+
149
+ def quit_app():
150
+ import sys
151
+ sys.exit()
152
+
153
+ available_functions = {
154
+ "greet": greet,
155
+ "quit": quit_app
156
+ }
157
+
158
+ func_name = input("Enter function to run (greet or quit): ")
159
+ if func_name in available_functions:
160
+ available_functions[func_name]()
161
+ else:
162
+ print("Unknown function")
163
+ ```
164
+
165
+ * For evaluating simple, safe expressions, use ast.literal_eval() which safely evaluates basic Python literals without allowing full code execution.
166
+ Avoid:
167
+ ```
168
+ exec("import os; os.system('your_command')")
169
+ ```
170
+ Recommended Alternative (`ast.literal_eval`):
171
+ ```python
172
+ import ast
173
+ user_input = "(2 + 3) * 5"
174
+ try:
175
+ result = ast.literal_eval(user_input)
176
+ print(result)
177
+ except (ValueError, SyntaxError):
178
+ print("Invalid input")
179
+ ```
180
+
181
+
130
182
 
131
183
 
132
184
  ## More information
133
185
 
186
+ * [CWE-94: Improper Control of Generation of Code ('Code Injection')](https://cwe.mitre.org/data/definitions/94.html)
134
187
  * https://docs.python.org/3/library/functions.html#eval
135
188
 
136
189
  * https://docs.python.org/3/library/functions.html#exec
137
190
 
138
- * https://docs.python.org/3/library/functions.html#compile
191
+ * https://docs.python.org/3/library/functions.html#compile
192
+
193
+ * [CVE-2025-3248 Detail](https://nvd.nist.gov/vuln/detail/CVE-2025-3248)
194
+
195
+ * [CVE-2025-3248 – Unauthenticated Remote Code Execution in Langflow via Insecure Python exec Usage](https://www.offsec.com/blog/cve-2025-3248/)
@@ -0,0 +1,67 @@
1
+ # Random Statement
2
+
3
+ Python Code Audit checks on use of the `random` module. Checks are done for:
4
+ * `random.seed`
5
+ * `random.Random`
6
+ * `random.randbytes`
7
+ * `random.randint`
8
+ * `random.random`
9
+ * `random.randrange`
10
+ * `random.seed`
11
+ * `random.triangular` and
12
+ * `random.uniform`
13
+
14
+ Too often these functions are not used in the right way!
15
+
16
+ The pseudo-random generators of the module `random` should **not** be used for security purposes.
17
+ However this is still too often neglected.
18
+
19
+ Normal `random` use is only acceptable if the Python code is not used for security or cryptographic purposes.
20
+
21
+ ## Rationale
22
+
23
+ The `random` module in Python is not safe for security or cryptographic purposes, such as generating session tokens, encryption keys, or passwords.
24
+
25
+ This is because the `random` module uses a pseudo-random number generator (PRNG) called the Mersenne Twister. This algorithm is deterministic. If an attacker can observe a sufficient amount of its output, they can completely determine its internal state (the seed) and accurately predict all future and even past values.
26
+
27
+ The `random` module is specifically designed for non-security-sensitive applications like simulations, statistical modeling, and simple games, prioritizing speed and good statistical distribution over true unpredictability.
28
+
29
+ For all security-sensitive tasks, you must use the `secrets` module, which relies on a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) provided by the operating system.
30
+
31
+
32
+ ## Preventive measures
33
+
34
+ - For security or cryptographic uses, **never** use the `random` module but use the `secrets` module.
35
+
36
+ - Use `random.SystemRandom` for random numbers, but this function is not available on all systems.
37
+
38
+
39
+ ## Example
40
+
41
+ ```python
42
+ """Problematic code using random module"""
43
+ import random
44
+
45
+ browser_cookie = random.randint(min_value, max_value)
46
+ ```
47
+
48
+ To improve this code:
49
+ Use the `SystemRandom` class. This class uses the system function `os.urandom()` to generate random numbers from sources provided by the operating system.
50
+
51
+ ```python
52
+ from random import SystemRandom
53
+ safe_random = SystemRandom()
54
+
55
+ browser_cookie = safe_random.randint(min_value, max_value)
56
+ ```
57
+
58
+
59
+ ## More information
60
+
61
+ * https://docs.python.org/3/library/random.html
62
+ * https://docs.python.org/3/library/secrets.html#module-secrets
63
+ * [ CWE-330: Use of Insufficiently Random Values](https://cwe.mitre.org/data/definitions/330.html)
64
+ * [CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)](https://cwe.mitre.org/data/definitions/338.html)
65
+ * [CVE-2022-23472](https://nvd.nist.gov/vuln/detail/CVE-2022-23472)
66
+ * [PEP 506 – Adding A Secrets Module To The Standard Library](https://peps.python.org/pep-0506/)
67
+ * https://www.codiga.io/blog/python-avoid-random/
@@ -14,6 +14,8 @@ And the methods:
14
14
  * `lzma.open`
15
15
  * `lzma.LZMAFile`
16
16
  * `shutil.unpack_archive`
17
+ * `compression.zstd.decompress`
18
+ * `compression.zstd.open`
17
19
 
18
20
  ## Potential danger when opening compressed files
19
21
 
@@ -27,7 +29,7 @@ It is possible that files are created outside of the path specified in the extra
27
29
  :::
28
30
 
29
31
 
30
- This accounts also for using `bz2`, `lzma` , `shutil.unpack_archive` or `tar` compressed files. All these great Python functions that can decompress files require defense in depth to be sure that only trusted files can be opened.
32
+ This accounts also for using `bz2`, `lzma` , `shutil.unpack_archive`, `tar` or `zstd` compressed files. All these great Python functions that can decompress files require defense in depth to be sure that only trusted files can be opened.
31
33
 
32
34
  This can lead to:
33
35
  * **Denial of Service via Resource Exhaustion**
@@ -53,4 +55,7 @@ A path traversal vulnerability could arise if the file in the `gzip` file is con
53
55
  * https://docs.python.org/3/library/zipfile.html#zipfile-resources-limitations
54
56
  * https://docs.python.org/3/library/gzip.html
55
57
  * https://docs.python.org/3/library/bz2.html#bz2.open
56
- * https://docs.python.org/3/library/shutil.html
58
+ * https://docs.python.org/3/library/shutil.html
59
+ * [PEP 784 on zstd](https://peps.python.org/pep-0784/)
60
+ * [CWE-409: Improper Handling of Highly Compressed Data (Data Amplification)](https://cwe.mitre.org/data/definitions/409.html)
61
+ * [urllib3 Streaming API improperly handles highly compressed data](https://www.cve.org/CVERecord?id=CVE-2025-66471)
@@ -1,6 +1,6 @@
1
1
  % THIS FILE IS GENERATED! - Use CLIcommands.ipynb to make it better!
2
2
  # Commands Overview
3
- Python Code Audit commands for: version: 1.2.0
3
+ Python Code Audit commands for: version: 1.4.0
4
4
  ```
5
5
  ----------------------------------------------------
6
6
  _ __ _
@@ -11,13 +11,13 @@ Python Code Audit commands for: version: 1.2.0
11
11
  Python Code Audit - A modern Python security source code analyzer based on distrust.
12
12
 
13
13
  Commands to evaluate Python source code:
14
- Usage: codeaudit COMMAND [PATH or FILE] [OUTPUTFILE]
14
+ Usage: codeaudit COMMAND <directory|package> [report.html]
15
15
 
16
- Depending on the command, a directory or file name must be specified. The output is a static HTML file to be examined in a browser. Specifying a name for the output file is optional.
16
+ Depending on the command, you must specify a local directory, a Python file, or a package name hosted on PyPI.org.Reporting: The results are generated as a static HTML report for viewing in a web browser.
17
17
 
18
18
  Commands:
19
- overview Reports complexity and statistics for Python files in a project directory.
20
- filescan Scans Python projects/files, reporting potential security weaknesses.
19
+ overview Reports complexity and security statistics of a Python project or package on PyPI.org.
20
+ filescan Scans Python code or packages on PyPI.org for security weaknesses.
21
21
  modulescan Reports module vulnerability information.
22
22
  checks Creates an HTML report of all implemented security checks.
23
23
  version Prints the module version. Or use codeaudit [-v] [--v] [-version] or [--version].
@@ -26,9 +26,9 @@ Use the Codeaudit documentation to check the security of Python programs and mak
26
26
  Check https://simplifysecurity.nocomplexity.com/
27
27
 
28
28
  ```
29
- ## Code Audit overview
29
+ ## codeaudit overview
30
30
  ```text
31
- Reports complexity and statistics for Python files in a project directory.
31
+ Reports complexity and security statistics of a Python project or package on PyPI.org.
32
32
 
33
33
  Parameters:
34
34
  directory (str): Path to the directory to scan.
@@ -44,7 +44,7 @@ or repr(object).
44
44
  encoding defaults to 'utf-8'.
45
45
  errors defaults to 'strict'.
46
46
  ```
47
- ## Code Audit modulescan
47
+ ## codeaudit modulescan
48
48
  ```text
49
49
  Reports module vulnerability information.str(object='') -> str
50
50
  str(bytes_or_buffer[, encoding[, errors]]) -> str
@@ -57,9 +57,9 @@ or repr(object).
57
57
  encoding defaults to 'utf-8'.
58
58
  errors defaults to 'strict'.
59
59
  ```
60
- ## Code Audit filescan
60
+ ## codeaudit filescan
61
61
  ```text
62
- Scans Python projects/files, reporting potential security weaknesses.
62
+ Scans Python code or packages on PyPI.org for security weaknesses.
63
63
 
64
64
  This function performs security validations on the specified file or directory,
65
65
  formats the results into an HTML report, and writes the output to an HTML file.
@@ -84,7 +84,7 @@ or repr(object).
84
84
  encoding defaults to 'utf-8'.
85
85
  errors defaults to 'strict'.
86
86
  ```
87
- ## Code Audit checks
87
+ ## codeaudit checks
88
88
  ```text
89
89
 
90
90
  Creates an HTML report of all implemented security checks.
@@ -115,7 +115,7 @@ or repr(object).
115
115
  encoding defaults to 'utf-8'.
116
116
  errors defaults to 'strict'.
117
117
  ```
118
- ## Code Audit version
118
+ ## codeaudit version
119
119
  ```text
120
120
  Prints the module version. Or use codeaudit [-v] [--v] [-version] or [--version].str(object='') -> str
121
121
  str(bytes_or_buffer[, encoding[, errors]]) -> str
@@ -1,12 +1,23 @@
1
1
 
2
2
  # Command `codeaudit overview`
3
3
 
4
- The command:
5
4
 
5
+
6
+ Use this command to generate a quick security relevant assessment of a Python project or package. It provides an overview of important security metrics for the project.
7
+
8
+ Usage
9
+ ```Bash
10
+ codeaudit overview <package-path|package-name> [report-name.html]
6
11
  ```
7
- codeaudit overview
8
- ```
9
- is created to give a quick insights in possible security concerns.
12
+
13
+ Arguments:
14
+ * `<package-path|package-name>` (Required)
15
+ Specify either a local directory containing Python files or the name of a Python package hosted on PyPI.org.
16
+
17
+ * `[report-name.html]` (Optional)
18
+ The filename for the generated security report. If omitted, the tool will use a default filename. If you provide a custom name, ensure it ends with the `.html` extension.
19
+
20
+
10
21
 
11
22
  For every Python file the following **security** relevant statistics are determined:
12
23
 
@@ -1,27 +1,50 @@
1
1
  # Complexity Check
2
2
 
3
- The Python `codeaudit` tool implements a Simple Cyclomatic complexity check.
3
+ **Python Code Audit** implements a Simple Cyclomatic Complexity check, operating on the principle that secure systems are simple systems.
4
+
5
+
6
+ Complexity directly impacts security. Simple systems are:
7
+
8
+ * Maintainable: Easier to change and manage.
9
+
10
+ * Reliable: Less prone to logic errors.
11
+
12
+ * Testable: Easier to validate and test.
13
+
14
+ **Python Code Audit** tool calculates the complexity per file and provides a module-level overview to help you track this metric.
15
+
16
+
17
+
18
+ :::{tip}
19
+ **Embrace Simplicity**
20
+
21
+ * Keep your architecture simple.
22
+
23
+ * Prefer straightforward designs over complex, highly specific ones.
24
+
25
+ This ensures your code is easy for others to read, manage, and change. Practice and use the [0complexity principles](https://nocomplexity.com/documents/0complexity/abstract.html)
26
+
27
+ :::
28
+
4
29
 
5
30
 
6
31
  [Cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) is a software metric used to indicate the complexity of a program. It was developed by Thomas J. McCabe, Sr. in 1976.
7
32
 
8
- Calculating the Cyclomatic complexity for Python sources is complex to do right. And seldom needed! Most implementations for calculating a very thorough Cyclomatic Complexity end up being opinionated sooner or later.
33
+ Calculating the cyclomatic complexity for Python source code is difficult to do accurately. Most implementations aiming for a thorough complexity score eventually become somewhat subjective or opinionated.
9
34
 
10
35
  :::{note}
11
36
  Codeaudit takes a pragmatic and simple approach to determine and calculate the complexity of a source file.
12
37
 
13
- **BUT:**
14
- The Complexity Score that Codeaudit presents gives a **good and solid** representation for the complexity of a Python source file.
38
+ The Complexity Score that Python Code Audit** presents gives a **good and solid** representation for the complexity of a Python source file.
15
39
  :::
16
40
 
17
41
 
18
- But I known the complexity score is not an exact exhaustive cyclomatic complexity measurement.
19
42
 
20
43
 
21
- The complexity is determined per file, and not per function within a Python source file. I have worked long ago with companies that calculated [function points](https://en.wikipedia.org/wiki/Function_point) for software that needed to be created or adjusted. Truth is: Calculating exact metrics about complexity for software code projects is a lot of work, is seldom done correctly and are seldom used with nowadays devops or scrum development teams.
44
+ The complexity is determined per file, and not per function within a Python source file. I have worked with companies that calculated [function points](https://en.wikipedia.org/wiki/Function_point) for systems that needed to be created or adjusted. Truth is: Calculating exact metrics about complexity for software code projects is a lot of work, is seldom done correctly and are seldom used with nowadays devops or scrum development teams.
22
45
 
23
46
 
24
- :::{tip}
47
+ :::{note}
25
48
  The complexity score of source code gives presented gives a solid indication from a security perspective.
26
49
  :::
27
50
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "Python_Code_Audit",
3
- "version": "1.2.0",
4
- "generated_on": "2025-10-15 15:23",
3
+ "version": "1.4.0",
4
+ "generated_on": "2025-12-23 16:15",
5
5
  "file_security_info": {
6
6
  "0": {
7
7
  "FileName": "demofile.py",
@@ -17,6 +17,11 @@ codeaudit filescan <INPUTFILE> [OUTPUTFILE]
17
17
  The `<INPUTFILE>` is mandatory. **Python Code Audit** will create a detailed security scan report.
18
18
 
19
19
 
20
+ **`<INPUTFILE>`** can be:
21
+ * A single Python file;
22
+ * A package on PyPI.org: Python Code Audit checks this package on security weakness, so cloning the sources local is not needed!
23
+ * A local directory with Python files, e.g. a local package development environment or a cloned package.
24
+
20
25
  If you do not specify [OUTPUTFILE], a HTML output file, a HTML report file is created in the current directory and will be named codeaudit-report.html.
21
26
 
22
27
  When running `codeaudit filescan` detailed information is determined for a Python file or package based on more than 70 validations implemented.
@@ -1,6 +1,6 @@
1
1
  # Help
2
2
 
3
- This Open Source tool is created to [simplifying cyber security](https://nocomplexity.com/documents/simplifysecurity/intro.html).
3
+ This **Python Code Audit** Open Source(F/OSS) tool is created to [simplifying cyber security](https://nocomplexity.com/documents/simplifysecurity/intro.html).
4
4
 
5
5
  :::{hint}
6
6
  Everyone can help with improving this tool!
@@ -24,9 +24,16 @@ Even if you already have it installed, it’s recommended to run the command aga
24
24
 
25
25
 
26
26
 
27
- ## 2. Clone the Repository you want to scan
27
+ ## 2. Clone the Repository you want to scan or use the PyPI package name
28
28
 
29
- To clone a repository:
29
+ ### To scan a directory based on the PyPI package name:
30
+
31
+ codeaudit filescanscan <package-name-of-package-on-PyPI> [OUTPUTFILE]
32
+
33
+
34
+ ### Or clone a repository:
35
+
36
+ For direct improvement and inspection of all code using your Python code editor, after examining the Code Audit weakness report:
30
37
 
31
38
  1. Go to the repository page (e.g., on GitHub).
32
39
  2. Click the green **Code** button.
@@ -73,7 +73,7 @@ The availability of good, maintained FOSS SAST tools for Python is limited. Whil
73
73
  :::{note}
74
74
  This `Python Code Audit` tool is built to be fast, lightweight, and easy to use.
75
75
 
76
- By default, the tool scans Python code against more than **70 rules** to detect potential security vulnerabilities. These rules target unsafe constructs of the standard Python libraries that could pose a security risk.
76
+ By default, the tool scans Python code against more than **80 rules** to detect potential security vulnerabilities. These rules target unsafe constructs of the standard Python libraries that could pose a security risk.
77
77
 
78
78
  :::
79
79
 
@@ -4,7 +4,9 @@ The rapid growth and increasing complexity of Python-based web applications and
4
4
 
5
5
  To strengthen cyber security, we must make protection both **better and simpler** — simpler to use, simpler to maintain, and simpler to understand.
6
6
 
7
- Too often, complex security tools end up **reducing security** rather than improving it. The goal should be to **do the simple things well** — ensuring strong fundamentals rather than adding unnecessary complexity.
7
+ Too often, complex security tools end up **reducing security** rather than improving it. The goal should be to **do the simple things well** — ensuring strong fundamentals rather than adding unnecessary complexity.
8
+
9
+ We believe that openly sharing ideas, specifications, and other intellectual property is key to maximizing security innovation and reducing vulnerabilities in Python software components.
8
10
 
9
11
  Security validation for Python code should be **fast, straightforward, and effective**.
10
12