codeaudit 0.8.0__tar.gz → 0.9.0__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.
- {codeaudit-0.8.0 → codeaudit-0.9.0}/PKG-INFO +1 -1
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/codeauditchecks.md +1 -1
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/codeauditcommands.md +3 -3
- codeaudit-0.9.0/docs/codeauditoverview.md +78 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/directoryscan.md +1 -1
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/examples/checks_example.html +30 -6
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/features.md +15 -9
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/filescan.md +1 -1
- codeaudit-0.9.0/docs/intro.md +48 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/modulescan.md +1 -1
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/userguide.md +19 -6
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/__about__.py +1 -1
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/checkmodules.py +36 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/codeaudit.py +2 -2
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/htmlhelpfunctions.py +8 -2
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/reporting.py +24 -8
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/totals.py +2 -2
- codeaudit-0.9.0/tests/test_modulecheck.py +21 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/modulecheck.py +1 -0
- codeaudit-0.8.0/docs/codeauditoverview.md +0 -65
- codeaudit-0.8.0/docs/intro.md +0 -51
- {codeaudit-0.8.0 → codeaudit-0.9.0}/.gitignore +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/CONTRIBUTE.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/LICENSE.txt +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/README.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/SECURITY.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/CLIcommands.ipynb +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/CONTRIBUTE.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/_config.yml +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/_static/nocxstyle.css +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/_toc.yml +2 -2
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/about.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/astlines.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/astlines2.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/assert_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/base64_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/binding_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/builtinfunctions_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/chmod_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/directorycreation_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/exception_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/hash_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/httpserver_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/input_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/loggingconf_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/marshal_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/mktemp_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/multiprocessing_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/pickle_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/random_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/shelve_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/shutil_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/subprocess_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/syscalls_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/systemcalls_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/tarfile_extract_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/xml_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checks/zipfile_check.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/checksinformation.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/complexitycheck.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/examples/directoryscan.html +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/examples/filescan.html +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/examples/modulescan.html +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/examples/overview.html +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/filescan.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/help.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/images/OO.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/images/ROI_logo.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/images/YourLogoHere.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/images/codeauditlogo.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/images/nocxbanner.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/images/overview_linkaudit.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/license.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/overviewplot.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/sponsors.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/warnings.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/docs/whysast.md +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/filescan.png +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/pyproject.toml +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/__init__.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/altairplots.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/complexitycheck.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/data/sastchecks.csv +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/filehelpfunctions.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/issuevalidations.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/security_checks.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/src/codeaudit/simple.css +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/__init__.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/count_lines_file1.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_basicpatterns.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_chmod.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_constructspart2.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_correctexceptionuse.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_count_commentlines.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_directorycreation.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_directorycreation2.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_hashstrenght.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_oschecks.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_random.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/test_standardlibconstructs.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/allshit.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/assert.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/base64.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/chmod_things.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/directorycreation.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/directorycreation2.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/exception.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/file3.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/file_with_warnings.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/hashcheck.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/httpserver.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/inputstatement.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/marshal.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/multiprocessing.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/oschecks.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/pickle.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/python2_file_willnotwork.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/random.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/shelve.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/shutil.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/subprocess.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/syslibrary.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/tarfilevalidation.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/tempcheck.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/validation1.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/validation2.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/xml.py +0 -0
- {codeaudit-0.8.0 → codeaudit-0.9.0}/tests/validationfiles/zipfile.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codeaudit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
% THIS FILE IS GENERATED! - Use CLIcommands.ipynb to make it better!
|
|
2
2
|
# Overview of Codeaudit commands
|
|
3
|
-
Codeaudit commands for: version: 0.
|
|
3
|
+
Codeaudit commands for: version: 0.8.0
|
|
4
4
|
```
|
|
5
5
|
--------------------------------------------------
|
|
6
6
|
_____ _ _ _ _
|
|
@@ -20,9 +20,9 @@ Depending on the command, a directory or file name must be specified. The output
|
|
|
20
20
|
|
|
21
21
|
Commands:
|
|
22
22
|
overview Reports Complexity and statistics per Python file from a directory.
|
|
23
|
-
modulescan Reports module information per file.
|
|
24
|
-
filescan Reports potential security issues for a single Python file.
|
|
25
23
|
directoryscan Reports potential security issues for all Python files found in a directory.
|
|
24
|
+
filescan Reports potential security issues for a single Python file.
|
|
25
|
+
modulescan Reports module information per file.
|
|
26
26
|
checks Generate an HTML report of all implemented codeaudit security checks.
|
|
27
27
|
version Prints the module version. Use [-v] [--v] [-version] or [--version].
|
|
28
28
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
|
|
2
|
+
# Command `codeaudit overview`
|
|
3
|
+
|
|
4
|
+
The command:
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
codeaudit overview
|
|
8
|
+
```
|
|
9
|
+
is created to give a quick insights in possible security concerns.
|
|
10
|
+
|
|
11
|
+
For every Python file the following **security** relevant statistics are determined:
|
|
12
|
+
|
|
13
|
+
* **Number Of Code Lines**: Too many Lines Of Code (LoC) means a higher risk. Large code bases require a lot of effort to keep the security risks manageable. A large number of LoCs (Lines Of Code) means extra effort for maintenance there is a severe risks that new features or fixes will introduce new security risks.
|
|
14
|
+
|
|
15
|
+
* **Number of AST_Nodes**: Codeaudit calculates the number or 'AST Nodes' based on creating an Abstract Syntax Tree (AST) of a file. This to give a solid insight in the complexity of Python source code. Code Audit does not simply counts nodes, but complexity is determined by an algorithm where e.g. the number of `if-else` loops is counted and weighted. More information about complexity can be found in the section [Codeaudit complexity Check](complexitycheck).
|
|
16
|
+
|
|
17
|
+
* **Number of Modules**: A high the number of used modules used within a Python file can mean more security risks. This since there are more dependencies to manage. To get more insight in modules used in a Python file you **SHOULD** use the `codeaudit modulescan` command!
|
|
18
|
+
|
|
19
|
+
* **Number of Functions**. There is no such thing as a perfect architecture for Python programs. However there are many programs that are simple **bad** designed. Too many functions in one Python file in combination with one of the other statistics is an indication for possible security risks.
|
|
20
|
+
|
|
21
|
+
* **Number of Classes**.
|
|
22
|
+
|
|
23
|
+
* **Number of Comment_Lines**. Python files with too little or too many comment lines can have impact on maintenance from a security point of view.
|
|
24
|
+
|
|
25
|
+
* **Complexity_Score**: Per file the complexity of file is determined. A high complexity score can in potential result in more possible security risks. More information about complexity can be found in the section [Codeaudit complexity Check](complexitycheck).
|
|
26
|
+
|
|
27
|
+
* **Number of Warnings**: A normal Python source file should not give Warnings. Warnings should be solved to prevent security risks in future.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
To get a quick overview and core statistics that gives a **solid** insight in possible security risks of Python files of a Python program (module) or directory of Python files do:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
codeaudit overview <DIRECTORY> [OUTPUTFILE]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The `DIRECTORY` is mandatory. Codeaudit will search for **all** Python files in this directory. It can even be e.g.:
|
|
38
|
+
* `.` for scanning and using the current directory for an overview report.
|
|
39
|
+
* `\src` for scanning and reporting on Python files found in the `\src` directory.
|
|
40
|
+
|
|
41
|
+
If you do not specify a HTML output file, a HTML report file is created in the current directory and will be named `codeaudit-report.html`.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Example
|
|
45
|
+
|
|
46
|
+
Example of an [overview report](examples/overview.html) that is generated with the command:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
codeaudit overview /src/linkaudit
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
An overview plot is generated to quickly get insight in possible problematic files. E.g. files that have a high complexity count or files that a large number of Lines Of Code (LoCs). Large files and files with a high complexity rating should be distrusted by default from a security perspective.
|
|
53
|
+
|
|
54
|
+
Example of an overview plot:
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
## Syntax
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
NAME
|
|
61
|
+
codeaudit overview - Reports Complexity and statistics per Python file from a directory.
|
|
62
|
+
|
|
63
|
+
SYNOPSIS
|
|
64
|
+
codeaudit overview DIRECTORY <flags>
|
|
65
|
+
|
|
66
|
+
DESCRIPTION
|
|
67
|
+
Reports Complexity and statistics per Python file from a directory.
|
|
68
|
+
|
|
69
|
+
POSITIONAL ARGUMENTS
|
|
70
|
+
DIRECTORY
|
|
71
|
+
Path to the directory to scan.
|
|
72
|
+
|
|
73
|
+
FLAGS
|
|
74
|
+
-f, --filename=FILENAME
|
|
75
|
+
Default: 'codeaudit-report.html'
|
|
76
|
+
Output filename for the HTML report.
|
|
77
|
+
|
|
78
|
+
```
|
|
@@ -222,7 +222,7 @@ footer {
|
|
|
222
222
|
<td>Base encoding visually hides otherwise easily recognized information such as passwords, but does not provide any computational confidentiality.</td>
|
|
223
223
|
</tr>
|
|
224
224
|
<tr>
|
|
225
|
-
<td>Built-in Functions: Check on compile
|
|
225
|
+
<td>Built-in Functions: Check on compile usage.</td>
|
|
226
226
|
<td>compile</td>
|
|
227
227
|
<td>High</td>
|
|
228
228
|
<td>It is possible to crash the Python interpreter when using this function.</td>
|
|
@@ -240,13 +240,13 @@ footer {
|
|
|
240
240
|
<td>Too broad exception handling risk when not used correctly.</td>
|
|
241
241
|
</tr>
|
|
242
242
|
<tr>
|
|
243
|
-
<td>Check on eval
|
|
243
|
+
<td>Check on eval usage</td>
|
|
244
244
|
<td>eval</td>
|
|
245
245
|
<td>High</td>
|
|
246
246
|
<td>This function can executes arbitrary code.</td>
|
|
247
247
|
</tr>
|
|
248
248
|
<tr>
|
|
249
|
-
<td>Built-in Functions: Check for exec
|
|
249
|
+
<td>Built-in Functions: Check for exec usage.</td>
|
|
250
250
|
<td>exec</td>
|
|
251
251
|
<td>High</td>
|
|
252
252
|
<td>This built-in function can execute code you do not want and/or aware of. So check and validate if it is used correct.</td>
|
|
@@ -264,13 +264,13 @@ footer {
|
|
|
264
264
|
<td>Use of insecure hashing algorithms detected.</td>
|
|
265
265
|
</tr>
|
|
266
266
|
<tr>
|
|
267
|
-
<td>HTTP servers: Check on
|
|
267
|
+
<td>HTTP servers: Check on usage.</td>
|
|
268
268
|
<td>http.server<br>BaseHTTPRequestHandler</td>
|
|
269
269
|
<td>High</td>
|
|
270
270
|
<td>Insecure for production use.</td>
|
|
271
271
|
</tr>
|
|
272
272
|
<tr>
|
|
273
|
-
<td>HTTP servers: Check on
|
|
273
|
+
<td>HTTP servers: Check on usage.</td>
|
|
274
274
|
<td>http.server<br>HTTPServer</td>
|
|
275
275
|
<td>High</td>
|
|
276
276
|
<td>Insecure for production use.</td>
|
|
@@ -533,12 +533,36 @@ footer {
|
|
|
533
533
|
<td>Medium</td>
|
|
534
534
|
<td>Use of the subprocess module calls should be analyzed in-depth.</td>
|
|
535
535
|
</tr>
|
|
536
|
+
<tr>
|
|
537
|
+
<td>Sys calls</td>
|
|
538
|
+
<td>sys.call_tracing</td>
|
|
539
|
+
<td>Medium</td>
|
|
540
|
+
<td>Sys functions that can give ow-level access to the interpreter's execution flow.</td>
|
|
541
|
+
</tr>
|
|
542
|
+
<tr>
|
|
543
|
+
<td>Sys calls</td>
|
|
544
|
+
<td>sys.setprofile</td>
|
|
545
|
+
<td>Medium</td>
|
|
546
|
+
<td>Sys functions that can give ow-level access to the interpreter's execution flow.</td>
|
|
547
|
+
</tr>
|
|
548
|
+
<tr>
|
|
549
|
+
<td>Sys calls</td>
|
|
550
|
+
<td>sys.settrace</td>
|
|
551
|
+
<td>Medium</td>
|
|
552
|
+
<td>Sys functions that can give ow-level access to the interpreter's execution flow.</td>
|
|
553
|
+
</tr>
|
|
536
554
|
<tr>
|
|
537
555
|
<td>Tarfile</td>
|
|
538
556
|
<td>tarfile.TarFile</td>
|
|
539
557
|
<td>High</td>
|
|
540
558
|
<td>Extracting files within a program should never be trusted by default. This issue is detected when the zipfile and/or tarfile module with an extraction method is used.</td>
|
|
541
559
|
</tr>
|
|
560
|
+
<tr>
|
|
561
|
+
<td>tempfile</td>
|
|
562
|
+
<td>tempfile.mktemp</td>
|
|
563
|
+
<td>Low</td>
|
|
564
|
+
<td>This function may introduce race conditions which could negatively impact security.</td>
|
|
565
|
+
</tr>
|
|
542
566
|
<tr>
|
|
543
567
|
<td>XML - client</td>
|
|
544
568
|
<td>xmlrpc.client</td>
|
|
@@ -558,4 +582,4 @@ footer {
|
|
|
558
582
|
<td>Extracting files within a program should never be trusted by default. This issue is detected when the zipfile and/or tarfile module with an extraction method is used.</td>
|
|
559
583
|
</tr>
|
|
560
584
|
</tbody>
|
|
561
|
-
</table><br><p>Number of implemented security validations:<b>
|
|
585
|
+
</table><br><p>Number of implemented security validations:<b>62</b></p><p>Version of codeaudit: <b>0.8.0</b><p>Because Python and cybersecurity are constantly changing, issue reports <b>SHOULD</b> specify the codeaudit version used.</p><p><b>Disclaimer:</b><i>This SAST tool 'codeaudit' provides a powerful automatic security analysis for Python source code. However it's not a substitute for human review in combination with business knowledge. <b>Undetected vulnerabilities may still exist</b>. There is and will never be a single security tool that gives 100% automatic guarantees. By reporting any issues you find, you contribute to a better tool for everyone.</i></p><footer><hr><p><small>This security report is created on: 2025-08-01 19:24, with <a href="https://github.com/nocomplexity/codeaudit">codeaudit</a> version 0.8.0 </small></p><p><small>Check the <a href="https://nocomplexity.com/documents/codeaudit/intro.html" target="_blank">documentation</a> for help on found issues. <a href="https://github.com/nocomplexity/codeaudit">Codeaudit</a> is made with ❤ by cyber security professionals who advocate for <a href="https://simplifysecurity.nocomplexity.com" target="_blank">simpler cyber solutions</a> that are transparent and just work. Help to make this FOSS software better!</small></p></footer></div></body></html>
|
|
@@ -2,36 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
Codeaudit is a modern Python source code analyzer based on distrust.
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
:::{admonition} This Python Code Audit tool has the following features:
|
|
6
7
|
:class: tip
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
* **Vulnerability Detection**: Identifies security
|
|
10
|
+
* **Vulnerability Detection**: Identifies potential security issues in Python files. Crucial to check trust in Python modules and essential for security research.
|
|
10
11
|
|
|
11
12
|
+++
|
|
12
13
|
|
|
13
|
-
* **Complexity & Statistics**: Reports security-relevant complexity using a fast, lightweight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) count
|
|
14
|
+
* **Complexity & Statistics**: Reports security-relevant complexity statistics using a fast, lightweight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) count by using Python AST.
|
|
14
15
|
|
|
15
16
|
+++
|
|
16
17
|
|
|
17
|
-
* **Module Usage & External Vulnerabilities**: Detects used modules and reports vulnerabilities in
|
|
18
|
+
* **Module Usage & External Vulnerabilities**: Detects used modules and reports existing vulnerabilities in used modules.
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
+++
|
|
21
|
-
* **Inline Issue Reporting**: Shows potential security issues with line numbers and code snippets.
|
|
22
|
+
* **Inline Issue Reporting**: Shows potential security issues with line numbers and crucial code snippets.
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
+++
|
|
25
|
-
* **HTML Reports**: All output is saved in simple, static HTML reports
|
|
26
|
-
|
|
26
|
+
* **HTML Reports**: All output is saved in simple, static HTML reports. Viewable in any browser.
|
|
27
27
|
|
|
28
28
|
:::
|
|
29
29
|
|
|
30
|
+
## More comprehensive outline:
|
|
31
|
+
|
|
32
|
+
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
Codeaudit has the has the following capabilities:
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
* Detect and reports complexity and statistics per Python file or from a directory.
|
|
37
|
+
|
|
38
|
+
Collected statistics are:
|
|
35
39
|
* Number_Of_Files
|
|
36
40
|
* Number_Of_Lines
|
|
37
41
|
* AST_Nodes
|
|
@@ -52,3 +56,5 @@ Per detected issue the line number is given, along with the lines that *could* c
|
|
|
52
56
|
|
|
53
57
|
* Detecting and reporting potential vulnerabilities from all Python files collected in a directory.
|
|
54
58
|
This is typically a must check when researching python packages on possible security issues.
|
|
59
|
+
|
|
60
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Command `codeaudit filescan`
|
|
2
2
|
|
|
3
3
|
The Codeaudit filescan command creates a report with valuable security information for potential security issues in the Python file.
|
|
4
4
|
See section [validations](checksinformation) for all security checks implemented!
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Codeaudit is a Python Static Application Security Testing (SAST) tool to find **potential security issues** in Python source files.
|
|
6
|
+
|
|
7
|
+
Codeaudit is designed to be:
|
|
8
|
+
* Simple to use.
|
|
9
|
+
* Simple to extend for various use cases.
|
|
10
|
+
* Powerful to determine *potential* security issues within Python code.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
:::{admonition} This Python Code Audit tool has the following features:
|
|
15
|
+
:class: tip
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
* **Vulnerability Detection**: Identifies potential security issues in Python files. Crucial to check trust in Python modules and essential for security research.
|
|
19
|
+
|
|
20
|
+
+++
|
|
21
|
+
|
|
22
|
+
* **Complexity & Statistics**: Reports security-relevant complexity statistics using a fast, lightweight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) count by using Python AST.
|
|
23
|
+
|
|
24
|
+
+++
|
|
25
|
+
|
|
26
|
+
* **Module Usage & External Vulnerabilities**: Detects used modules and reports existing vulnerabilities in used modules.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
+++
|
|
30
|
+
* **Inline Issue Reporting**: Shows potential security issues with line numbers and crucial code snippets.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
+++
|
|
34
|
+
* **HTML Reports**: All output is saved in simple, static HTML reports. Viewable in any browser.
|
|
35
|
+
|
|
36
|
+
:::
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Background
|
|
41
|
+
|
|
42
|
+
There are not many good and maintained FOSS SAST tools for Python available. A well known Python SAST tool is `Bandit`. However `Bandit` is limited in identifying security issues and has constrains that makes the use not simple. `Bandit` lacks crucial Python code validations from a security perspective!
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
:::{note}
|
|
46
|
+
This `codeaudit` tool is designed to be complete, fast and simple and easy to maintain library that can be extended for all needs.
|
|
47
|
+
:::
|
|
48
|
+
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Installation
|
|
4
4
|
|
|
5
|
-
Codeaudit
|
|
5
|
+
Codeaudit **SHOULD** be installed using `pip`:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
pip install codeaudit
|
|
@@ -14,10 +14,24 @@ or use:
|
|
|
14
14
|
pip install -U codeaudit
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
If you have installed Python Codeaudit in the past and want to make
|
|
17
|
+
If you have installed and used Python Codeaudit in the past and want to make benefit of new checks and features.
|
|
18
18
|
|
|
19
19
|
:::{hint}
|
|
20
|
-
It is recommended to use `pip` for installation.
|
|
20
|
+
It is recommended to use `pip` for installation.
|
|
21
|
+
|
|
22
|
+
`Hatch` is used for packaging. By default [`Hatch`](https://hatch.pypa.io/latest/config/build/#reproducible-builds) supports [reproducible builds](https://nocomplexity.com/documents/securityarchitecture/prevention/reproduciblebuilds.html#reproducible-builds).
|
|
23
|
+
:::
|
|
24
|
+
|
|
25
|
+
:::{admonition} A default workflow
|
|
26
|
+
:class: tip
|
|
27
|
+
|
|
28
|
+
If you want to inspect a package or directory of Python files a simple workflow is:
|
|
29
|
+
|
|
30
|
+
1. Start with an overview: `codeaudit overview`
|
|
31
|
+
2. Do a directory scan: `codeaudit directoryscan` OR
|
|
32
|
+
3. OR Scan files of interest with: `codeaudit filescan`
|
|
33
|
+
4. Inspect the used modules of a file on reported vulnerabilties by: `codeaudit modulescan`
|
|
34
|
+
|
|
21
35
|
:::
|
|
22
36
|
|
|
23
37
|
## CodeAudit commands
|
|
@@ -29,12 +43,11 @@ Codeaudit has a few powerful CLI commands to satisfy your curiosity about securi
|
|
|
29
43
|
|
|
30
44
|
|
|
31
45
|
|
|
32
|
-
|
|
33
46
|
## Getting help
|
|
34
47
|
|
|
35
|
-
After installation you can get an overview of all implemented commands.
|
|
48
|
+
After installation you can get an overview of all implemented commands. Type in your terminal:
|
|
36
49
|
|
|
37
|
-
```
|
|
50
|
+
```bash
|
|
38
51
|
codeaudit
|
|
39
52
|
```
|
|
40
53
|
|
|
@@ -18,6 +18,7 @@ import sys
|
|
|
18
18
|
import json
|
|
19
19
|
import urllib.request
|
|
20
20
|
|
|
21
|
+
from codeaudit.filehelpfunctions import collect_python_source_files , read_in_source_file
|
|
21
22
|
|
|
22
23
|
def get_imported_modules(source_code):
|
|
23
24
|
tree = ast.parse(source_code)
|
|
@@ -98,3 +99,38 @@ def check_module_on_vuln(module):
|
|
|
98
99
|
result = query_osv(module)
|
|
99
100
|
vulnerability_info = extract_vuln_info(result)
|
|
100
101
|
return vulnerability_info
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def get_all_modules(directory_to_scan):
|
|
105
|
+
"Function to get all modules of a package or directory of Python files - never trust requirements.txt or project.toml"
|
|
106
|
+
files_to_check = collect_python_source_files(directory_to_scan)
|
|
107
|
+
all_int_modules = set()
|
|
108
|
+
all_ext_modules = set()
|
|
109
|
+
for python_file in files_to_check:
|
|
110
|
+
source = read_in_source_file(python_file)
|
|
111
|
+
used_modules = get_imported_modules(source)
|
|
112
|
+
core_modules = used_modules['core_modules']
|
|
113
|
+
external_modules = used_modules['imported_modules']
|
|
114
|
+
all_int_modules.update(core_modules)
|
|
115
|
+
all_ext_modules.update(external_modules)
|
|
116
|
+
all_modules_discovered = {
|
|
117
|
+
"core_modules": sorted(all_int_modules),
|
|
118
|
+
"imported_modules": sorted(all_ext_modules) }
|
|
119
|
+
return all_modules_discovered
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def get_imported_modules_by_file(python_file_name):
|
|
123
|
+
"Function to get all modules of a package or directory of Python files - never trust requirements.txt or project.toml"
|
|
124
|
+
#total_result=[]
|
|
125
|
+
source = read_in_source_file(python_file_name)
|
|
126
|
+
used_modules = get_imported_modules(source)
|
|
127
|
+
core_modules = used_modules['core_modules']
|
|
128
|
+
external_modules = used_modules['imported_modules']
|
|
129
|
+
# result = { "filename" : python_file ,
|
|
130
|
+
# "used_modules" : core_modules,
|
|
131
|
+
# "external_modules": external_modules }
|
|
132
|
+
#total_result.append(result)
|
|
133
|
+
all_modules_discovered = {
|
|
134
|
+
"core_modules": sorted(core_modules),
|
|
135
|
+
"imported_modules": sorted(external_modules) }
|
|
136
|
+
return all_modules_discovered
|
|
@@ -42,8 +42,8 @@ def display_help():
|
|
|
42
42
|
print('Usage: codeaudit COMMAND [PATH or FILE] [OUTPUTFILE] \n')
|
|
43
43
|
print('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.\n')
|
|
44
44
|
print('Commands:')
|
|
45
|
-
commands = ["overview", "
|
|
46
|
-
functions = [overview_report,
|
|
45
|
+
commands = ["overview", "directoryscan", "filescan", "modulescan", "checks","version"] # commands on CLI
|
|
46
|
+
functions = [overview_report, directory_scan_report, file_scan_report, report_module_information, report_implemented_tests,display_version] # Related functions relevant for help
|
|
47
47
|
for command, function in zip(commands, functions):
|
|
48
48
|
docstring = function.__doc__.strip().split('\n')[0] or ""
|
|
49
49
|
summary = docstring.split("\n", 1)[0]
|
|
@@ -15,7 +15,6 @@ HTML helper functions for codeaudit
|
|
|
15
15
|
import json
|
|
16
16
|
from html import escape
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
def dict_to_html(data):
|
|
20
19
|
"""Creates simple HTML from a dict with values that are list:
|
|
21
20
|
Example {'core_modules': ['os', 'hashlib', 'socket', 'logging.config', 'tarfile'],
|
|
@@ -25,9 +24,15 @@ def dict_to_html(data):
|
|
|
25
24
|
|
|
26
25
|
if not isinstance(data, dict):
|
|
27
26
|
html_output += "<p>None</p>\n"
|
|
28
|
-
return
|
|
27
|
+
return html_output
|
|
29
28
|
|
|
30
29
|
for key, items in data.items():
|
|
30
|
+
# Check if items are missing, empty, or not iterable
|
|
31
|
+
if not items or not isinstance(items, (list, tuple)):
|
|
32
|
+
html_output += f"<h3>{key.capitalize()}</h3>\n - not found<ul>\n"
|
|
33
|
+
html_output += "</ul>\n"
|
|
34
|
+
continue
|
|
35
|
+
|
|
31
36
|
html_output += f"<h3>{key.capitalize()}</h3>\n<ul>\n"
|
|
32
37
|
try:
|
|
33
38
|
for item in items:
|
|
@@ -35,6 +40,7 @@ def dict_to_html(data):
|
|
|
35
40
|
except Exception:
|
|
36
41
|
html_output += " <li>None</li>\n"
|
|
37
42
|
html_output += "</ul>\n"
|
|
43
|
+
|
|
38
44
|
return html_output
|
|
39
45
|
|
|
40
46
|
|
|
@@ -20,10 +20,10 @@ import pandas as pd
|
|
|
20
20
|
import datetime
|
|
21
21
|
|
|
22
22
|
from codeaudit.security_checks import perform_validations , ast_security_checks
|
|
23
|
-
from codeaudit.filehelpfunctions import get_filename_from_path , collect_python_source_files
|
|
23
|
+
from codeaudit.filehelpfunctions import get_filename_from_path , collect_python_source_files , read_in_source_file
|
|
24
24
|
from codeaudit.altairplots import multi_bar_chart
|
|
25
|
-
from codeaudit.totals import
|
|
26
|
-
from codeaudit.checkmodules import get_imported_modules , check_module_on_vuln
|
|
25
|
+
from codeaudit.totals import get_statistics , overview_count , overview_per_file
|
|
26
|
+
from codeaudit.checkmodules import get_imported_modules , check_module_on_vuln , get_all_modules , get_imported_modules_by_file
|
|
27
27
|
from codeaudit.htmlhelpfunctions import dict_to_html , json_to_html , dict_list_to_html_table
|
|
28
28
|
from codeaudit import __version__
|
|
29
29
|
|
|
@@ -69,9 +69,16 @@ def overview_report(directory, filename=DEFAULT_OUTPUT_FILE):
|
|
|
69
69
|
html += '<p>Based on the total Lines of Code (LoC) : Security concern rate is <b>HIGH</b>'
|
|
70
70
|
else:
|
|
71
71
|
html += '<p>Based on the total Lines of Code (LoC) : Security concern rate is <b>LOW</b>'
|
|
72
|
-
html += '<br
|
|
73
|
-
|
|
72
|
+
html += '<br>'
|
|
73
|
+
## Module overview
|
|
74
|
+
modules_discovered = get_all_modules(directory)
|
|
74
75
|
html += '<details>'
|
|
76
|
+
html += '<summary>Click to see all discovered modules.</summary>'
|
|
77
|
+
html+=dict_to_html(modules_discovered)
|
|
78
|
+
html += '<p><i>The command "codeaudit modulescan" can be used to check if vulnerabilities are reported in an external module.</i></p>'
|
|
79
|
+
html += '</details>'
|
|
80
|
+
html += f'<h2>Detailed overview per source file</h2>'
|
|
81
|
+
html += '<details>'
|
|
75
82
|
html += '<summary>Click to see the report details.</summary>'
|
|
76
83
|
html += df.to_html(escape=True,index=False)
|
|
77
84
|
html += '</details>'
|
|
@@ -150,6 +157,14 @@ def single_file_report(filename , scan_output):
|
|
|
150
157
|
html += f'<summary>Click to see details for file {filename}</summary>'
|
|
151
158
|
html += df_overview.to_html(escape=True,index=False)
|
|
152
159
|
html += '</details>'
|
|
160
|
+
#imported modules
|
|
161
|
+
html += '<br>'
|
|
162
|
+
html += '<details>'
|
|
163
|
+
html += '<summary>Click to see details for used modules in this file.</summary>'
|
|
164
|
+
modules_found = get_imported_modules_by_file(filename)
|
|
165
|
+
html += dict_to_html(modules_found)
|
|
166
|
+
html += f'<p><i>Use the command:<br><b><code>codeaudit modulescan {filename}</code></b><br> to check if vulnerabilities are reported in an external module used by this file.</i></p>'
|
|
167
|
+
html += '</details>'
|
|
153
168
|
return html
|
|
154
169
|
|
|
155
170
|
|
|
@@ -214,8 +229,9 @@ def report_module_information(inputfile,reportname=DEFAULT_OUTPUT_FILE):
|
|
|
214
229
|
html = '<h1>Codeaudit Report</h1>'
|
|
215
230
|
html += f'<h2>Module information for file {inputfile}</h2>'
|
|
216
231
|
html += dict_to_html(used_modules)
|
|
217
|
-
#Now vuln info per external module
|
|
218
|
-
|
|
232
|
+
#Now vuln info per external module
|
|
233
|
+
if external_modules:
|
|
234
|
+
html += '<h2>Vulnerability information for detected modules</h2>'
|
|
219
235
|
for i,module in enumerate(external_modules): #sorted for nicer report
|
|
220
236
|
printProgressBar(i + 1, l, prefix='Progress:', suffix='Complete', length=50)
|
|
221
237
|
vuln_info = check_module_on_vuln(module)
|
|
@@ -262,7 +278,7 @@ def create_htmlfile(html_input,outputfile):
|
|
|
262
278
|
code_audit_version = __version__
|
|
263
279
|
output += '<footer>'
|
|
264
280
|
output += '<hr>'
|
|
265
|
-
output += f'<p><small>This security report is created on: {timestamp_str}, with <a href="https://github.com/nocomplexity">codeaudit</a> version {code_audit_version} </small></p>'
|
|
281
|
+
output += f'<p><small>This security report is created on: {timestamp_str}, with <a href="https://github.com/nocomplexity/codeaudit">codeaudit</a> version {code_audit_version} </small></p>'
|
|
266
282
|
output += '<p><small>Check the <a href="https://nocomplexity.com/documents/codeaudit/intro.html" target="_blank">documentation</a> for help on found issues. <a href="https://github.com/nocomplexity/codeaudit">Codeaudit</a> is made with ❤ by cyber security professionals who advocate for <a href="https://simplifysecurity.nocomplexity.com" target="_blank">simpler cyber solutions</a> that are transparent and just work. Help to make this FOSS software better!</small></p>'
|
|
267
283
|
output += '</footer>'
|
|
268
284
|
output += '</div>' #base container
|
|
@@ -126,7 +126,7 @@ def overview_per_file(python_file):
|
|
|
126
126
|
lines = {"Number_Of_Lines": number_of_lines}
|
|
127
127
|
complexity_score = calculate_complexity(source)
|
|
128
128
|
complexity = {"Complexity_Score": complexity_score}
|
|
129
|
-
|
|
129
|
+
warnings_count = count_static_warnings_in_file(python_file)
|
|
130
130
|
result = (
|
|
131
131
|
name_dict
|
|
132
132
|
| file_location
|
|
@@ -134,7 +134,7 @@ def overview_per_file(python_file):
|
|
|
134
134
|
| count_ast_objects(source)
|
|
135
135
|
| count_comment_lines(source)
|
|
136
136
|
| complexity
|
|
137
|
-
|
|
|
137
|
+
| warnings_count
|
|
138
138
|
) # merge the dicts
|
|
139
139
|
return result
|
|
140
140
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from codeaudit.filehelpfunctions import read_in_source_file
|
|
5
|
+
from codeaudit.checkmodules import get_imported_modules
|
|
6
|
+
|
|
7
|
+
def test_module_check():
|
|
8
|
+
current_file_directory = Path(__file__).parent
|
|
9
|
+
# validation1.py is in a subfolder:
|
|
10
|
+
validation_file_path = current_file_directory / "validationfiles" / "modulecheck.py"
|
|
11
|
+
source = read_in_source_file(validation_file_path)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
actual_data = get_imported_modules(source)
|
|
15
|
+
|
|
16
|
+
# This is the expected dictionary
|
|
17
|
+
expected_data = {'core_modules': ['csv','os', 'random' ],
|
|
18
|
+
'imported_modules': ['linkaudit', 'pandas', 'requests']}
|
|
19
|
+
|
|
20
|
+
# Assert that the actual data matches the expected data
|
|
21
|
+
assert actual_data == expected_data
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Codeaudit Overview
|
|
3
|
-
|
|
4
|
-
`Codeaudit overview` is created to give a quick insight in possible security issues.
|
|
5
|
-
|
|
6
|
-
For every Python file the following security relevant statistics are determined:
|
|
7
|
-
* Number Of Code Lines: Too much means more energy to keep the security risks manageable. Files with a large number of LoCs (Lines Of Code) means besides extra effort for maintenance and activities needed to keep security risks zero.
|
|
8
|
-
* Number of AST_Nodes: Codeaudit calculates Abstract Syntax Trees (ASTs) to give a solid insight in the complexity of Python source code.
|
|
9
|
-
* Number of Modules: A high the number of used modules can mean more security risks. To get more insight in modules used in a Python file you **SHOULD** use the `codeaudit modulescan` command!
|
|
10
|
-
* Number of Functions.
|
|
11
|
-
* Number of Classes
|
|
12
|
-
* Number of Comment_Lines
|
|
13
|
-
* Complexity_Score: Per file the complexity of file is determined. A high score means more possible security risks.
|
|
14
|
-
* Number of Warnings: A normal Python source file should not give Warnings. Warnings should be solved to prevent security risks in future.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
To get a quick overview and core statistics that give a **solid** insight in the security of Python files of a directory do:
|
|
19
|
-
|
|
20
|
-
```text
|
|
21
|
-
codeaudit overview <DIRECTORY> [OUTPUTFILE]
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
The `DIRECTORY` is mandatory. Codeaudit will search for **all** Python files in this directory. It can even be e.g.:
|
|
25
|
-
* `.` for scanning and using the current directory for an overview report.
|
|
26
|
-
* `\src` for scanning and reporting on Python files found in the `\src` directory.
|
|
27
|
-
|
|
28
|
-
If you do not specify a HTML output file, a HTML report file is created in the current directory and will be named `codeaudit-report.html`.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Example
|
|
32
|
-
|
|
33
|
-
Example of an [overview report](examples/overview.html) that is generated with the command:
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
codeaudit overview /src/linkaudit
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
An overview plot is generated to quickly get insight in possible problematic files. E.g. files that have a high complexity count or files that a large number of Lines Of Code (LoCs). Large files and files with a high complexity rating should be distrusted by default from a security perspective.
|
|
40
|
-
|
|
41
|
-
Example of an overview plot:
|
|
42
|
-

|
|
43
|
-
|
|
44
|
-
## Syntax
|
|
45
|
-
|
|
46
|
-
```text
|
|
47
|
-
NAME
|
|
48
|
-
codeaudit overview - Reports Complexity and statistics per Python file from a directory.
|
|
49
|
-
|
|
50
|
-
SYNOPSIS
|
|
51
|
-
codeaudit overview DIRECTORY <flags>
|
|
52
|
-
|
|
53
|
-
DESCRIPTION
|
|
54
|
-
Reports Complexity and statistics per Python file from a directory.
|
|
55
|
-
|
|
56
|
-
POSITIONAL ARGUMENTS
|
|
57
|
-
DIRECTORY
|
|
58
|
-
Path to the directory to scan.
|
|
59
|
-
|
|
60
|
-
FLAGS
|
|
61
|
-
-f, --filename=FILENAME
|
|
62
|
-
Default: 'codeaudit-report.html'
|
|
63
|
-
Output filename for the HTML report.
|
|
64
|
-
|
|
65
|
-
```
|
codeaudit-0.8.0/docs/intro.md
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Introduction
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
Codeaudit is a Python Static Application Security Testing (SAST) tool to find **potential security issues** in Python source files.
|
|
6
|
-
|
|
7
|
-
Codeaudit is designed to be:
|
|
8
|
-
* Simple to use.
|
|
9
|
-
* Simple to extend for various use cases.
|
|
10
|
-
* Powerful to determine *potential* security issues within Python code.
|
|
11
|
-
|
|
12
|
-
## Features
|
|
13
|
-
:::{admonition} This Python Code Audit tool has the following features:
|
|
14
|
-
:class: tip
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* **Vulnerability Detection**: Identifies security vulnerabilities in Python files, essential for package security research.
|
|
18
|
-
|
|
19
|
-
+++
|
|
20
|
-
|
|
21
|
-
* **Complexity & Statistics**: Reports security-relevant complexity using a fast, lightweight [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) count via Python's AST.
|
|
22
|
-
|
|
23
|
-
+++
|
|
24
|
-
|
|
25
|
-
* **Module Usage & External Vulnerabilities**: Detects used modules and reports vulnerabilities in external ones.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
+++
|
|
29
|
-
* **Inline Issue Reporting**: Shows potential security issues with line numbers and code snippets.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
+++
|
|
33
|
-
* **HTML Reports**: All output is saved in simple, static HTML reports viewable in any browser.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
:::
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Background
|
|
41
|
-
|
|
42
|
-
There are not many good FOSS SAST tools for Python available. A good one is `Bandit`. However this `Bandit` has some constrains that makes the use not simple and lacks crucial but needed validations from a security perspective!
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
:::{note}
|
|
46
|
-
This `codeaudit` tool is designed to be fast and simple and easy to maintain library that can be extended for future needs.
|
|
47
|
-
:::
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```{tableofcontents}
|
|
51
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|