Skip to content

Commit f052e10

Browse files
Update rules metadata (#776)
1 parent 2f22b31 commit f052e10

39 files changed

+161
-186
lines changed

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/ClassComplexity.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Classes should not be too complex",
2+
"title": "Cyclomatic Complexity of classes should not be too high",
33
"type": "CODE_SMELL",
44
"status": "deprecated",
55
"remediation": {

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/FunctionComplexity.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Functions should not be too complex",
2+
"title": "Cyclomatic Complexity of functions should not be too high",
33
"type": "CODE_SMELL",
44
"status": "ready",
55
"remediation": {

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S1313.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
<p>Last but not least it has an effect on application security. Attackers might be able to decompile the code and thereby discover a potentially
1414
sensitive address. They can perform a Denial of Service attack on the service at this address or spoof the IP address. Such an attack is always
1515
possible, but in the case of a hardcoded IP address the fix will be much slower, which will increase an attack's impact.</p>
16-
<h2>Recommended Secure Coding Practices</h2>
16+
<h2>Ask Yourself Whether</h2>
17+
<p>The disclosed IP address is sensitive, eg:</p>
1718
<ul>
18-
<li> make the IP address configurable. </li>
19+
<li> Can give information to an attacker about the network topology. </li>
20+
<li> It's a personal (assigned to an identifiable person) IP address. </li>
1921
</ul>
20-
<h2>Noncompliant Code Example</h2>
22+
<p>There is a risk if you answered yes to any of these questions.</p>
23+
<h2>Recommended Secure Coding Practices</h2>
24+
<p>Don't hard-code the IP address in the source code, instead make it configurable.</p>
25+
<h2>Sensitive Code Example</h2>
2126
<pre>
2227
ip = '192.168.12.42'
2328
sock = socket.socket()

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S1523.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ <h2>Ask Yourself Whether</h2>
1414
<li> the executed code may come from an untrusted source and hasn't been sanitized. </li>
1515
<li> you really need to run code dynamically. </li>
1616
</ul>
17-
<p>You are at risk if you answered yes to the first question. You are increasing the security risks for no reason if you answered yes to the second
18-
question.</p>
17+
<p>There is a risk if you answered yes to any of those questions.</p>
1918
<h2>Recommended Secure Coding Practices</h2>
2019
<p>Regarding the execution of unknown code, the best solution is to not run code provided by an untrusted source. If you really need to do it, run the
2120
code in a <a href="https://en.wikipedia.org/wiki/Sandbox_(computer_security)">sandboxed</a> environment. Use jails, firewalls and whatever means your

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S2068.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h2>Ask Yourself Whether</h2>
1515
<li> Credentials are used in production environments. </li>
1616
<li> Application re-distribution is required before updating the credentials. </li>
1717
</ul>
18-
<p>You are at risk, if you answered yes to any of these questions.</p>
18+
<p>There is a risk if you answered yes to any of those questions.</p>
1919
<h2>Recommended Secure Coding Practices</h2>
2020
<ul>
2121
<li> Store the credentials in a configuration file that is not pushed to the code repository. </li>

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S2077.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2>Ask Yourself Whether</h2>
2323
<li> the SQL query is built using string formatting technics, such as concatenating variables. </li>
2424
<li> some of the values are coming from an untrusted source and are not sanitized. </li>
2525
</ul>
26-
<p>You may be at risk if you answered yes to this question.</p>
26+
<p>There is a risk if you answered yes to any of those questions.</p>
2727
<h2>Recommended Secure Coding Practices</h2>
2828
<ul>
2929
<li> Avoid building queries manually using formatting. If you do it anyway, do not include user input in this building process. </li>
@@ -65,6 +65,16 @@ <h2>Sensitive Code Example</h2>
6565
},
6666
)
6767
</pre>
68+
<h2>Compliant Solution</h2>
69+
<pre>
70+
cursor = connection.cursor(prepared=True)
71+
sql_insert_query = """ select col from sometable here mycol = %s and othercol = %s """
72+
73+
select_tuple = (1, value)
74+
75+
cursor.execute(sql_insert_query, select_tuple) # Compliant, the query is parameterized
76+
connection.commit()
77+
</pre>
6878
<h2>See</h2>
6979
<ul>
7080
<li> <a href="https://www.owasp.org/index.php/Top_10-2017_A1-Injection">OWASP Top 10 2017 Category A1</a> - Injection </li>

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S2092.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ <h2>Ask Yourself Whether</h2>
66
<li> it's not sure that the website contains <a href="https://developer.mozilla.org/fr/docs/S%C3%A9curit%C3%A9/MixedContent">mixed content</a> or
77
not (ie HTTPS everywhere or not) </li>
88
</ul>
9-
<p>You are at risk if you answered yes to any of those questions.</p>
9+
<p>There is a risk if you answered yes to any of those questions.</p>
1010
<h2>Recommended Secure Coding Practices</h2>
1111
<ul>
1212
<li> It is recommended to use <code>HTTPs</code> everywhere so setting the <code>secure</code> flag to <em>true</em> should be the default behaviour
1313
when creating cookies. </li>
1414
<li> Set the <code>secure</code> flag to <em>true</em> for session-cookies. </li>
1515
</ul>
16-
<h2>Sensitive Code Examples</h2>
16+
<h2>Sensitive Code Example</h2>
1717
<p>Flask</p>
1818
<pre>
1919
from flask import Response

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S2245.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h2>Ask Yourself Whether</h2>
1414
<li> the generated value is used multiple times. </li>
1515
<li> an attacker can access the generated value. </li>
1616
</ul>
17-
<p>You are at risk if you answered yes to the first question and any of the following ones.</p>
17+
<p>There is a risk if you answered yes to any of those questions.</p>
1818
<h2>Recommended Secure Coding Practices</h2>
1919
<ul>
2020
<li> Only use random number generators which are <a

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S2275.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ <h2>Compliant Solution</h2>
1818

1919
print('User {a} has not been able to access {b}'.format(a='Alice', b='MyFile'))
2020
</pre>
21-
<h2>See also</h2>
21+
<h2>See</h2>
2222
<ul>
23-
<li> {rule:python:S3457} - Strings should be formatted correctly. </li>
23+
<li> <a href="https://docs.python.org/3/library/string.html#format-string-syntax">Python documentation - Format String Syntax</a> </li>
24+
<li> <a href="https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting">Python documentation - printf-style String
25+
Formatting</a> </li>
2426
</ul>
2527

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/S3330.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ <h2>Ask Yourself Whether</h2>
99
<li> the <code>HttpOnly</code> attribute offer an additional protection (not the case for an <em>XSRF-TOKEN cookie</em> / CSRF token for example)
1010
</li>
1111
</ul>
12-
<p>You are at risk if you answered yes to any of those questions.</p>
12+
<p>There is a risk if you answered yes to any of those questions.</p>
1313
<h2>Recommended Secure Coding Practices</h2>
1414
<ul>
1515
<li> By default the <code>HttpOnly</code> flag should be set to <em>true</em> for most of the cookies and it's mandatory for session /
1616
sensitive-security cookies. </li>
1717
</ul>
18-
<h2>Sensitive Code Examples</h2>
18+
<h2>Sensitive Code Example</h2>
1919
<p>Flask:</p>
2020
<pre>
2121
from flask import Response

0 commit comments

Comments
 (0)