-
Notifications
You must be signed in to change notification settings - Fork 15
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
Adding two abstract visitor classes for XXE vulnerabilities #98
Conversation
aaronist
commented
Aug 17, 2023
•
edited
Loading
edited
- Add two abstract visitors (one to search, one to update) for XXE vulnerabilities to allow for easier addition of new XML parsers
- Additional code cleanup
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.
Some suggestions. Otherwise looks good!
@Getter | ||
public abstract class XmlFactoryInsertVisitor<P> extends JavaIsoVisitor<P> { | ||
private final J.Block scope; | ||
private final StringBuilder template; |
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.
Just assign this to a new string builder, then you don't need to pass it in the super call
return s != null ? s.getCoordinates().before() : b.getCoordinates().lastStatement(); | ||
} | ||
|
||
public J.Block updateTemplate(J.Block b, J.Block block, Statement beforeStatement, Set<String> imports) { |
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.
Curious about this method name
maybeAddImport("javax.xml.XMLConstants"); | ||
Statement beforeStatement = getInsertStatement(b); | ||
if (b.isScope(getScope())) { | ||
b = updateTemplate(b, block, beforeStatement, Stream.of("javax.xml.XMLConstants").collect(Collectors.toSet())); |
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.
b = updateTemplate(b, block, beforeStatement, Stream.of("javax.xml.XMLConstants").collect(Collectors.toSet())); | |
b = updateTemplate(b, block, beforeStatement, Collections.single("javax.xml.XMLConstants")); |
Not sure I got the method name entirely correct
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.
LGTM!