codeaudit 1.2.0__tar.gz → 1.3.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-1.2.0 → codeaudit-1.3.0}/CHANGELOG.md +22 -1
- {codeaudit-1.2.0 → codeaudit-1.3.0}/PKG-INFO +6 -1
- {codeaudit-1.2.0 → codeaudit-1.3.0}/README.md +3 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/_toc.yml +4 -2
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/pickle_check.md +1 -1
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/codeauditcommands.md +5 -5
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/demoscan.json +2 -2
- codeaudit-1.3.0/docs/handling_errors.md +13 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/help.md +31 -2
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/intro.md +3 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/license.md +6 -2
- codeaudit-1.3.0/docs/project_philosophy.md +55 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/userguide.md +11 -15
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/warnings.md +2 -2
- {codeaudit-1.2.0 → codeaudit-1.3.0}/pyproject.toml +2 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/__about__.py +1 -1
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/data/sastchecks.csv +8 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/reporting.py +4 -4
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_constructspart2.py +2 -8
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_random.py +13 -10
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_standardlibconstructs.py +10 -11
- codeaudit-1.3.0/tests/validationfiles/pickle.py +19 -0
- codeaudit-1.3.0/tests/validationfiles/random.py +31 -0
- codeaudit-1.3.0/tests/validationfiles/shelve.py +7 -0
- codeaudit-1.2.0/tests/validationfiles/pickle.py +0 -12
- codeaudit-1.2.0/tests/validationfiles/random.py +0 -16
- codeaudit-1.2.0/tests/validationfiles/shelve.py +0 -4
- {codeaudit-1.2.0 → codeaudit-1.3.0}/.gitignore +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/CONTRIBUTE.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/LICENSE.txt +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/SECURITY.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/CLIcommands.ipynb +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/CONTRIBUTE.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/_config.yml +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/_static/nocxstyle.css +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/about.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/apidocs/api_intro.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/apidocs/codeaudit.rst +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/apidocs/modules.rst +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/astlines.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/astlines2.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/changelog.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/assert_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/base64_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/binding_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/builtinfunctions_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/chmod_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/directorycreation_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/dynamicimport_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/exception_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/hash_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/httpserver_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/input_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/loggingconf_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/marshal_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/mktemp_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/multiprocessing_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/random_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/shelve_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/shutil_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/subprocess_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/syscalls_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/systemcalls_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/tarfile_extract_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/xml_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checks/zipfile_check.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/checksinformation.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/codeauditchecks.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/codeauditoverview.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/complexitycheck.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/ca_api_example_basic.ipynb +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/ca_api_example_json.ipynb +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/ca_api_example_overview.ipynb +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/checks.html +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/demofile.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/directoryscan.html +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/filescan.html +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/modulescan.html +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/examples/overview.html +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/features.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/filescan.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/filescan.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/howtoscan.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/images/OO.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/images/ROI_logo.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/images/YourLogoHere.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/images/codeauditlogo.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/images/nocxbanner.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/images/overview_linkaudit.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/implementedvalidations.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/issues.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/makeitbetter.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/modulescan.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/overviewplot.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/pca_overview.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/sponsors.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/whatissast.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/docs/whysast.md +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/filescan.png +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/__init__.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/altairplots.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/api_interfaces.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/checkmodules.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/codeaudit.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/complexitycheck.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/filehelpfunctions.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/htmlhelpfunctions.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/issuevalidations.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/security_checks.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/simple.css +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/src/codeaudit/totals.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/__init__.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/count_lines_file1.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_apicalls.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_basicpatterns.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_chmod.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_correctexceptionuse.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_count_commentlines.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_directorycreation.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_directorycreation2.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_hashstrenght.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_modulecheck.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_obfuscatingbuiltins.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_oschecks.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/test_totalscheck.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/allshit.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/assert.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/base64.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/chmod_things.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/complexitycheck.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/correctcounts.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/directorycreation.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/directorycreation2.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/dunderexec_with_parsing_error.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/exception.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/file3.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/file_with_warnings.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/gzip.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/hashcheck.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/httpserver.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/inputstatement.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/marshal.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/modulecheck.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/multiprocessing.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/obfuscating.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/oschecks.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/python2_file_willnotwork.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/shutil.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/subprocess.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/syslibrary.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/tarfilevalidation.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/tempcheck.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/validation1.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/validation2.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/xml.py +0 -0
- {codeaudit-1.2.0 → codeaudit-1.3.0}/tests/validationfiles/zipfile.py +0 -0
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Version 1.3: Changes and Updates
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* **Documentation:** General improvements and clarifications.
|
|
10
|
+
* **Environment:** Updated `project.toml` — now compatible with **Python 3.14**.
|
|
11
|
+
|
|
12
|
+
* ⚠️ *Note:* The **Altair** dependency for Python 3.14 requires an update; final wording will depend on the release status of the next Altair version. The current working version of Altair (`altair-5.6.0.dev0 with typing-extensions-4.15.0` ) was used to validate correct working of all functionality of **Python Code Audit** for Python 3.14.
|
|
13
|
+
|
|
14
|
+
* **Validation Enhancements:**
|
|
15
|
+
|
|
16
|
+
* Added validation for use of the class `pickle.Unpickler`, which may process untrusted binary pickle data streams.
|
|
17
|
+
* Added validation for use of the class `shelve.DbfilenameShelf`.
|
|
18
|
+
* Extended validation to detect potentially unsafe calls to the `random` module.
|
|
19
|
+
|
|
20
|
+
* **CLI:** Improved help text for the `cld` command.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Version 1.2: Changes and Updates
|
|
4
25
|
|
|
5
26
|
* fix: Improved error handling — when performing a file scan on a single Python file that cannot be parsed, the CLI now correctly displays an error message.
|
|
6
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codeaudit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -14,8 +14,10 @@ Classifier: Environment :: Console
|
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: Intended Audience :: Science/Research
|
|
16
16
|
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
21
|
Classifier: Topic :: Security
|
|
20
22
|
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
23
|
Requires-Python: >=3.8
|
|
@@ -28,9 +30,12 @@ Description-Content-Type: text/markdown
|
|
|
28
30
|
|
|
29
31
|

