Skip to content

Commit ed9675d

Browse files
authored
Fixes issue #839 (#848)
co-author: myteron and hubert. Signed-off-by: emcdtho <[email protected]>
1 parent e3c85e7 commit ed9675d

File tree

10 files changed

+51
-25
lines changed

10 files changed

+51
-25
lines changed

docs/Secure-Coding-Guide-for-Python/CONTRIBUTING.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributor Guide
22

3-
This guide provides an overview of how you can help, the standards we adhere to, and the steps to get your contributions reviewed for the subpages in [wg-best-practices-os-developers/docs/Secure-Coding-Guide-for-Python/](https://github.com/ossf/wg-best-practices-os-developers/docs/Secure-Coding-Guide-for-Python/)
3+
This guide provides an overview of how you can help, the standards we adhere to, and the steps to get your contributions reviewed for the subpages in [wg-best-practices-os-developers/docs/Secure-Coding-Guide-for-Python/](https://github.com/ossf/wg-best-practices-os-developers/tree/main/docs/Secure-Coding-Guide-for-Python/).
44

55
## Code of Conduct
66

@@ -82,15 +82,15 @@ Join us to explore how this resource can become an indispensable part of your se
8282

8383
## Documentation Style
8484

85-
* Bottom Line Up Front (BLUF), conclusion is in the first sentence of a rule
85+
* Bottom Line Up Front (BLUF), conclusion is in the first sentence of a rule
8686
* Keep It Small and Simple (KISS)
8787
* Working code examples
8888
* Academic in wording whilst aiming for low word count.
8989
* No fluff, "in software security it is important to be aware of ...."
9090
* Use imperative "do x and y to ensure z" instead of vague wording "might want to, could be a good idea..."
9191
* bibliography, follow the Harvard reference guide
9292

93-
A template for a rule is available here: [README_TEMPLATE.md](README_TEMPLATE.md) with inline documentation on each section.
93+
A template for a rule is available here: [README_TEMPLATE.md](templates/README_TEMPLATE.md) with inline documentation on each section.
9494

9595
Each rule should have:
9696

@@ -112,7 +112,7 @@ The guide is structed in two levels. The top level readme is to list all rules w
112112
The sublevel has an a individual rule with a single CWE where possible.
113113

114114
> [!NOTE]
115-
> We are aware that CWEs are not designed as 'read throughs'. Their numbering is not designed to become a step by step guide. The [Introduction to Multithreading and Multiprocessing](../Intro_to_multiprocessing_and_multithreading/readme.md) in Python is an example where we had to provide an alternative layout with three levels. Eventually we will have to shuffle the individual rules into a more suitable sequence.
115+
> We are aware that CWEs are not designed as 'read throughs'. Their numbering is not designed to become a step by step guide. The [Introduction to Multithreading and Multiprocessing](Intro_to_multiprocessing_and_multithreading/readme.md) in Python is an example where we had to provide an alternative layout with three levels. Eventually we will have to shuffle the individual rules into a more suitable sequence.
116116
> Same CWE number with different titles will also have to be fixed at some stage.
117117

118118
### From a author perspective
@@ -130,32 +130,32 @@ Example structure with mocked up data:
130130
./README.md
131131
./licenses/MIT.txt
132132
./licenses/CC-BY-4.0.txt
133-
133+
134134
./Concepts/Multithreading_Multiprocessing.md
135-
135+
136136
# Top level using Pillar CWE-707:
137137
./CWE-707/README.md
138-
138+
139139
# Second level representing a Rule is either a CWE of type Base, Variant or Class:
140140
./CWE-664/CWE-197/README.md
141141
./CWE-664/CWE-197/compliant01.py
142142
./CWE-664/CWE-197/example01.py
143143
./CWE-664/CWE-197/noncompliant01.py
144-
144+
145145
# Multiple rules matching one CWE of type Base, Variant or Class:
146146
./CWE-664/CWE-197/01/README.md
147147
./CWE-664/CWE-197/01/compliant01.py
148148
./CWE-664/CWE-197/01/noncompliant01.py
149-
149+
150150
# Rule matching no CWE of type Base, Variant, or Class:
151151
./CWE-707/XXX-000/README.md
152152
./CWE-707/XXX-000/noncompliant01.py
153153
./CWE-707/XXX-000/compliant01.py
154-
154+
155155
./CWE-707/XXX-001/README.md
156156
./CWE-707/XXX-001/noncompliant01.py
157157
./CWE-707/XXX-001/compliant01.py
158-
158+
159159
# Rule matching multiple CWEs of type Base, Variant or Class:
160160
./CWE-707/CWE-117/README.md
161161
./CWE-707/CWE-117/compliant01.py

docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ if __name__ == "__main__":
131131
|||
132132
|:---|:---|
133133
|[SEI CERT C Coding Standard](https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Coding+Standard)|[FIO30-C Exclude user input from format strings](https://wiki.sei.cmu.edu/confluence/display/c/FIO30-C.+Exclude+user+input+from+format+strings)|
134-
|[SEI CERT Perl Coding Standard](https://www.securecoding.cert.org/confluence/display/perl/CERT+Perl+Secure+Coding+Standard)|[IDS30-PL. Exclude user input from format strings](https://www.securecoding.cert.org/confluence/display/perl/IDS30-PL.+Exclude+user+input+from+format+strings)|
134+
|[SEI CERT Perl Coding Standard](https://wiki.sei.cmu.edu/confluence/display/perl/SEI+CERT+Perl+Coding+Standard)|[IDS30-PL. Exclude user input from format strings](https://www.securecoding.cert.org/confluence/display/perl/IDS30-PL.+Exclude+user+input+from+format+strings)|
135135
|[SEI CERT Coding Standard for Java](https://wiki.sei.cmu.edu/confluence/display/java/SEI+CERT+Oracle+Coding+Standard+for+Java)|[IDS06-J. Exclude unsanitized user input from format strings](https://wiki.sei.cmu.edu/confluence/display/java/IDS06-J.+Exclude+unsanitized+user+input+from+format+strings)|
136-
|[ISO/IEC TR 24772:2013](https://wiki.sei.cmu.edu/confluence/display/java/Rule+AA.+References#RuleAA.References-ISO/IECTR24772-2013)|Injection [RST]|
136+
|[ISO/IEC TR 24772:2013](https://wiki.sei.cmu.edu/confluence/display/java/Rule+AA.+References#RuleAA.References-ISO/IECTR24772-2013)|Injection RST|
137137
|[MITRE CWE Pillar](http://cwe.mitre.org/)|[CWE-664: Improper Control of a Resource Through its Lifetime (4.13) (mitre.org)](https://cwe.mitre.org/data/definitions/664.html)|
138138
|[MITRE CWE Base](http://cwe.mitre.org/)|[CWE-134, Uncontrolled Format String](http://cwe.mitre.org/data/definitions/134.html)|
139139

docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ print(Decimal("0.45"))
4949

5050
|||
5151
|:---|:---|
52-
|[Wikipedia 2025](en.wikipedia.org)|IEEE 754 [online]. Available from: [https://en.wikipedia.org/wiki/IEEE_754](https://en.wikipedia.org/wiki/IEEE_754)|
52+
|[Wikipedia 2025](https://en.wikipedia.org)|IEEE 754 [online]. Available from: [https://en.wikipedia.org/wiki/IEEE_754](https://en.wikipedia.org/wiki/IEEE_754)|
5353
|[Python docs](https://docs.python.org/3/)|decimal — Decimal fixed-point and floating-point arithmetic [online]. Available from: [https://docs.python.org/3/library/decimal.html](https://docs.python.org/3/library/decimal.html) [accessed 2 February 2025]|

docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Output from above example01.py:
3131
```bash
3232
foo = 50 = 00110010
3333
foo = 42 = 00101010
34-
34+
3535
foo << 2 = 11001000
3636
foo >> 2 = 00001100
3737
~foo = -0110011
@@ -92,7 +92,7 @@ The statement in `compliant01.py` clarifies the programmer's intention.
9292
print(8 * 4 + 10)
9393
```
9494
95-
It is recommended by *[CWE-191, Integer Underflow (Wrap or Wraparound)](../CWE-191/README.md)* to also check for under or overflow.
95+
It is recommended by *[CWE-191, Integer Underflow (Wrap or Wraparound)](../../CWE-191/README.md)* to also check for under or overflow.
9696
9797
## Non-compliant Code Example (Right Shift)
9898

docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ The `compliant01.py` does not use data that origins from a lesser trusted source
195195

196196
|||
197197
|:---|:---|
198-
|[MITRE CWE](http://cwe.mitre.org/)|Pillar: [CWE-707: Improper Neutralization](hhttps://cwe.mitre.org/data/definitions/707.html)|
199-
|[MITRE CWE](http://cwe.mitre.org/)|Base: [CWE-78, Improper Neutralization of Special Elements Used in an OS Command ("OS Command Injection")](https://cwe.mitre.org/data/definitions/000.html)|
198+
|[MITRE CWE](http://cwe.mitre.org/)|Pillar: [CWE-707: Improper Neutralization](https://cwe.mitre.org/data/definitions/707.html)|
199+
|[MITRE CWE](http://cwe.mitre.org/)|Base: [CWE-78, Improper Neutralization of Special Elements Used in an OS Command ("OS Command Injection")](https://cwe.mitre.org/data/definitions/78.html)|
200200
|[SEI CERT Coding Standard for Java](https://wiki.sei.cmu.edu/confluence/display/java/SEI+CERT+Oracle+Coding+Standard+for+Java)|[IDS07-J. Sanitize untrusted data passed to the Runtime.exec() method](https://wiki.sei.cmu.edu/confluence/display/java/IDS07-J.+Sanitize+untrusted+data+passed+to+the+Runtime.exec%28%29+method)|
201201
|[SEI CERT C Coding Standard](https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Coding+Standard)|[ENV03-C. Sanitize the environment when invoking external programs](https://wiki.sei.cmu.edu/confluence/display/c/ENV03-C.+Sanitize+the+environment+when+invoking+external+programs)|
202202
|[SEI CERT C Coding Standard](https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Coding+Standard)|[ENV33-C. Do not call system()](https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152177)|

docs/Secure-Coding-Guide-for-Python/readme.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Please join us, see [contributing](CONTRIBUTING.md)
1313

1414
## Disclaimer
1515

16-
Content comes __WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED__, as stated in the license text [CC-BY-4.0](LICENSE/CC-BY-4.0.txt) for documentation and [MIT](LICENSE/MIT.txt).
16+
Content comes __WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED__, as stated in the license text [CC-BY-4.0](../../LICENSES/CC-BY-4.0.txt) for documentation and [MIT](../../LICENSES/MIT.txt).
1717
Following or using the documentation and or code is at your own risk. Code examples are intended purely for educational use and not for products in parts or in full.
1818
Code examples are NOT to be used to cause harm of any kind to anyone or anything.
1919

@@ -61,7 +61,6 @@ It is __not production code__ and requires code-style or python best practices t
6161
|[CWE-681: Avoid an uncontrolled loss of precision when passing floating-point literals to a Decimal constructor.](CWE-664/CWE-681/01/README.md)||
6262
|[CWE-833: Deadlock](CWE-664/CWE-833/README.md)||
6363
|[CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')](CWE-664/CWE-843/.)|[CVE-2021-29513](https://www.cvedetails.com/cve/CVE-2021-29513),<br/>CVSSv3.1: __7.8__,<br/>EPSS: __00.05__ (05.11.2024)|
64-
|[XXX-005: Consider hash-based integrity verification of byte code files against their source code files](CWE-664/XXX-005/.)||
6564

6665
|[CWE-682: Incorrect Calculation](https://cwe.mitre.org/data/definitions/682.html)|Prominent CVE|
6766
|:---------------------------------------------------------------------------------------------------------------|:----|
@@ -118,5 +117,5 @@ It is __not production code__ and requires code-style or python best practices t
118117

119118
## License
120119

121-
* [CC-BY 4.0](LICENSE/CC-BY-4.0.txt) for documentation
122-
* [MIT](LICENSE/MIT.txt) for code snippets
120+
* [CC-BY 4.0](../../LICENSES/CC-BY-4.0.txt) for documentation
121+
* [MIT](../../LICENSES/MIT.txt) for code snippets

docs/Secure-Coding-Guide-for-Python/templates/README_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Introduction paragraph, expanding on the introduction sentence...
77
[*example01.py:*](example01.py)
88

99
```py
10-
""" Code Example """
10+
"""Code Example"""
1111

1212
# Code goes here
1313
```
@@ -25,7 +25,7 @@ Introduction to the code example...
2525
*[noncompliant01.py](noncompliant01.py):*
2626

2727
```python
28-
""" Non-compliant Code Example """
28+
"""Non-compliant Code Example"""
2929

3030
# Code goes here
3131

@@ -45,7 +45,7 @@ Introduction to the code example...
4545
*[compliant01.py](compliant01.py):*
4646

4747
```python
48-
""" Compliant Code Example """
48+
"""Compliant Code Example"""
4949

5050
# Code goes here
5151

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: OpenSSF project contributors
2+
# SPDX-License-Identifier: MIT
3+
"""Compliant Code Example"""
4+
5+
# Code goes here
6+
7+
#####################
8+
# Trying to exploit above code example
9+
#####################
10+
11+
# Code goes here
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: OpenSSF project contributors
2+
# SPDX-License-Identifier: MIT
3+
"""Code Example"""
4+
5+
# Code goes here
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: OpenSSF project contributors
2+
# SPDX-License-Identifier: MIT
3+
"""Non-compliant Code Example"""
4+
5+
# Code goes here
6+
7+
#####################
8+
# Trying to exploit above code example
9+
#####################
10+
11+
# Code goes here

0 commit comments

Comments
 (0)