-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify S6373: Change text to the LaYC format (APPSEC-1108) (#3162)
- Loading branch information
1 parent
8ab8c5b
commit f1c3564
Showing
5 changed files
with
136 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
The following code is vulnerable because it explicitly enables the `xinclude` | ||
feature. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
== How to fix it in Dom4j | ||
|
||
=== Code examples | ||
|
||
include::../common/code-rationale.adoc[] | ||
|
||
==== Noncompliant code example | ||
|
||
[source,java,diff-id=2,diff-type=noncompliant] | ||
---- | ||
import org.dom4j.io.SAXReader; | ||
SAXReader xmlReader = new SAXReader(); | ||
xmlReader.setFeature("http://apache.org/xml/features/xinclude", true); // Noncompliant | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,java,diff-id=2,diff-type=compliant] | ||
---- | ||
import org.dom4j.io.SAXReader; | ||
SAXReader xmlReader = new SAXReader(); | ||
xmlReader.setFeature("http://apache.org/xml/features/xinclude", false); | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
== How to fix it in Java SE | ||
|
||
=== Code examples | ||
|
||
include::../common/code-rationale.adoc[] | ||
|
||
==== Noncompliant code example | ||
|
||
[source,java,diff-id=1,diff-type=noncompliant] | ||
---- | ||
import javax.xml.parsers.SAXParserFactory; | ||
SAXParserFactory factory = SAXParserFactory.newInstance(); | ||
factory.setXIncludeAware(true); // Noncompliant | ||
factory.setFeature("http://apache.org/xml/features/xinclude", true); // Noncompliant | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,java,diff-id=1,diff-type=compliant] | ||
---- | ||
import javax.xml.parsers.SAXParserFactory; | ||
SAXParserFactory factory = SAXParserFactory.newInstance(); | ||
factory.setXIncludeAware(false); | ||
factory.setFeature("http://apache.org/xml/features/xinclude", false); | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
== How to fix it in Jdom2 | ||
|
||
=== Code examples | ||
|
||
include::../common/code-rationale.adoc[] | ||
|
||
==== Noncompliant code example | ||
|
||
[source,java,diff-id=3,diff-type=noncompliant] | ||
---- | ||
import org.jdom2.input.SAXBuilder; | ||
SAXBuilder builder = new SAXBuilder(); | ||
builder.setFeature("http://apache.org/xml/features/xinclude", true); // Noncompliant | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,java,diff-id=3,diff-type=compliant] | ||
---- | ||
import org.jdom2.input.SAXBuilder; | ||
SAXBuilder builder = new SAXBuilder(); | ||
builder.setFeature("http://apache.org/xml/features/xinclude", false); | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters