Skip to content

Commit 3ba2c48

Browse files
committed
first commit
0 parents  commit 3ba2c48

60 files changed

Lines changed: 3610 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Python Security Handbook
2+
3+
**A practical, no-nonsense guide to writing secure Python code in 2026 and beyond.**
4+
5+
![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white)
6+
![License](https://img.shields.io/github/license/nocomplexity/pythonsecurity)
7+
![Stars](https://img.shields.io/github/stars/nocomplexity/pythonsecurity)
8+
9+
This open-source book covers **Python Security Fundamentals** with a strong focus on real-world practices, essential security tools, and actionable security recipes.
10+
11+
## What You'll Learn
12+
13+
- Core security principles every Python developer should know
14+
- How to secure common Python patterns and libraries
15+
- Secure coding techniques
16+
- Essential open-source security tools for Python
17+
- Practical **security recipes** – step-by-step solutions to common security challenges
18+
- Dependency management, supply chain security, and runtime protection
19+
- Static Application Security Testing (SAST) and Software Composition Analysis (SCA)
20+
21+
22+
## Key Features
23+
24+
- **Fundamentals First** – Clear explanations of weaknesses, vulnerabilities, and threats
25+
- **Practical Recipes** – Ready-to-use, secure code patterns
26+
- **Tool Recommendations** – Focused on the best Free and Open Source (FOSS) tools
27+
- **Realistic Advice** – Balanced between theory and production reality
28+
- **Regularly Updated** – Keeping pace with the evolving Python and security landscape
29+
30+
31+
## Tools Featured
32+
33+
- **[Python Code Audit](https://github.com/nocomplexity/codeaudit)** – Best-in-class open-source Python SAST scanner
34+
- Dependency scanners (pip-audit, uv, etc.)
35+
- And other essential security tools
36+
37+
## How to Read This Book
38+
39+
You can read the book online at:
40+
👉 **[https://nocomplexity.github.io/pythonsecurity/](https://nocomplexity.github.io/pythonsecurity/)**
41+
42+
## Contributing
43+
44+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
45+
46+
Simple ways to help:
47+
- Star the repository
48+
- Share with fellow Python developers
49+
- Report issues or suggest improvements
50+
- Submit pull requests for new recipes or corrections
51+
52+
## License
53+
54+
This book is licensed under **CC-BY 4.0** – you are free to share and adapt with attribution.
55+
56+
---
57+
58+
**Made with ❤️ to [Simplify Cyber Security](https://nocomplexity.com/simplifysecurity-manifesto/) Challenges**
59+
60+
Want to support the project? Consider [sponsoring](sponsors.md) or making a [donation](contribute.md).
61+
```
62+

‎_static/cover_securitybydesign.jpg‎

339 KB
Loading

‎_static/nocxstyle.css‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Minor css adjustments for the book-theme - Jupyter Book 2 - Not perfect as adjusting style is still in development for JupterBook2! */
2+
.text-blue-800 {
3+
--tw-text-opacity: 1;
4+
color: #ff0000;
5+
}
6+
7+
.text-gray-600 {
8+
--tw-text-opacity: 1;
9+
color: #ff0000;
10+
}
11+
12+
.text-gray-500 {
13+
--tw-text-opacity: 1;
14+
color: black;
15+
}
16+
17+
a.button, button.button, cite.button a, span.button {
18+
white-space: nowrap;
19+
--tw-bg-opacity: 1;
20+
background-color: #ff0000;
21+
}

‎_static/nocxstyle2026.css‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Minor css adjustments for the book-theme - Jupyter Book 2 - Not perfect as adjusting style is still in development for JupterBook2! */
2+
.text-blue-800 {
3+
--tw-text-opacity: 1;
4+
color: #ff0000;
5+
}
6+
7+
.text-gray-600 {
8+
--tw-text-opacity: 1;
9+
color: #ff0000;
10+
}
11+
12+
.text-gray-500 {
13+
--tw-text-opacity: 1;
14+
color: black;
15+
}
16+
17+
a.button, button.button, cite.button a, span.button {
18+
white-space: nowrap;
19+
--tw-bg-opacity: 1;
20+
background-color: #ff0000;
21+
}

‎aboutnocx.md‎

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# About NO|Complexity
2+
3+
> Trust in security software is not only about the software itself, but also about the people and their beliefs. People's core principles do shape software and communities around it.
4+
5+
## Who is Behind NO|Complexity?
6+
7+
[NO|Complexity.com](https://nocomplexity.com/) is dedicated to solve business IT challenges in a rapidly evolving world. I’m Maikel Mardjan, and I believe that many business IT solutions are overly complex. Simple solutions have many advantages. But creating simple solutions is not simple. Tackling complexity challenges requires an unique combination of expertise, skills and people.
8+
9+
10+
With extensive experience across multiple architecture disciplines — including IT Architect, Security Architect, Business Architect, and Enterprise Architect — I have helped numerous organisations design secure and resilient IT systems with a strong emphasis on simplicity and practicality.
11+
12+
I hold two Master’s degrees: an MSc in Business Studies from the University of Groningen and an MSc in Electrical Engineering from Delft University of Technology. I am also TOGAF 9 Certified and hold the CISSP (Certified Information Systems Security Professional) certification.
13+
14+
Finding genuinely capable security professionals is not primarily about collecting industry certifications or academic qualifications. What truly matters is practical, **hands-on experience**. In cybersecurity, one of the most valuable traits is the ability to keep learning. While technologies, tools, and industry hypes constantly evolve, the **fundamental principles of information security have remained remarkably consistent over the past three decades.**
15+
16+
17+
Currently, I lead initiatives at [NO|Complexity.com](https://nocomplexity.com/), an innovative IT company focused on straightforward solutions based in the Netherlands.
18+
19+
20+
Certifications such as ISO 27001 and other industry-mandated standards play an important role in establishing structure and governance. However, they do not, by themselves, protect your information or systems.
21+
22+
True information security is delivered by skilled people supported by effective open source tools and processes. Certifications and standards are helpful frameworks, but they are **not a substitute** for experienced professionals who understand the real-world challenges of securing complex Python (and other) environments.
23+
24+
25+
I created **[Python Code Audit](https://nocomplexity.com/codeaudit/)** because I believe existing tools fall short of what modern Python security demands. Python powers an enormous range of applications. From web services and data science to automation and AI and has become one of the most widely used programming languages in the world.
26+
27+
In the security industry, we often use complex terminology around risks, processes, and metrics. There is frequently a lack of transparency, and too much reliance on opaque, difficult-to-maintain security products.
28+
29+
I strongly believe that good cybersecurity tools should be **open source**, ideally under the GPL licence. While open source is not a guarantee of superiority over commercial solutions, genuine security begins with **trust**. Real Open source tools offer full transparency. You can inspect exactly how they work, what they detect, and their limitations.
30+
31+
A single tool will never solve all cybersecurity challenges. Effective security is always a combination of good tools, robust processes, and skilled people.
32+
33+
I am an active member of [OWASP](owasp.org), a community where security professionals collaborate to share knowledge, experiences, and practical solutions with the goal of making our digital world safer.
34+
35+
36+
37+
38+
+++{"no-pdf": true}
39+
40+
## Other NO|Complexity Publications
41+
42+
### Cyber Security
43+
44+
% Start cards grid
45+
::::{grid} 1 1 2 3
46+
47+
:::{card}
48+
:link: https://nocomplexity.com/codeaudit
49+
:header: 😀 **Python Code Audit**
50+
51+
Modern Python source code security analyser. A local-first, FOSS tool that makes security checks simple for everyone.
52+
:::
53+
54+
55+
:::{card}
56+
:link: https://nocomplexity.com/documents/securityarchitecture/introduction.html
57+
:header: 🤩 **Open Security Reference Architecture**
58+
Cyber security can still be simple and effective.
59+
Use this Playbook to create better and faster security solutions for your security use case.
60+
:::
61+
62+
:::{card}
63+
:link: https://nocomplexity.com/documents/securitybydesign/intro.html
64+
:header: 😋 **Security By Design**
65+
66+
Security by design is a proven method to develop products that are less vulnerable for cyber security threats.
67+
Master the topic quickly with this eBook.
68+
:::
69+
70+
:::{card}
71+
:link: https://nocomplexity.com/documents/securitysolutions/intro.html
72+
:header: 🙃 **Open Security Solutions**
73+
74+
Given the vast array of FOSS cybersecurity products available, this publication offers a handcrafted curated selection.
75+
:::
76+
77+
:::{card}
78+
:link: https://nocomplexity.com/documents/reports/SimplifySecurity.pdf
79+
:header: 😻 **Simplify Cyber Manifest**
80+
81+
A manifesto to revolutionize cybersecurity through simplification.
82+
:::
83+
84+
85+
:::{card}
86+
:link: https://nocomplexity.com/documents/simplifysecurity/intro.html#
87+
:header: 😉 **Simplify Security**
88+
89+
Find open simple cyber solutions that work. Simplify cyber security to accelerate its effectiveness.
90+
:::
91+
92+
93+
:::{card}
94+
:link: https://nocomplexity.com/documents/simplifyprivacy/intro.html
95+
:header: 😀 **Simplify Digital Privacy**
96+
This digital Playbook is all about protecting *your* digital privacy.
97+
:::
98+
99+
::::
100+
% End of Cards grid
101+
102+
### Machine Learning - AI and Tools
103+
104+
% Start cards grid
105+
::::{grid} 1 1 2 3
106+
107+
108+
:::{card}
109+
:link: https://nocomplexity.com/documents/fossml/abstract.html
110+
:header: 🥸 **Free and Open Machine Learning**
111+
112+
Freedom to control machine learning and AI technology is not self-evident. This Playbook gives you full control.
113+
:::
114+
115+
116+
:::{card}
117+
:link: https://nocomplexity.com/documents/jupyterlab/intro.html
118+
:header: 🤓 **Mastering JupyterLab**
119+
120+
Supercharge your data science journey with Mastering JupyterLab. Use this Playbook to streamline your workflow and boost productivity.
121+
:::
122+
123+
124+
:::{card}
125+
:link: https://nocomplexity.com/documents/pythonbook/introduction.html
126+
:header: 😋 **Master Python for AI/ML**
127+
128+
Python programming skills are essential for architects, engineers, and even managers in the IT industry.
129+
Become a Python master to do more with AI/ML applications.
130+
:::
131+
132+
::::
133+
% End of Cards grid
134+
135+
136+
### General
137+
138+
% Start cards grid
139+
::::{grid} 1 1 2 3
140+
141+
142+
:::{card}
143+
:link: https://nocomplexity.com/documents/arplaybook/introduction.html
144+
:header: 😎 **Architecture Playbook**
145+
146+
A playbook providing practical tools to help create architectures and designs more quickly and effectively.
147+
:::
148+
149+
:::{card}
150+
:link: https://nocomplexity.com/simplifyit/
151+
:header: 😲 **Simplify IT**
152+
153+
This is an eBook with proven scientific tools and frameworks to help you effectively solve complex IT problems and gain a comprehensive understanding of IT systems in a business context.
154+
:::
155+
156+
157+
::::
158+
% End of Cards grid
159+
160+
161+
+++
162+
% End of part that will not be shown in PDF - automatic transform will not work - status May 2026 -

‎appendices/definitions.md‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Key Definitions and Python Security Terms
3+
short_title: Definitions
4+
---
5+
6+
7+
Clear and consistent terminology is essential in cybersecurity. However, the industry often suffers from hype, overlapping definitions, and vendor-specific jargon. In this book, the following definitions are used for precision and clarity within the Python security context.
8+
9+
## Core Python Packaging Terms
10+
11+
**Import Package**
12+
An import package is a Python module (or collection of modules) that can be imported using the `import` statement.
13+
14+
**Distribution Package**
15+
A distribution package is a versioned archive of software that can be installed using tools such as `pip`. It is often synonymous with a “project” on PyPI. Distribution packages typically consist of one or more import packages (modules) bundled together.
16+
17+
> **Security Note**: Every distribution package contains code — either pure Python modules or extensions written in other languages (e.g., C, C++, Rust, or Go). From a security perspective, **all dependencies**, both direct and transitive, should be regularly scanned for vulnerabilities.
18+
19+
**Python Module**
20+
A Python module is a single `.py` file (or compiled equivalent) containing Python code that can be imported into other programs.
21+
22+
**Python Library**
23+
The term “library” has no strict formal definition in Python. It is commonly used interchangeably with “module” or “package”. The **Python Standard Library** is the best-known example of a Python library.
24+
25+
**Python Standard Library (PSL)**
26+
The Python Standard Library is the collection of modules and packages included with every standard Python installation. It provides broad functionality for common tasks (file I/O, networking, cryptography, data processing, etc.), making Python a “batteries-included” language. While generally robust, certain functions within the PSL can introduce security weaknesses depending on how they are used.
27+
28+
**Standard Python Module**
29+
A module that is included with the default Python distribution as part of the Python Standard Library. Although these modules undergo extensive review, some APIs can still lead to vulnerabilities (e.g., unsafe use of `eval()`, `pickle`, or XML parsers). Static Application Security Testing (SAST) is recommended to identify and mitigate such risks in your codebase.
30+
31+
## Security Concepts
32+
33+
**Weakness**
34+
A condition in software, firmware, hardware, or a service that, under certain circumstances, could contribute to the introduction of a vulnerability. A weakness is not necessarily exploitable on its own.
35+
36+
**Vulnerability**
37+
An exploitable weakness. A vulnerability is a specific flaw that an attacker can leverage to cause harm, such as unauthorised access, data leakage, or remote code execution.
38+
39+
**Threat**
40+
An external event, actor, or action that has the potential to exploit a vulnerability. It represents the intent or mechanism of harm.
41+
42+
**Advanced Persistent Threat (APT)**
43+
An Advanced Persistent Threat occurs when an attacker successfully compromises a network, establishes a long-term presence on one or more systems, and extracts data over an extended period. Some APTs eventually reveal themselves through destructive actions (e.g., WannaCry ransomware or Stuxnet), but most aim to remain undetected for as long as possible.
44+
45+
**Static Application Security Testing (SAST)**
46+
SAST is a white-box security testing methodology that analyses source code, documentation, and design artefacts for potential security weaknesses without executing the program. In Python projects, SAST tools scan code for risky patterns such as unsafe use of `eval()`, insecure deserialisation, or improper input validation.
47+
48+
**Software Composition Analysis (SCA)**
49+
SCA is the process of identifying and evaluating the security risks associated with open-source and third-party dependencies in a project. While valuable, SCA is limited by the fact that many vulnerabilities in dependencies remain unreported or undiscovered. SCA should therefore be treated as one layer within a broader security strategy, not a complete solution.
50+

‎appendices/references.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: References
3+
short_title: References
4+
---
5+
6+
7+
This section provides key resources that are particularly valuable when developing secure Python applications.
8+
9+
## Official Python Documentation
10+
11+
- **[Python Security Considerations](https://docs.python.org/3/library/security_warnings.html)**
12+
The official Python documentation that summarises important security considerations and known risks for modules in the Python Standard Library (PSL). Every serious Python SAST tool should align with these warnings.
13+
14+
## Additional Recommended References
15+
16+
- **[Simplify Python – References](https://nocomplexity.com/documents/pythonbook/generatedfiles/overview.html#references)**
17+
A carefully curated, free, and openly licensed (CC-BY) collection of high-quality references for professional Python developers.
18+

0 commit comments

Comments
 (0)