-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update for missing a couple possibly unsafe xml parser #902
Conversation
} catch (ParserConfigurationException e) { | ||
log.warn(e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that catching and swallowing the exception makes it possible to return a document builder factory which is still vulnerable!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already delete this block, please check it again, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution! I have a couple of comments that should be easy to address. Also you will need to agree to the CLA before we can merge this contribution (see the comment on the PR by the bot).
@@ -94,14 +94,25 @@ public static <T> DefaultXMLValueProvider<T> getValueFromTag( | |||
return new DefaultXMLValueProvider<>(null, klass); | |||
} | |||
|
|||
public DocumentBuilderFactory safeDocumentBuilderFactory() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be static
. Also can we add a bit of Javadoc as to its purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course! Thanks for your comment.
public DocumentBuilderFactory safeDocumentBuilderFactory() { | ||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | ||
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); | ||
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); | ||
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); | ||
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); | ||
dbf.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", false); | ||
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); | ||
return dbf; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we make the XMLUtil#safeDocumentBuilderFactory
method static, we can get rid of this method, and just call XMLUtil.safeDocumentBuilderFactory()
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I've already make the XMLUtil#safeDocumentBuilderFactory method static. please check it again, Thank you!
@@ -16,7 +16,7 @@ | |||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
* OUT OF OR IN CONNECTION WITH com.uber.nullaway.fixserializationTHE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we revert this change? we shouldn't modify license headers unless there's a reason
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you run our configured formatter (./gradlew spotlessApply
) on this PR?
We try to be consistent in formatting and these two blank lines don't seem right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the comment, based on the CI run looks like there are compile errors. You can run ./gradlew compileJava
to ensure that all the code compiles
@@ -94,14 +94,25 @@ public static <T> DefaultXMLValueProvider<T> getValueFromTag( | |||
return new DefaultXMLValueProvider<>(null, klass); | |||
} | |||
|
|||
public static DocumentBuilderFactory safeDocumentBuilderFactory() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add Javadoc describing what this method does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what your project use is jdk 21?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JDK 21 is required in order to run certain tests. Sorry for the hassle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I‘ve already pushed and the ./gradlew spotlessApply
is run successfully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the cli ./gradlew compileJava
is failed cause it need to use jdk8? I don't know why, but I think it's not caused by the code I've added. Please check it again, and I will try to fix it if you find any error again. Feel sorry to trouble you again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #902 +/- ##
============================================
- Coverage 86.99% 86.98% -0.01%
- Complexity 1958 1959 +1
============================================
Files 77 77
Lines 6319 6330 +11
Branches 1223 1223
============================================
+ Hits 5497 5506 +9
- Misses 418 420 +2
Partials 404 404 ☔ View full report in Codecov by Sentry. |
Thank you for your merge! Considering the possible information leakage consequences of this vulnerability, maybe we can request for a CVE-ID? |
Sorry no, I do not believe this deserves a CVE. See my previous comments. |
Fixes #901