|
|
30
32
|
|
|
33
|
+
[](https://github.com/nocomplexity/codeaudit)
|
|
31
34
|
[](https://pypi.org/project/codeaudit)
|
|
32
35
|
[](https://pypi.org/project/codeaudit)
|
|
33
36
|
[](https://www.bestpractices.dev/projects/10970)
|
|
37
|
+
[](https://nocomplexity.com/documents/codeaudit/intro.html)
|
|
38
|
+
[](https://nocomplexity.com/documents/codeaudit/license.html)
|
|
34
39
|
[](https://pepy.tech/projects/codeaudit)
|
|
35
40
|
|
|
36
41
|
Python Code Audit - A modern Python source code analyzer based on distrust.
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
+
[](https://github.com/nocomplexity/codeaudit)
|
|
5
6
|
[](https://pypi.org/project/codeaudit)
|
|
6
7
|
[](https://pypi.org/project/codeaudit)
|
|
7
8
|
[](https://www.bestpractices.dev/projects/10970)
|
|
9
|
+
[](https://nocomplexity.com/documents/codeaudit/intro.html)
|
|
10
|
+
[](https://nocomplexity.com/documents/codeaudit/license.html)
|
|
8
11
|
[](https://pepy.tech/projects/codeaudit)
|
|
9
12
|
|
|
10
13
|
Python Code Audit - A modern Python source code analyzer based on distrust.
|
|
@@ -5,13 +5,13 @@ parts:
|
|
|
5
5
|
- caption: Quick Start
|
|
6
6
|
chapters:
|
|
7
7
|
- file: features
|
|
8
|
+
- file: howtoscan
|
|
8
9
|
- file: userguide
|
|
9
10
|
sections:
|
|
10
11
|
- file: codeauditoverview
|
|
11
12
|
- file: filescan
|
|
12
13
|
- file: modulescan
|
|
13
|
-
- file: codeauditchecks
|
|
14
|
-
- file: howtoscan
|
|
14
|
+
- file: codeauditchecks
|
|
15
15
|
- file: whatissast
|
|
16
16
|
- file: whysast
|
|
17
17
|
- file: issues
|
|
@@ -54,8 +54,10 @@ parts:
|
|
|
54
54
|
#- file: astlines
|
|
55
55
|
# - file: astlines2
|
|
56
56
|
- file: makeitbetter
|
|
57
|
+
- file: project_philosophy
|
|
57
58
|
- file: complexitycheck
|
|
58
59
|
- file: warnings
|
|
60
|
+
- file: handling_errors
|
|
59
61
|
- file: codeauditcommands
|
|
60
62
|
- file: changelog
|
|
61
63
|
|
|
@@ -5,7 +5,7 @@ Codeaudit checks on the use of the `pickle` statement.
|
|
|
5
5
|
:::{danger}
|
|
6
6
|
Unpickling will import any class or function that it finds in the pickle data. This is a severe security concern as it permits the unpickler to import and invoke arbitrary code.
|
|
7
7
|
|
|
8
|
-
**Never use `pickle.load()`
|
|
8
|
+
**Never use `pickle.load()` , `pickle.loads()` or `pickle.Unpickler` on data received from an untrusted or unauthenticated source.**
|
|
9
9
|
|
|
10
10
|
:::
|
|
11
11
|
|
|
@@ -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.
|
|
3
|
+
Python Code Audit commands for: version: 1.2.0
|
|
4
4
|
```
|
|
5
5
|
----------------------------------------------------
|
|
6
6
|
_ __ _
|
|
@@ -16,8 +16,8 @@ Usage: codeaudit COMMAND [PATH or FILE] [OUTPUTFILE]
|
|
|
16
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.
|
|
17
17
|
|
|
18
18
|
Commands:
|
|
19
|
-
overview Reports
|
|
20
|
-
filescan Scans Python files
|
|
19
|
+
overview Reports complexity and statistics for Python files in a project directory.
|
|
20
|
+
filescan Scans Python projects/files, reporting potential 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].
|
|
@@ -28,7 +28,7 @@ Check https://simplifysecurity.nocomplexity.com/
|
|
|
28
28
|
```
|
|
29
29
|
## Code Audit overview
|
|
30
30
|
```text
|
|
31
|
-
Reports
|
|
31
|
+
Reports complexity and statistics for Python files in a project directory.
|
|
32
32
|
|
|
33
33
|
Parameters:
|
|
34
34
|
directory (str): Path to the directory to scan.
|
|
@@ -59,7 +59,7 @@ errors defaults to 'strict'.
|
|
|
59
59
|
```
|
|
60
60
|
## Code Audit filescan
|
|
61
61
|
```text
|
|
62
|
-
Scans Python files
|
|
62
|
+
Scans Python projects/files, reporting potential 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.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Handling parsing errors
|
|
2
|
+
|
|
3
|
+
Only Python files that can be fully parsed are included in the **Python Code Security audit** scans.
|
|
4
|
+
|
|
5
|
+
Files are parsed using Python’s Abstract Syntax Tree (AST) module. If a file cannot be parsed due to invalid syntax or incompatibility with Python 3.x, an error will be reported (e.g., in the CLD). Such files cannot be analyzed and must be fixed to be included in the audit.
|
|
6
|
+
|
|
7
|
+
## Parsing Errors vs. Warnings
|
|
8
|
+
It is important to distinguish between parsing errors and warnings:
|
|
9
|
+
* **Parsing Errors**: Files that cause a parsing error are not analyzed. These errors indicate the code is fundamentally unreadable by the AST and **should be fixed**.
|
|
10
|
+
* **Warnings**: Python files may contain warnings, but these files are still fully parsed and analyzed. However, from a security standpoint, you should **also fix** Python files that produce warnings, as warnings often point to questionable or deprecated code practices.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
See also the section of [Python warnings](warnings) to learn how **Python Code Audit** handles warnings.
|
|
@@ -10,12 +10,41 @@ Everyone can help with improving this tool!
|
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
## Promote Your Commitment to Python Code Audit
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
Helping is possible in multiple ways:
|
|
16
16
|
* [Support this work](sponsors)
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
* If you use **Python Code Audit**, showcase your dedication to secure coding by adding the badge  to your public repository.
|
|
19
|
+
Displaying the badge signals that you take Python security seriously and have proactively audited your code for potential vulnerabilities.
|
|
20
|
+
|
|
21
|
+
You can display the badge, , by embedding the following snippet in your Markdown file:
|
|
22
|
+
|
|
23
|
+
```markdown
|
|
24
|
+
[](https://github.com/nocomplexity/codeaudit)
|
|
25
|
+
```
|
|
26
|
+
Or by embedding this in your HTML page:
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<href="https://github.com/nocomplexity/codeaudit"><img alt="PythonCodeAudit Badge" src="https://img.shields.io/badge/Python%20Code%20Audit-Security%20Verified-FF0000?style=flat-square"></a>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
:::{admonition} When using the Python Code Audit badge, inform your users!
|
|
33
|
+
:class: tip, dropdown
|
|
34
|
+
|
|
35
|
+
When you use **Python Code Audit**, you are in control.
|
|
36
|
+
|
|
37
|
+
No AI agent should decide what is necessary — only you fully understand your design and its complete context.
|
|
38
|
+
|
|
39
|
+
You should carefully evaluate all reported weaknesses.
|
|
40
|
+
|
|
41
|
+
Not every issue requires fixing; depending on your program and the environment in which it operates, **some detected weaknesses may not be relevant**.
|
|
42
|
+
|
|
43
|
+
However, it is important to document your decisions and inform your users about the design choices you have made and the rationale behind them.
|
|
44
|
+
:::
|
|
45
|
+
|
|
18
46
|
* Send me a line that you use this tool within your company.
|
|
47
|
+
|
|
19
48
|
* [Contribute](CONTRIBUTE)
|
|
20
49
|
|
|
21
50
|
Guideline to contribute:
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Introduction
|
|
2
2
|
|
|
3
|
+
[](https://github.com/nocomplexity/codeaudit)
|
|
3
4
|
[](https://www.bestpractices.dev/projects/10970)
|
|
4
5
|
[](https://pypi.org/project/codeaudit)
|
|
6
|
+
[](https://nocomplexity.com/documents/codeaudit/intro.html)
|
|
7
|
+
[](https://nocomplexity.com/documents/codeaudit/license.html)
|
|
5
8
|
|
|
6
9
|

|
|
7
10
|
|
|
@@ -6,7 +6,11 @@ Open accessible information should not available as easy as possible without bor
|
|
|
6
6
|
|
|
7
7
|
So I choose to use a Creative Commons Attribution-ShareAlike License for documentation. This license allows you to freely use and share all the information as long as you follow the simple terms that come with this open access license. Using this license creates a brighter future for us all.
|
|
8
8
|
|
|
9
|
-
For the **
|
|
9
|
+
For the **Python Code Audit** tool all code is available under the FOSS (Free and Open Source Software) GPLv3 license.
|
|
10
|
+
Transparency builds trust. Openness is key.
|
|
11
|
+
|
|
12
|
+
You should only use [open security solutions (products, methods, and documentation)](https://nocomplexity.com/documents/securitysolutions/intro.html) that are open and can be improved so that we all benefit.
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
## Documentation license
|
|
12
16
|
|
|
@@ -55,7 +59,7 @@ material.
|
|
|
55
59
|
## Software License
|
|
56
60
|
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
**Python Code Audit** is a Python program to check for security weaknesses in Python files.
|
|
59
63
|
|
|
60
64
|
Copyright (C) 2025 BM-Support.org Foundation and Maikel Mardjan.
|
|
61
65
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Project Philosophy
|
|
2
|
+
|
|
3
|
+
The rapid growth and increasing complexity of Python-based web applications and systems have made robust security testing more important than ever.
|
|
4
|
+
|
|
5
|
+
To strengthen cyber security, we must make protection both **better and simpler** — simpler to use, simpler to maintain, and simpler to understand.
|
|
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.
|
|
8
|
+
|
|
9
|
+
Security validation for Python code should be **fast, straightforward, and effective**.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
However, there are almost no **high-quality Free and Open Source (FOSS)** Static Application Security Testing (SAST) tools available for Python.
|
|
13
|
+
|
|
14
|
+
## Design Approach and Solution
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
We believe that static security testing of Python code should be carried out more frequently and to a higher standard — but it should also be **extremely simple for everyone** to perform. Whether you’re a professional developer or an occasional Python user, **anyone** should be able to run a SAST test quickly and easily.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Python Code Audit is built on strong design principles:
|
|
21
|
+
* **Better be safe than sorry!** **Python Code Audit** takes a defensive security approach.
|
|
22
|
+
|
|
23
|
+
* **Local first**: No data leakage and no reliance on third-party services. Security should never be outsourced to a “black box” environment.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
* **Simple to use**: Designed for ease of use by anyone, regardless of experience level.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
* **Simple to extend**: Easy to adapt and build upon for future needs.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
* **Simple to maintain**: We follow [0Complexity design principles](https://nocomplexity.com/documents/0complexity/abstract.html): simplicity enhances security. This means minimising dependencies and keeping both design and implementation straightforward and transparent.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
* **Transparent**: All code is released under a FOSS (Free and Open Source Software) [licence](license). Transparency builds trust.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
* **Trust is good, but validation is better**: The tool validates against numerous common weaknesses often found in Python code.
|
|
39
|
+
|
|
40
|
+
* **Limited scope**: No tool can do everything well. Complex checks such as SQL injection detection, TLS certificate validation, or cryptographic misuse analysis are intentionally out of scope. These areas are difficult to automate reliably and often create a false sense of security. Instead, we focus on delivering a **simple, trustworthy security tool** that performs its defined tasks exceptionally well — without compromise.
|
|
41
|
+
|
|
42
|
+
* **You are in charge**: No AI agent should decide what is needed — only you fully understand the context. The tool is there to assist, but it remains **your responsibility** to determine whether a weakness could develop into a vulnerability that requires fixing.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Read our Manifesto
|
|
46
|
+
|
|
47
|
+
:::{admonition} Cyber security protection can be much better and simpler.
|
|
48
|
+
:class: tip
|
|
49
|
+
[**Read our Manifesto**](https://nocomplexity.com/simplifysecurity-manifesto/)
|
|
50
|
+
|
|
51
|
+
:::
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
@@ -61,16 +61,13 @@ codeaudit
|
|
|
61
61
|
This will show:
|
|
62
62
|
|
|
63
63
|
```text
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
| |___| (_) | (_| | __/ (_| | |_| | (_| | | |_
|
|
70
|
-
\_____\___/ \__,_|\___|\__,_|\__,_|\__,_|_|\__|
|
|
71
|
-
--------------------------------------------------
|
|
64
|
+
----------------------------------------------------
|
|
65
|
+
_ __ _
|
|
66
|
+
|_) \/_|_|_ _ __ / _ _| _ |_| _| o _|_
|
|
67
|
+
| / |_| |(_)| | \__(_)(_|(/_ | ||_|(_| | |_
|
|
68
|
+
----------------------------------------------------
|
|
72
69
|
|
|
73
|
-
|
|
70
|
+
Python Code Audit - A modern Python security source code analyzer based on distrust.
|
|
74
71
|
|
|
75
72
|
Commands to evaluate Python source code:
|
|
76
73
|
Usage: codeaudit COMMAND [PATH or FILE] [OUTPUTFILE]
|
|
@@ -78,12 +75,11 @@ Usage: codeaudit COMMAND [PATH or FILE] [OUTPUTFILE]
|
|
|
78
75
|
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.
|
|
79
76
|
|
|
80
77
|
Commands:
|
|
81
|
-
overview Reports
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
version Prints the module version. Use [-v] [--v] [-version] or [--version].
|
|
78
|
+
overview Reports complexity and statistics for Python files in a project directory.
|
|
79
|
+
filescan Scans Python projects/files, reporting potential security weaknesses.
|
|
80
|
+
modulescan Reports module vulnerability information.
|
|
81
|
+
checks Creates an HTML report of all implemented security checks.
|
|
82
|
+
version Prints the module version. Or use codeaudit [-v] [--v] [-version] or [--version].
|
|
87
83
|
|
|
88
84
|
Use the Codeaudit documentation to check the security of Python programs and make your Python programs more secure!
|
|
89
85
|
Check https://simplifysecurity.nocomplexity.com/
|
|
@@ -22,8 +22,10 @@ classifiers = [
|
|
|
22
22
|
"Topic :: Software Development :: Quality Assurance",
|
|
23
23
|
"Development Status :: 4 - Beta",
|
|
24
24
|
"Programming Language :: Python",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
25
26
|
"Programming Language :: Python :: 3.12",
|
|
26
27
|
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Programming Language :: Python :: 3.14",
|
|
27
29
|
]
|
|
28
30
|
|
|
29
31
|
|
|
@@ -21,6 +21,7 @@ Insecure Hashing Algorithm,hashlib.sha1,High,SHA-1 is cryptographically broken a
|
|
|
21
21
|
Logging Configuration,logging.config,Medium,Parsing untrusted logging configurations can lead to vulnerabilities if not handled correctly.
|
|
22
22
|
Pickle Usage,pickle.loads,High,Deserializing untrusted data with `pickle` can lead to arbitrary code execution.
|
|
23
23
|
Pickle Usage,pickle.load,High,Deserializing untrusted data with `pickle` can lead to arbitrary code execution.
|
|
24
|
+
Pickle Usage,pickle.Unpickler,High,Deserializing untrusted data with `pickle` can lead to arbitrary code execution.
|
|
24
25
|
OS Execution,os.system,High,Direct OS function calls can have significant security implications and require careful review.
|
|
25
26
|
OS Execution,os.execl,High,Direct OS function calls can have significant security implications and require careful review.
|
|
26
27
|
OS Execution,os.execle,High,Direct OS function calls can have significant security implications and require careful review.
|
|
@@ -51,8 +52,15 @@ Base64 Encoding ,base64,Low,"Base64 encoding is not for security. It only visual
|
|
|
51
52
|
XML-RPC Client,xmlrpc.client,High,Vulnerable to denial-of-service via decompression bombs.
|
|
52
53
|
XML-RPC Server,xmlrpc.server.SimpleXMLRPCServer,High,Vulnerable to denial-of-service via decompression bombs.
|
|
53
54
|
Cryptographically Unsafe Randomness,random.random,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
55
|
+
Cryptographically Unsafe Randomness,random.Random,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
56
|
+
Cryptographically Unsafe Randomness,random.randrange,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
57
|
+
Cryptographically Unsafe Randomness,random.randint,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
58
|
+
Cryptographically Unsafe Randomness,random.uniform,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
59
|
+
Cryptographically Unsafe Randomness,random.triangular,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
54
60
|
Cryptographically Unsafe Randomness,random.seed,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
61
|
+
Cryptographically Unsafe Randomness,random.randbytes,Low,The pseudo-random generators in this module are not suitable for security purposes.
|
|
55
62
|
Shelve Usage,shelve.open,High,"The `shelve` module uses `pickle` internally, making it unsafe for untrusted data."
|
|
63
|
+
Shelve Usage,shelve.DbfilenameShelf,High,"The `shelve` module uses `pickle` internally, making it unsafe for untrusted data."
|
|
56
64
|
Unsafe Deserialization: multiprocessing,connection.recv,High,"Uses pickle, which can execute arbitrary code when receiving data. "
|
|
57
65
|
Unsafe Deserialization: multiprocessing,multiprocessing.connection.Connection,High,Relies on pickle; dangerous with untrusted data.
|
|
58
66
|
Zipfile Extraction,zipfile.ZipFile,High,Vulnerable to path traversal attacks if used with untrusted archives.
|
|
@@ -30,7 +30,7 @@ from codeaudit import __version__
|
|
|
30
30
|
|
|
31
31
|
from importlib.resources import files
|
|
32
32
|
|
|
33
|
-
DISCLAIMER_TEXT = "<p><b>Disclaimer:</b><i>This SAST tool
|
|
33
|
+
DISCLAIMER_TEXT = "<p><b>Disclaimer:</b><i>This SAST tool <b>Python Code Audit</b> provides a powerful, automatic security analysis for Python source code. However, it's not a substitute for human review in combination with business knowledge. Undetected vulnerabilities may still exist. <b>There is, and will never be, a single security tool that gives 100% automatic guarantees</b>. By reporting any issues you find, you contribute to a better tool for everyone.</i>"
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
SIMPLE_CSS_FILE = files('codeaudit') / 'simple.css'
|
|
@@ -38,7 +38,7 @@ SIMPLE_CSS_FILE = files('codeaudit') / 'simple.css'
|
|
|
38
38
|
DEFAULT_OUTPUT_FILE = 'codeaudit-report.html'
|
|
39
39
|
|
|
40
40
|
def overview_report(directory, filename=DEFAULT_OUTPUT_FILE):
|
|
41
|
-
"""Reports
|
|
41
|
+
"""Reports complexity and statistics for Python files in a project directory.
|
|
42
42
|
|
|
43
43
|
Parameters:
|
|
44
44
|
directory (str): Path to the directory to scan.
|
|
@@ -104,7 +104,7 @@ def overview_report(directory, filename=DEFAULT_OUTPUT_FILE):
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
def scan_report(input_path , filename=DEFAULT_OUTPUT_FILE):
|
|
107
|
-
"""Scans Python files
|
|
107
|
+
"""Scans Python projects/files, reporting potential security weaknesses.
|
|
108
108
|
|
|
109
109
|
This function performs security validations on the specified file or directory,
|
|
110
110
|
formats the results into an HTML report, and writes the output to an HTML file.
|
|
@@ -119,7 +119,7 @@ def scan_report(input_path , filename=DEFAULT_OUTPUT_FILE):
|
|
|
119
119
|
Returns:
|
|
120
120
|
None - A HTML report is written as output
|
|
121
121
|
"""
|
|
122
|
-
|
|
122
|
+
# Check if the input is a valid directory or a single valid Python file
|
|
123
123
|
file_path = Path(input_path)
|
|
124
124
|
if file_path.is_dir():
|
|
125
125
|
directory_scan_report(input_path , filename ) #create a package aka directory scan report
|
|
@@ -12,20 +12,14 @@ def test_shelve_usage():
|
|
|
12
12
|
|
|
13
13
|
# validation1.py is in a subfolder:
|
|
14
14
|
validation_file_path = current_file_directory / "validationfiles" / "shelve.py"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
#We run now constructs based on definitions!
|
|
18
|
-
# constructs = {'random.random',
|
|
19
|
-
# 'random.seed'}
|
|
20
15
|
|
|
21
16
|
result = perform_validations(validation_file_path)
|
|
22
17
|
|
|
23
|
-
#actual_data = find_constructs(source, constructs)
|
|
18
|
+
# actual_data = find_constructs(source, constructs)
|
|
24
19
|
actual_data = result['result']
|
|
25
20
|
|
|
26
21
|
# This is the expected dictionary
|
|
27
|
-
expected_data = {
|
|
28
|
-
}
|
|
22
|
+
expected_data = {"shelve.DbfilenameShelf": [7], "shelve.open": [3]}
|
|
29
23
|
|
|
30
24
|
# Assert that the actual data matches the expected data
|
|
31
25
|
assert actual_data == expected_data
|
|
@@ -12,19 +12,22 @@ def test_random_usage():
|
|
|
12
12
|
# validation1.py is in a subfolder:
|
|
13
13
|
validation_file_path = current_file_directory / "validationfiles" / "random.py"
|
|
14
14
|
|
|
15
|
-
source = read_in_source_file(validation_file_path)
|
|
16
|
-
|
|
17
|
-
# constructs = {'random.random',
|
|
18
|
-
# 'random.seed'}
|
|
19
|
-
|
|
20
15
|
result = perform_validations(validation_file_path)
|
|
21
16
|
|
|
22
|
-
#actual_data = find_constructs(source, constructs)
|
|
23
|
-
actual_data = result[
|
|
17
|
+
# actual_data = find_constructs(source, constructs)
|
|
18
|
+
actual_data = result["result"]
|
|
24
19
|
|
|
25
20
|
# This is the expected dictionary
|
|
26
|
-
expected_data = {
|
|
27
|
-
|
|
21
|
+
expected_data = {
|
|
22
|
+
"random.Random": [19],
|
|
23
|
+
"random.randrange": [22],
|
|
24
|
+
"random.randint": [24],
|
|
25
|
+
"random.uniform": [26],
|
|
26
|
+
"random.triangular": [28],
|
|
27
|
+
"random.randbytes": [31],
|
|
28
|
+
"random.random": [14],
|
|
29
|
+
"random.seed": [15],
|
|
30
|
+
}
|
|
28
31
|
|
|
29
32
|
# Assert that the actual data matches the expected data
|
|
30
|
-
assert actual_data == expected_data
|
|
33
|
+
assert actual_data == expected_data
|
|
@@ -3,6 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
|
|
4
4
|
from codeaudit.filehelpfunctions import read_in_source_file
|
|
5
5
|
from codeaudit.issuevalidations import find_constructs
|
|
6
|
+
from codeaudit.security_checks import perform_validations
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def test_xml_usage():
|
|
@@ -83,20 +84,18 @@ def test_httpserver_usage():
|
|
|
83
84
|
|
|
84
85
|
def test_pickle_usage():
|
|
85
86
|
current_file_directory = Path(__file__).parent
|
|
86
|
-
|
|
87
|
-
# validation1.py is in a subfolder:
|
|
87
|
+
|
|
88
88
|
validation_file_path = current_file_directory / "validationfiles" / "pickle.py"
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
|
|
91
|
+
result = perform_validations(validation_file_path)
|
|
92
|
+
#actual_data = find_constructs(source, constructs)
|
|
93
|
+
actual_data = result['result']
|
|
94
|
+
# This is the expected dictionary
|
|
91
95
|
|
|
92
|
-
|
|
93
|
-
'pickle.loads'}
|
|
94
|
-
actual_data = find_constructs(source, constructs)
|
|
96
|
+
expected_data = {'pickle.loads': [3, 12], 'pickle.Unpickler': [16], 'pickle.load': [7]}
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
'pickle.loads': [3,12] }
|
|
99
|
-
|
|
100
|
-
# Assert that the actual data matches the expected data
|
|
98
|
+
|
|
99
|
+
# # Assert that the actual data matches the expected data
|
|
101
100
|
assert actual_data == expected_data
|
|
102
101
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import pickle
|
|
3
|
+
pickle.loads(b"cos\nsystem\n(S'echo hello world'\ntR.")
|
|
4
|
+
|
|
5
|
+
def donotdothis():
|
|
6
|
+
with open('data.pickle', 'rb') as f:
|
|
7
|
+
data = pickle.load(f)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
from pickle import loads as importmalware
|
|
11
|
+
|
|
12
|
+
importmalware('mysafefile.txt')
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#The pickle.Unpickler class is the deserialization engine of the pickle module.
|
|
16
|
+
unpickler = pickle.Unpickler(pickled_data_stream)
|
|
17
|
+
|
|
18
|
+
# Call the load() method to deserialize the data
|
|
19
|
+
unpickled_data = unpickler.load()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import random
|
|
3
|
+
|
|
4
|
+
def generate_random_float():
|
|
5
|
+
"""
|
|
6
|
+
Generates a random floating-point number between 0.0 (inclusive) and 1.0 (exclusive).
|
|
7
|
+
|
|
8
|
+
The random.random() function from Python's built-in 'random' module is used
|
|
9
|
+
to produce this number.
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
float: A random float between 0.0 and 1.0.
|
|
13
|
+
"""
|
|
14
|
+
random_number = random.random()
|
|
15
|
+
random.seed(23)
|
|
16
|
+
return random_number
|
|
17
|
+
|
|
18
|
+
# Create a Random instance with a fixed seed for reproducibility
|
|
19
|
+
rng = random.Random(42)
|
|
20
|
+
|
|
21
|
+
# Generate a random number from 0 up to (but not including) 10
|
|
22
|
+
num1 = random.randrange(10)
|
|
23
|
+
|
|
24
|
+
num = random.randint(1, 10)
|
|
25
|
+
|
|
26
|
+
num_uni = random.uniform(1.0, 10.0)
|
|
27
|
+
|
|
28
|
+
num_tri = random.triangular(1.0, 10.0, 5.0)
|
|
29
|
+
|
|
30
|
+
# Generate a larger block of random bytes (e.g., 16 bytes)
|
|
31
|
+
more_data = random.randbytes(16)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import random
|
|
3
|
-
|
|
4
|
-
def generate_random_float():
|
|
5
|
-
"""
|
|
6
|
-
Generates a random floating-point number between 0.0 (inclusive) and 1.0 (exclusive).
|
|
7
|
-
|
|
8
|
-
The random.random() function from Python's built-in 'random' module is used
|
|
9
|
-
to produce this number.
|
|
10
|
-
|
|
11
|
-
Returns:
|
|
12
|
-
float: A random float between 0.0 and 1.0.
|
|
13
|
-
"""
|
|
14
|
-
random_number = random.random()
|
|
15
|
-
random.seed(23)
|
|
16
|
-
return random_number
|
|
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
|
|
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
|