Skip to content

Configure XML parser with secure processing in AstSchemaParser (Sonar S2755) #23

Closed

Description

@fupacat

Description

SonarCloud flagged vulnerability rule java:S2755 on tsql-scriptdom-astgen/src/main/java/io/github/fupacat/AstSchemaParser.java.
The DocumentBuilderFactory parses XML without explicitly disabling external entity resolution, leaving it vulnerable to potential XML External Entity (XXE) attacks.

Proposed Changes

  • In AstSchemaParser.java, configure DocumentBuilderFactory with:
    factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
    factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
  • Ensure safe parsing without affecting the generation of AST classes from Ast.xml.

References

  • Sonar rule: java:S2755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions