codeaudit 0.5.3__tar.gz → 0.5.5__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 (136) hide show
  1. {codeaudit-0.5.3 → codeaudit-0.5.5}/.gitignore +1 -0
  2. codeaudit-0.5.5/CONTRIBUTE.md +64 -0
  3. {codeaudit-0.5.3 → codeaudit-0.5.5}/PKG-INFO +19 -11
  4. {codeaudit-0.5.3 → codeaudit-0.5.5}/README.md +12 -10
  5. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/CLIcommands.ipynb +4 -2
  6. codeaudit-0.5.5/docs/CONTRIBUTE.md +64 -0
  7. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/_config.yml +1 -1
  8. codeaudit-0.5.5/docs/_toc.yml +67 -0
  9. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/astlines.md +6 -5
  10. codeaudit-0.5.5/docs/checks/assert_check.md +40 -0
  11. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/base64_check.md +5 -1
  12. codeaudit-0.5.5/docs/checks/binding_check.md +54 -0
  13. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/builtinfunctions_check.md +12 -5
  14. codeaudit-0.5.5/docs/checks/chmod_check.md +18 -0
  15. codeaudit-0.5.5/docs/checks/directorycreation_check.md +61 -0
  16. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/exception_check.md +16 -4
  17. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/hash_check.md +3 -1
  18. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/httpserver_check.md +1 -1
  19. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/input_check.md +23 -11
  20. codeaudit-0.5.5/docs/checks/loggingconf_check.md +24 -0
  21. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/marshal_check.md +10 -3
  22. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/multiprocessing_check.md +11 -5
  23. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/pickle_check.md +14 -13
  24. codeaudit-0.5.5/docs/checks/random_check.md +15 -0
  25. codeaudit-0.5.5/docs/checks/shelve_check.md +25 -0
  26. codeaudit-0.5.5/docs/checks/shutil_check.md +23 -0
  27. codeaudit-0.5.5/docs/checks/subprocess_check.md +22 -0
  28. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/systemcalls_check.md +10 -5
  29. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/tarfile_extract_check.md +10 -2
  30. codeaudit-0.5.5/docs/checksinformation.md +73 -0
  31. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/codeauditcommands.md +9 -7
  32. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/codeauditoverview.md +1 -1
  33. codeaudit-0.5.5/docs/complexitycheck.md +28 -0
  34. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/directoryscan.md +1 -1
  35. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/filescan.md +1 -1
  36. codeaudit-0.5.5/docs/help.md +66 -0
  37. codeaudit-0.5.5/docs/images/codeauditlogo.png +0 -0
  38. codeaudit-0.5.5/docs/intro.md +43 -0
  39. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/license.md +2 -1
  40. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/sponsors.md +12 -4
  41. codeaudit-0.5.5/docs/warnings.md +43 -0
  42. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/whysast.md +10 -3
  43. {codeaudit-0.5.3 → codeaudit-0.5.5}/pyproject.toml +6 -1
  44. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/__about__.py +1 -1
  45. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/altairplots.py +30 -18
  46. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/checkmodules.py +20 -23
  47. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/complexitycheck.py +10 -9
  48. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/data/sastchecks.csv +5 -5
  49. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/filehelpfunctions.py +1 -1
  50. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/htmlhelpfunctions.py +9 -8
  51. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/reporting.py +4 -2
  52. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/totals.py +66 -42
  53. codeaudit-0.5.3/docs/_toc.yml +0 -64
  54. codeaudit-0.5.3/docs/checks/assert_check.md +0 -40
  55. codeaudit-0.5.3/docs/checks/binding_check.md +0 -76
  56. codeaudit-0.5.3/docs/checks/chmod_check.md +0 -6
  57. codeaudit-0.5.3/docs/checks/directorycreation_check.md +0 -58
  58. codeaudit-0.5.3/docs/checks/loggingconf_check.md +0 -17
  59. codeaudit-0.5.3/docs/checks/random_check.md +0 -11
  60. codeaudit-0.5.3/docs/checks/shelve_check.md +0 -54
  61. codeaudit-0.5.3/docs/checks/shutil_check.md +0 -20
  62. codeaudit-0.5.3/docs/checks/subprocess_check.md +0 -20
  63. codeaudit-0.5.3/docs/commands.md +0 -20
  64. codeaudit-0.5.3/docs/complexitycheck.md +0 -14
  65. codeaudit-0.5.3/docs/contribute.md +0 -23
  66. codeaudit-0.5.3/docs/help.md +0 -54
  67. codeaudit-0.5.3/docs/intro.md +0 -24
  68. codeaudit-0.5.3/docs/overviewcommand.md +0 -36
  69. {codeaudit-0.5.3 → codeaudit-0.5.5}/LICENSE.txt +0 -0
  70. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/_static/nocxstyle.css +0 -0
  71. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/about.md +0 -0
  72. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/astlines2.md +0 -0
  73. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/xml_check.md +0 -0
  74. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/checks/zipfile_check.md +0 -0
  75. /codeaudit-0.5.3/docs/checkscommand.md → /codeaudit-0.5.5/docs/codeauditchecks.md +0 -0
  76. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/examples/checks_example.html +0 -0
  77. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/examples/directoryscan.html +0 -0
  78. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/examples/filescan.html +0 -0
  79. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/examples/modulescan.html +0 -0
  80. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/examples/overview.html +0 -0
  81. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/features.md +0 -0
  82. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/filescan.png +0 -0
  83. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/images/OO.png +0 -0
  84. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/images/ROI_logo.png +0 -0
  85. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/images/YourLogoHere.png +0 -0
  86. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/images/nocxbanner.png +0 -0
  87. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/images/overview_linkaudit.png +0 -0
  88. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/modulescan.md +0 -0
  89. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/overviewplot.png +0 -0
  90. {codeaudit-0.5.3 → codeaudit-0.5.5}/docs/userguide.md +0 -0
  91. {codeaudit-0.5.3 → codeaudit-0.5.5}/filescan.png +0 -0
  92. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/__init__.py +0 -0
  93. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/codeaudit.py +0 -0
  94. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/issuevalidations.py +0 -0
  95. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/security_checks.py +0 -0
  96. {codeaudit-0.5.3 → codeaudit-0.5.5}/src/codeaudit/simple.css +0 -0
  97. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/__init__.py +0 -0
  98. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/count_lines_file1.py +0 -0
  99. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_basicpatterns.py +0 -0
  100. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_chmod.py +0 -0
  101. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_constructspart2.py +0 -0
  102. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_correctexceptionuse.py +0 -0
  103. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_count_commentlines.py +0 -0
  104. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_directorycreation.py +0 -0
  105. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_directorycreation2.py +0 -0
  106. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_hashstrenght.py +0 -0
  107. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_oschecks.py +0 -0
  108. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_random.py +0 -0
  109. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/test_standardlibconstructs.py +0 -0
  110. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/allshit.py +0 -0
  111. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/assert.py +0 -0
  112. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/base64.py +0 -0
  113. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/chmod_things.py +0 -0
  114. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/directorycreation.py +0 -0
  115. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/directorycreation2.py +0 -0
  116. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/exception.py +0 -0
  117. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/file3.py +0 -0
  118. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/file_with_warnings.py +0 -0
  119. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/hashcheck.py +0 -0
  120. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/httpserver.py +0 -0
  121. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/inputstatement.py +0 -0
  122. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/marshal.py +0 -0
  123. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/modulecheck.py +0 -0
  124. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/multiprocessing.py +0 -0
  125. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/oschecks.py +0 -0
  126. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/pickle.py +0 -0
  127. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/python2_file_willnotwork.py +0 -0
  128. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/random.py +0 -0
  129. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/shelve.py +0 -0
  130. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/shutil.py +0 -0
  131. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/subprocess.py +0 -0
  132. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/tarfilevalidation.py +0 -0
  133. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/validation1.py +0 -0
  134. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/validation2.py +0 -0
  135. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/xml.py +0 -0
  136. {codeaudit-0.5.3 → codeaudit-0.5.5}/tests/validationfiles/zipfile.py +0 -0
