github-advanced-security[bot] commented on code in PR #627:
URL: https://github.com/apache/creadur-rat/pull/627#discussion_r2901707129
##########
apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XmlWriter.java:
##########
@@ -675,49 +307,39 @@
while (!elementNames.isEmpty()) {
closeElement();
}
- writer.flush();
return this;
}
- private void rawWrite(final CharSequence sequence) throws IOException {
- for (int i = 0; i < sequence.length(); i++) {
- final char charAt = sequence.charAt(i);
- writer.write(charAt);
+ @Override
+ public void close() throws IOException {
+ closeDocument();
+ if (appendable instanceof Closeable) {
+ ((Closeable) appendable).close();
}
}
- private boolean isInvalidName(final CharSequence sequence) {
- boolean result = true;
- final int length = sequence.length();
- for (int i = 0; i < length; i++) {
- char character = sequence.charAt(i);
- if (i == 0) {
- if (!isValidNameStart(character)) {
- result = false;
- break;
- }
- } else {
- if (!isValidNameBody(character)) {
- result = false;
- break;
- }
- }
+ public IXmlWriter append(final Document document) throws IOException {
+ validateRootOpen();
+ elementsWritten = true;
+ maybeCloseElement();
+ appendable.append(System.lineSeparator());
+ currentAttributes.clear();
+ TransformerFactory tf = TransformerFactory.newInstance();
Review Comment:
## XML parsers should not be vulnerable to XXE attacks
<!--SONAR_ISSUE_KEY:AZzNJ5RrDgifRzo4FoZ8-->Disable access to external
entities in XML parsing. <p>See more on <a
href="https://sonarcloud.io/project/issues?id=apache_creadur-rat&issues=AZzNJ5RrDgifRzo4FoZ8&open=AZzNJ5RrDgifRzo4FoZ8&pullRequest=627">SonarQube
Cloud</a></p>
[Show more
details](https://github.com/apache/creadur-rat/security/code-scanning/6)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]