Skip to content

Commit 70fe385

Browse files
SONARJAVA-3884: Changes from review
* Revert link change in S2077 * Add missing description of S2755
1 parent 0fe88f0 commit 70fe385

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2077_java.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p>Formatted SQL queries can be difficult to maintain, debug and can increase the risk of SQL injection when concatenating untrusted values into the
2-
query. However, this rule doesn’t detect SQL injections (unlike rule {rule:java:S3649}), the goal is only to highlight complex/formatted queries.</p>
2+
query. However, this rule doesn’t detect SQL injections (unlike rule {rule:javasecurity:S3649}), the goal is only to highlight complex/formatted queries.</p>
33
<h2>Ask Yourself Whether</h2>
44
<ul>
55
<li> Some parts of the query come from untrusted values (like user inputs). </li>

java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2755_java.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
<h2>Noncompliant Code Example</h2>
1+
<p>XML standard allows the use of entities, declared in the DOCTYPE of the document, which can be <a
2+
href="https://www.w3.org/TR/xml/#sec-internal-ent">internal</a> or <a href="https://www.w3.org/TR/xml/#sec-external-ent">external</a>.</p>
3+
<p>When parsing the XML file, the content of the external entities is retrieved from an external storage such as the file system or network, which may
4+
lead, if no restrictions are put in place, to arbitrary file disclosures or <a
5+
href="https://www.owasp.org/index.php/Server_Side_Request_Forgery">server-side request forgery (SSRF)</a> vulnerabilities.</p>
6+
<pre>
7+
&lt;?xml version="1.0" encoding="utf-8"?&gt;
8+
&lt;!DOCTYPE person [
9+
&lt;!ENTITY file SYSTEM "file:///etc/passwd"&gt;
10+
&lt;!ENTITY ssrf SYSTEM "https://internal.network/sensitive_information"&gt;
11+
]&gt;
12+
13+
&lt;person&gt;
14+
&lt;name&gt;&amp;file;&lt;/name&gt;
15+
&lt;city&gt;&amp;ssrf;&lt;/city&gt;
16+
&lt;age&gt;18&lt;/age&gt;
17+
&lt;/person&gt;
18+
</pre>
19+
<p>It’s recommended to limit resolution of external entities by using one of these solutions:</p>
20+
<ul>
21+
<li> If DOCTYPE is not necessary, completely disable all DOCTYPE declarations. </li>
22+
<li> If external entities are not necessary, completely disable their declarations. </li>
23+
<li> If external entities are necessary then:
24+
<ul>
25+
<li> Use XML processor features, if available, to authorize only required protocols (eg: https). </li>
26+
<li> And use an entity resolver (and optionally an XML Catalog) to resolve only trusted entities. == Noncompliant Code Example </li>
27+
</ul> </li>
28+
</ul>
229
<p>For <a href="https://docs.oracle.com/javase/9/docs/api/javax/xml/parsers/DocumentBuilderFactory.html">DocumentBuilder</a>, <a
330
href="https://docs.oracle.com/javase/9/docs/api/javax/xml/parsers/SAXParserFactory.html">SAXParser</a>, <a
431
href="https://docs.oracle.com/javase/9/docs/api/javax/xml/stream/XMLInputFactory.html">XMLInput</a>, <a

sonarpedia.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"languages": [
44
"JAVA"
55
],
6-
"latest-update": "2021-06-25T08:53:01.331051Z",
6+
"latest-update": "2021-06-25T11:15:59.148768Z",
77
"options": {
88
"no-language-in-filenames": false,
99
"preserve-filenames": false
1010
}
11-
}
11+
}

0 commit comments

Comments
 (0)