@@ -146,3 +146,4 @@ dmypy.json
146
146
  _build/*
147
147
  .gitignore
148
148
 
149
+
@@ -0,0 +1,64 @@
1
+ # Contribute
2
+
3
+ Great that you see this page and want to contribute!
4
+
5
+ :::{tip}
6
+ All contributions are welcome!
7
+ Think of corrections on the manual, code and more or better tests.
8
+ :::
9
+
10
+ The **Codeaudit** code repository is hosted at [Github](github.com/nocomplexity/codeaudit).
11
+
12
+ Simple Guidelines:
13
+
14
+ * Questions, Feature Requests, Bug Reports should all be reported on the [Github Issue Tracker](https://github.com/nocomplexity/codeaudit/issues) .
15
+ * [Black](https://black.readthedocs.io/en/stable/index.html) is used for code style. But for a simple fix, using `Black` is not required!
16
+
17
+ This codeaudit tool is designed by applying [Zero Complexity By Design principles](https://nocomplexity.com/documents/0complexity/abstract.html). So the goal is to keep the tool simple to use and the code simple to adjust or to extend.
18
+
19
+ :::{warning}
20
+ This simple tool is designed to be simple to use and maintain.
21
+ :::
22
+
23
+ **Pull Requests are welcome!**
24
+
25
+ When you contribute to Codeaudit, your contributions are made under the same license as the file you are working on.
26
+
27
+
28
+ We adopt the [Collective Code Construction Contract(C4)](https://rfc.zeromq.org/spec/42/) to streamline collaboration. C4 is meant to provide a reusable optimal collaboration model for open source software projects.
29
+
30
+ :::{attention}
31
+ This project values respect and inclusiveness, and enforces a [Code of Conduct](CoC-label) in all interactions.
32
+ :::
33
+
34
+
35
+ :::{note}
36
+ This is an open community driven project. Contributors will be mentioned in the documentation.
37
+ :::
38
+
39
+ (CoC-label)=
40
+ ## Code of Conduct
41
+
42
+ Version : 1.0
43
+
44
+ As contributors, maintainers, administrators and founders of the Python Codeaudit Community projects, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
45
+
46
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
47
+
48
+ Examples of unacceptable behavior by participants include:
49
+ * The use of sexualized language or imagery.
50
+ * Personal attacks.
51
+ * Trolling or insulting/derogatory comments.
52
+ * Public or private harassment.
53
+ * Publishing other’s private information, such as physical or electronic addresses, without explicit permission.
54
+ * Other unethical or unprofessional conduct.
55
+
56
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, documentation edits, issues, and other contributions that are not aligned to this Code of Conduct.
57
+
58
+ By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
59
+
60
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
61
+
62
+ This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
63
+
64
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](https://www.contributor-covenant.org/version/1/2/0/code-of-conduct/).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeaudit
3
- Version: 0.5.3
3
+ Version: 0.5.5
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
@@ -8,24 +8,32 @@ Project-URL: Source, https://github.com/nocomplexity/codeaudit
8
8
  Author-email: Maikel Mardjan <mike@bm-support.org>
9
9
  License-Expression: GPL-3.0-or-later
10
10
  License-File: LICENSE.txt
11
+ Keywords: Complexity Checker,Python SAST,SAST,SAST API
11
12
  Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
12
16
  Classifier: Programming Language :: Python
13
17
  Classifier: Programming Language :: Python :: 3.12
14
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Security
20
+ Classifier: Topic :: Software Development :: Quality Assurance
15
21
  Requires-Python: >=3.8
16
22
  Requires-Dist: altair>=5.5
17
23
  Requires-Dist: fire>=0.7.0
18
24
  Requires-Dist: pandas>=2.3
19
25
  Description-Content-Type: text/markdown
20
26
 
21
- # codeaudit
27
+ # Codeaudit
28
+
29
+ ![CodeauditLogo](docs/images/codeauditlogo.png)
22
30
 
23
31
  [![PyPI - Version](https://img.shields.io/pypi/v/codeaudit.svg)](https://pypi.org/project/codeaudit)
24
32
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/codeaudit.svg)](https://pypi.org/project/codeaudit)
25
33
 
26
- Codeaudit - A modern Python source code analyzer based on distrust.
34
+ Python Codeaudit - A modern Python source code analyzer based on distrust.
27
35
 
28
- Codeaudit is a tool designed to find security issues in Python code. This static application security testing (SAST) tool has great features to simplify the necessary security tasks and make it fun and easy.
36
+ Codeaudit is a tool to find security issues in Python code. This static application security testing (SAST) tool has **great** features to simplify the necessary security tasks and make it fun and easy.
29
37
 
30
38
  This tool is created for:
31
39
  * Anyone who want or must check security risks with Python programs.
@@ -34,20 +42,20 @@ This tool is created for:
34
42
 
35
43
 
36
44
  > [!WARNING]
37
- > Codeaudit is still is currently in *beta status*. There are still bugs in the software that need to be fixed. Consider [contributing](CONTRIBUTING.md) to make Codeaudit a cool modern Python SAST tool. Codeaudit is currently in a thorough testing period and changes and fixes are frequently applied.
45
+ > Python Codeaudit is currently in *beta status*. Consider [contributing](CONTRIBUTING.md) to make Codeaudit the coolest open source Python SAST tool. Codeaudit is currently in a thorough testing phase. So use the Codeaudit now to and contribute to make it better!
38
46
 
39
47
  ## Features
40
48
 
41
- Codeaudit has the following features:
49
+ Python Codeaudit has the following features:
42
50
 
43
51
  * Detecting and reporting potential vulnerabilities of from all Python files collected in a directory. This is a must **do** check when researching python packages on possible security issues.
44
52
 
45
53
  * Detect and reports complexity and statistics relevant for security per Python file or from Python files found in a directory.
46
54
 
47
- * Codeaudit implements a light weight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) using Python’s Abstract Syntax Tree module. The codeaudit implemented check is by far good enough for determining security risks in Python files very quick!
55
+ * Python Codeaudit implements a light weight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) count, using Python’s Abstract Syntax Tree module. The codeaudit complexity check is designed to determine security risks in Python files very quick!
48
56
 
49
57
 
50
- * Detect and reports which module are used within a Python file. Also vulnerability information found from used external modules is shown.
58
+ * Detect and reports which module are used within a Python file. Also vulnerability information found from used external modules is reported.
51
59
 
52
60
  * Detecting and reporting potential vulnerability issues within a Python file. Per detected issue the line number shown, with the lines that *could* cause a security issue.
53
61
 
@@ -55,7 +63,7 @@ Codeaudit has the following features:
55
63
 
56
64
 
57
65
  > [!IMPORTANT]
58
- > Codeaudit uses the Python's Abstract Syntax Tree (AST) to get robust and reliable result. Using the Python AST makes contextual Vulnerability Detection possible and false positive are minimized.
66
+ > Python Codeaudit uses the Python's Abstract Syntax Tree (AST) to get robust and reliable result. Using the Python AST makes contextual Vulnerability Detection possible and false positive are minimized.
59
67
 
60
68
 
61
69
  ## Installation
@@ -107,7 +115,7 @@ Commands:
107
115
  checks Generate an HTML report of all implemented codeaudit security checks.
108
116
  version Prints the module version. Use [-v] [--v] [-version] or [--version].
109
117
 
110
- Use the Codeaudit documentation to check the security of Python programs and make your Python programs more secure!
118
+ Use the [Codeaudit documentation](https://nocomplexity.com/documents/codeaudit/intro.html) to check the security of Python programs and make your Python programs more secure!
111
119
  Check https://simplifysecurity.nocomplexity.com/
112
120
  ```
113
121
 
@@ -144,7 +152,7 @@ When you contribute to Codeaudit, your contributions are made under the same lic
144
152
 
145
153
 
146
154
  > [!NOTE]
147
- > This is an open community driven project. Contributors will be mentioned in the documentation.
155
+ > This is an open community driven project. Contributors will be mentioned in the [documentation](https://nocomplexity.com/documents/codeaudit/intro.html).
148
156
 
149
157
  We adopt the [Collective Code Construction Contract(C4)](https://rfc.zeromq.org/spec/42/) to streamline collaboration.
150
158
 
@@ -1,11 +1,13 @@
1
- # codeaudit
1
+ # Codeaudit
2
+
3
+ ![CodeauditLogo](docs/images/codeauditlogo.png)
2
4
 
3
5
  [![PyPI - Version](https://img.shields.io/pypi/v/codeaudit.svg)](https://pypi.org/project/codeaudit)
4
6
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/codeaudit.svg)](https://pypi.org/project/codeaudit)
5
7
 
6
- Codeaudit - A modern Python source code analyzer based on distrust.
8
+ Python Codeaudit - A modern Python source code analyzer based on distrust.
7
9
 
8
- Codeaudit is a tool designed to find security issues in Python code. This static application security testing (SAST) tool has great features to simplify the necessary security tasks and make it fun and easy.
10
+ Codeaudit is a tool to find security issues in Python code. This static application security testing (SAST) tool has **great** features to simplify the necessary security tasks and make it fun and easy.
9
11
 
10
12
  This tool is created for:
11
13
  * Anyone who want or must check security risks with Python programs.
@@ -14,20 +16,20 @@ This tool is created for:
14
16
 
15
17
 
16
18
  > [!WARNING]
17
- > Codeaudit is still is currently in *beta status*. There are still bugs in the software that need to be fixed. Consider [contributing](CONTRIBUTING.md) to make Codeaudit a cool modern Python SAST tool. Codeaudit is currently in a thorough testing period and changes and fixes are frequently applied.
19
+ > Python Codeaudit is currently in *beta status*. Consider [contributing](CONTRIBUTING.md) to make Codeaudit the coolest open source Python SAST tool. Codeaudit is currently in a thorough testing phase. So use the Codeaudit now to and contribute to make it better!
18
20
 
19
21
  ## Features
20
22
 
21
- Codeaudit has the following features:
23
+ Python Codeaudit has the following features:
22
24
 
23
25
  * Detecting and reporting potential vulnerabilities of from all Python files collected in a directory. This is a must **do** check when researching python packages on possible security issues.
24
26
 
25
27
  * Detect and reports complexity and statistics relevant for security per Python file or from Python files found in a directory.
26
28
 
27
- * Codeaudit implements a light weight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) using Python’s Abstract Syntax Tree module. The codeaudit implemented check is by far good enough for determining security risks in Python files very quick!
29
+ * Python Codeaudit implements a light weight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) count, using Python’s Abstract Syntax Tree module. The codeaudit complexity check is designed to determine security risks in Python files very quick!
28
30
 
29
31
 
30
- * Detect and reports which module are used within a Python file. Also vulnerability information found from used external modules is shown.
32
+ * Detect and reports which module are used within a Python file. Also vulnerability information found from used external modules is reported.
31
33
 
32
34
  * Detecting and reporting potential vulnerability issues within a Python file. Per detected issue the line number shown, with the lines that *could* cause a security issue.
33
35
 
@@ -35,7 +37,7 @@ Codeaudit has the following features:
35
37
 
36
38
 
37
39
  > [!IMPORTANT]
38
- > Codeaudit uses the Python's Abstract Syntax Tree (AST) to get robust and reliable result. Using the Python AST makes contextual Vulnerability Detection possible and false positive are minimized.
40
+ > Python Codeaudit uses the Python's Abstract Syntax Tree (AST) to get robust and reliable result. Using the Python AST makes contextual Vulnerability Detection possible and false positive are minimized.
39
41
 
40
42
 
41
43
  ## Installation
@@ -87,7 +89,7 @@ Commands:
87
89
  checks Generate an HTML report of all implemented codeaudit security checks.
88
90
  version Prints the module version. Use [-v] [--v] [-version] or [--version].
89
91
 
90
- Use the Codeaudit documentation to check the security of Python programs and make your Python programs more secure!
92
+ Use the [Codeaudit documentation](https://nocomplexity.com/documents/codeaudit/intro.html) to check the security of Python programs and make your Python programs more secure!
91
93
  Check https://simplifysecurity.nocomplexity.com/
92
94
  ```
93
95
 
@@ -124,7 +126,7 @@ When you contribute to Codeaudit, your contributions are made under the same lic
124
126
 
125
127
 
126
128
  > [!NOTE]
127
- > This is an open community driven project. Contributors will be mentioned in the documentation.
129
+ > This is an open community driven project. Contributors will be mentioned in the [documentation](https://nocomplexity.com/documents/codeaudit/intro.html).
128
130
 
129
131
  We adopt the [Collective Code Construction Contract(C4)](https://rfc.zeromq.org/spec/42/) to streamline collaboration.
130
132
 
@@ -59,6 +59,8 @@
59
59
  "metadata": {},
60
60
  "outputs": [],
61
61
  "source": [
62
+ "output += '% THIS FILE IS GENERATED! - Use CLIcommands.ipynb to make it better!\\n'\n",
63
+ "output += '# Overview of Codeaudit commands\\n'\n",
62
64
  "output += f'Codeaudit commands for: {version_id}'"
63
65
  ]
64
66
  },
@@ -100,7 +102,7 @@
100
102
  " \"checks\" : 'report_implemented_tests',\n",
101
103
  " \"version\" : 'display_version'} \n",
102
104
  "for key, value in commands.items(): \n",
103
- " output += f'### codeaudit {key}\\n' # newlines matter when creating markdown\n",
105
+ " output += f'## codeaudit {key}\\n' # newlines matter when creating markdown\n",
104
106
  " output += '```text\\n' # raw display \n",
105
107
  " func_name = value\n",
106
108
  " output += getattr(codeaudit, func_name).__doc__\n",
@@ -158,7 +160,7 @@
158
160
  "name": "python",
159
161
  "nbconvert_exporter": "python",
160
162
  "pygments_lexer": "ipython3",
161
- "version": "3.13.5"
163
+ "version": "3.13.1"
162
164
  }
163
165
  },
164
166
  "nbformat": 4,
@@ -0,0 +1,64 @@
1
+ # Contribute
2
+
3
+ Great that you see this page and want to contribute!
4
+
5
+ :::{tip}
6
+ All contributions are welcome!
7
+ Think of corrections on the manual, code and more or better tests.
8
+ :::
9
+
10
+ The **Codeaudit** code repository is hosted at [Github](github.com/nocomplexity/codeaudit).
11
+
12
+ Simple Guidelines:
13
+
14
+ * Questions, Feature Requests, Bug Reports should all be reported on the [Github Issue Tracker](https://github.com/nocomplexity/codeaudit/issues) .
15
+ * [Black](https://black.readthedocs.io/en/stable/index.html) is used for code style. But for a simple fix, using `Black` is not required!
16
+
17
+ This codeaudit tool is designed by applying [Zero Complexity By Design principles](https://nocomplexity.com/documents/0complexity/abstract.html). So the goal is to keep the tool simple to use and the code simple to adjust or to extend.
18
+
19
+ :::{warning}
20
+ This simple tool is designed to be simple to use and maintain.
21
+ :::
22
+
23
+ **Pull Requests are welcome!**
24
+
25
+ When you contribute to Codeaudit, your contributions are made under the same license as the file you are working on.
26
+
27
+
28
+ We adopt the [Collective Code Construction Contract(C4)](https://rfc.zeromq.org/spec/42/) to streamline collaboration. C4 is meant to provide a reusable optimal collaboration model for open source software projects.
29
+
30
+ :::{attention}
31
+ This project values respect and inclusiveness, and enforces a [Code of Conduct](CoC-label) in all interactions.
32
+ :::
33
+
34
+
35
+ :::{note}
36
+ This is an open community driven project. Contributors will be mentioned in the documentation.
37
+ :::
38
+
39
+ (CoC-label)=
40
+ ## Code of Conduct
41
+
42
+ Version : 1.0
43
+
44
+ As contributors, maintainers, administrators and founders of the Python Codeaudit Community projects, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
45
+
46
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
47
+
48
+ Examples of unacceptable behavior by participants include:
49
+ * The use of sexualized language or imagery.
50
+ * Personal attacks.
51
+ * Trolling or insulting/derogatory comments.
52
+ * Public or private harassment.
53
+ * Publishing other’s private information, such as physical or electronic addresses, without explicit permission.
54
+ * Other unethical or unprofessional conduct.
55
+
56
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, documentation edits, issues, and other contributions that are not aligned to this Code of Conduct.
57
+
58
+ By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
59
+
60
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
61
+
62
+ This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
63
+
64
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](https://www.contributor-covenant.org/version/1/2/0/code-of-conduct/).
@@ -100,6 +100,6 @@ sphinx:
100
100
  use_issues_button: True
101
101
  home_page_in_toc: True
102
102
  logo:
103
- text: <b>Code Audit</b>
103
+ text: <b>Python Security Code Audit</b>
104
104
  extra_footer: '<p><a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.</p>'
105
105
 
@@ -0,0 +1,67 @@
1
+ format: jb-book
2
+ root: intro
3
+
4
+ parts:
5
+ - caption: Quick Start
6
+ chapters:
7
+ - file: features
8
+ - file: userguide
9
+ sections:
10
+ - file: codeauditoverview
11
+ - file: modulescan
12
+ - file: filescan
13
+ - file: directoryscan
14
+ - file: codeauditchecks
15
+ - file: whysast
16
+
17
+
18
+ - caption: Security Checks
19
+ chapters:
20
+ - file: checksinformation
21
+ sections:
22
+ - file: checks/assert_check
23
+ - file: checks/input_check
24
+ - file: checks/builtinfunctions_check
25
+ - file: checks/chmod_check
26
+ - file: checks/binding_check
27
+ - file: checks/directorycreation_check
28
+ - file: checks/exception_check
29
+ - file: checks/tarfile_extract_check
30
+ - file: checks/hash_check
31
+ - file: checks/marshal_check
32
+ - file: checks/subprocess_check
33
+ - file: checks/systemcalls_check
34
+ - file: checks/loggingconf_check
35
+ - file: checks/base64_check
36
+ - file: checks/httpserver_check
37
+ - file: checks/multiprocessing_check
38
+ - file: checks/pickle_check
39
+ - file: checks/random_check
40
+ - file: checks/shelve_check
41
+ - file: checks/xml_check
42
+ - file: checks/zipfile_check
43
+ - file: checks/shutil_check
44
+
45
+
46
+ - caption: Architecture
47
+ chapters:
48
+ # - file: astlines
49
+ # - file: astlines2
50
+ - file: complexitycheck
51
+ - file: warnings
52
+ - file: codeauditcommands
53
+
54
+
55
+
56
+ # - caption: API Documentation
57
+ # chapters:
58
+ # - file: modules
59
+
60
+
61
+ - caption: About
62
+ chapters:
63
+ - file: help
64
+ - file: CONTRIBUTE
65
+ - file: sponsors
66
+ - file: license
67
+ - file: about
@@ -8,7 +8,7 @@ AST lines are needed to give a more precise indication of the complexity of a Py
8
8
 
9
9
  To explain the difference between an **AST line** (as counted by the provided `count_ast_lines` function) and a **line counted by the Unix `wc` command**, let’s break it down:
10
10
 
11
- ### 1. **Lines Counted by Unix `wc -l`**
11
+ 1. **Lines Counted by Unix `wc -l`**
12
12
  - The Unix command `wc -l filename` counts the **physical lines** in a file.
13
13
  - A "line" is defined as any sequence of characters terminated by a newline character (`\n`).
14
14
  - This includes:
@@ -26,7 +26,7 @@ To explain the difference between an **AST line** (as counted by the provided `c
26
26
  ```
27
27
  Running `wc -l` on this file yields **5 lines** because there are five newline characters (one for each line, including the blank line).
28
28
 
29
- ### 2. **AST Lines (as counted by `count_ast_lines`)**
29
+ 2. **AST Lines (as counted by `count_ast_lines`)**
30
30
  - The `count_ast_lines` function uses Python’s `ast` module to parse the source code into an **Abstract Syntax Tree (AST)** and counts **unique lines that contain AST nodes with a `lineno` attribute**.
31
31
  - An AST represents the syntactic structure of the code, ignoring comments, blank lines, and certain non-executable elements.
32
32
  - The function:
@@ -57,7 +57,7 @@ To explain the difference between an **AST line** (as counted by the provided `c
57
57
  - `x = 1` (line 5, Assign node).
58
58
  - The `set` of line numbers is `{2, 3, 5}`, so `count_ast_lines` returns **3**.
59
59
 
60
- ### 3. **Key Differences**
60
+ 3. **Key Differences**
61
61
  | Aspect | `wc -l` | `count_ast_lines` (AST Lines) |
62
62
  |----------------------------|--------------------------------------|---------------------------------------|
63
63
  | **Definition** | Counts physical lines (newline-terminated). | Counts unique lines with AST nodes. |
@@ -67,7 +67,8 @@ To explain the difference between an **AST line** (as counted by the provided `c
67
67
  | **Purpose** | General file line count | Measures executable code lines |
68
68
  | **Example Output** | 5 (for above example) | 3 (for above example) |
69
69
 
70
- ### 4. **Additional Example for Clarity**
70
+ 4. **Additional Example for Clarity**
71
+
71
72
  Consider this code:
72
73
  ```python
73
74
  # This is a comment
@@ -96,7 +97,7 @@ def example():
96
97
  - Unique line numbers: `{2, 3, 7, 11}`.
97
98
  - Output: `4`.
98
99
 
99
- ### 5. **Why the Difference Matters**
100
+ 5. **Why the Difference Matters**
100
101
  - `wc -l` is useful for getting a raw count of lines in a file, often used for file statistics or quick checks.
101
102
  - `count_ast_lines` is more relevant for analyzing **executable code complexity** or **code coverage**, as it focuses on lines that represent actual Python syntax nodes, ignoring non-executable content like comments or blank lines.
102
103
 
@@ -0,0 +1,40 @@
1
+ # Assert Statement
2
+
3
+ The Python `assert` statement itself is not insecure, but its *misuse* can lead to security vulnerabilities.
4
+
5
+ :::{danger}
6
+ Using `assert` can be problematic from a security perspective!
7
+ :::
8
+
9
+
10
+ ## Rationale
11
+
12
+ 1. Assertions are primarily for debugging and development, **NOT** for production validation or error handling.
13
+
14
+ * **They can be disabled:** When Python is run in optimized mode (with the `-O` or `-OO` flags, or by setting the `PYTHONOPTIMIZE` environment variable), `assert` statements are completely ignored. This means any crucial checks you rely on for security or data integrity will simply vanish, leaving your application vulnerable.
15
+
16
+ * **Not for user input validation:** So never use `assert` to validate user input or external data. If assertions are disabled in production, malicious or malformed input will bypass your checks, potentially leading to crashes, data corruption, or even arbitrary code execution. Use `if/else` statements with proper exception handling (e.g., `ValueError`, `TypeError`) for this.
17
+
18
+ * **Not for graceful error handling:** Assertions are designed to signal "this should never happen, it's a bug." They raise an `AssertionError` which typically halts the program. In a production environment, you usually want to handle anticipated errors gracefully, log them, and potentially recover or inform the user, rather than crashing the application.
19
+
20
+ 2. Some side effects within `assert` statements can be dangerous.
21
+
22
+ * If an `assert` statement contains code with side effects (e.g., modifying a variable, calling a function that performs an action), those side effects will also be skipped when assertions are disabled. This can lead to unexpected behavior and security gaps.
23
+
24
+ 3. Use assert for testing code and during development only
25
+
26
+ * `assert` is good to use for `pytest` or other development constructs.
27
+
28
+ * `Assert` helps to find mistakes during development. But it is not a security fence to protect against external threats or a robust mechanism for handling runtime issues in a live system. For production code, especially when dealing with external inputs or critical business logic, rely on explicit `if/else` checks and robust exception handling.
29
+
30
+ * `Assert` statements should in general only be used for testing and debugging purposes.
31
+ `assert` statements **SHOULD** be removed when not running in debug mode (i.e. when invoking the Python command with the -O or -OO options).
32
+
33
+
34
+
35
+
36
+ ## More information
37
+
38
+ * [The assert statement - Python Documentation](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
39
+ * [The dangers of assert in Python](https://snyk.io/blog/the-dangers-of-assert-in-python/)
40
+ * [Feature: Python assert should be consider harmful](https://community.sonarsource.com/t/feature-python-assert-should-be-consider-harmful/38501) But note that Sonar did not implement this check.
@@ -1,9 +1,13 @@
1
- # Using Base64 Encoding / Decoding
1
+ # Base64 Statements
2
+
3
+ Codeaudit checks on use of:
4
+ * Base64 Encoding / Decoding
2
5
 
3
6
  The `base64` module requires specific security considerations.
4
7
 
5
8
  It’s recommended to review the security considerations for any code deployed to production using `base64` encoding.
6
9
 
10
+ Security considerations section from RFC 4648 (section 12):
7
11
 
8
12
  ```text
9
13
  Security Considerations
@@ -0,0 +1,54 @@
1
+ # Binding Statement
2
+
3
+ Purpose of this validation is to detect code construct where binding to all interfaces is applied.
4
+
5
+ The Python construct `s.bind()` is dangerous from a security perspective.
6
+
7
+ It opens network sockets and makes your application vulnerable. Additional measurements are often required. So not only within the Python code. This is seldom enough.
8
+
9
+ When `s.bind` constuct is detected this requires a further inspection to determine what the risks are. This inspection can only be done in full context, so in context of the environment where the code will be executed.
10
+
11
+ ## Additional explanation
12
+
13
+ Within Python Binding sockets on all interfaces can be done on several ways. E.g.:
14
+ ```python
15
+ import socket
16
+
17
+ addr = ("", 8080) # all interfaces, port 8080
18
+ if socket.has_dualstack_ipv6():
19
+ s = socket.create_server(addr, family=socket.AF_INET6, dualstack_ipv6=True)
20
+ else:
21
+ s = socket.create_server(addr)
22
+ ```
23
+ ([reference - Python documentation](https://docs.python.org/3/library/socket.html#socket.AF_INET6))
24
+
25
+ :::{caution}
26
+ Port bindings **SHOULD** never be hardcoded. But if used dynamically assigned based on ports that are not yet in use.
27
+
28
+ When multiple sockets are allowed to bind to the same port, other services on that port may be stolen or spoofed.
29
+
30
+ So prevent an another application to bind to the specific address on unprivileged port, and steal its UDP packets/TCP connection.
31
+
32
+ Minimal required is a strong authorization mechanism and preferred is a 'zero-trust' network policy.
33
+
34
+ **Make sure measurements are taken** when communication using raw sockets in Python.
35
+
36
+ :::
37
+
38
+ Some measurements (besides changing the code!) are:
39
+
40
+ 1. **Firewall Configuration:** Configure a to explicitly allow incoming connections *only from trusted sources* or specific IP ranges. Block all other incoming connections to that port.
41
+
42
+ 2. **Application Security:**
43
+ * **Authentication and Authorization:** Implement strong authentication and authorization mechanisms for your application. Don't leave it open for anyone to connect.
44
+ * **Input Validation:** Sanitize and validate all user inputs to prevent common vulnerabilities like SQL injection, cross-site scripting (XSS), and command injection.
45
+ * **Least Privilege:** Ensure the application runs with the minimum necessary privileges.
46
+ * **Error Handling:** Implement robust error handling that doesn't expose sensitive system information.
47
+ * **Logging and Monitoring:** Log access attempts and suspicious activities. Monitor these logs for anomalies.
48
+
49
+ 4. **Zero-Trust and Network Segmentation:** For critical services, consider placing them in separate network segments to limit lateral movement if one part of your network is compromised.
50
+
51
+
52
+
53
+ ## More Information
54
+ * https://docs.python.org/3/library/socket.html
@@ -1,23 +1,30 @@
1
1
  # Built-in Functions
2
2
 
3
- Some Python built-in functions can cause risks. Codeaudit checks on:
3
+ Some Python built-in functions can cause severe risks.
4
4
 
5
+ The Python built-in functions:
6
+ * `eval`
7
+ * `exec` and
8
+ * `compile`
9
+ Should always be reviewed within the full context. By default use of this function is a **red** alert from a security perspective.
5
10
 
6
- ## Check on `eval`
11
+
12
+ ## Why check on `eval`
7
13
 
8
14
  This function executes arbitrary code. Calling it with user-supplied input may lead to security vulnerabilities.
9
15
 
10
16
  This function can also be used to execute arbitrary code objects (such as those created by compile()).
11
17
 
12
- ## Check on `exec`
18
+ ## Why Check on `exec`
13
19
 
14
20
  This function executes arbitrary code. Calling it with user-supplied input may lead to security vulnerabilities.
15
21
 
16
- ## Check on `compile`
22
+ ## Why check on `compile`
17
23
 
18
24
  It is possible to crash the Python interpreter with a sufficiently large/complex string when compiling to an AST object due to stack depth limitations in Python’s AST compiler.
19
25
 
20
- More info:
26
+ ## More info
27
+
21
28
  * https://docs.python.org/3/library/functions.html#eval
22
29
 
23
30
  * https://docs.python.org/3/library/functions.html#exec
@@ -0,0 +1,18 @@
1
+ # Chmod Statement
2
+
3
+ Applying and using the Python `os.chmod` function is not the way to deal with permissions.
4
+ Sooner or later you will share your program to be used by others.
5
+
6
+ It is also common that Python programs run with too wide authorizations.
7
+
8
+ Especially with downloaded programs:
9
+
10
+ :::{tip}
11
+ Always check if `chmod` is used in the code!
12
+ :::
13
+
14
+ Automatic use of `chmod` in programs is a receipt for disasters and privacy concerns.
15
+
16
+ ## More information
17
+
18
+ * https://docs.python.org/3/library/os.html#os.chmod