All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.codemodder.codemods.harden-xmlreader.yaml Maven / Gradle / Ivy

The newest version!
rules:
  - id: harden-xmlreader
    patterns:
      - pattern: $XMLR.parse(...);
      - pattern-inside: |
          $RT $METHOD ($ARGS) {
            ...
            $XMLR = XMLReaderFactory.createXMLReader(...);
            ...
          }
      - pattern-not-inside: |
          $RT $METHOD ($ARGS) {
            ...
            $XMLR.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            ...
          }
      - pattern-not-inside: |
          $RT $METHOD ($ARGS) {
            ...
            $XMLR.setFeature("http://xml.org/sax/features/external-general-entities", false);
            ...
            $XMLR.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
            ...
          }
      - pattern-not-inside: |
          $RT $METHOD ($ARGS) {
            ...
            $XMLR.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
            ...
            $XMLR.setFeature("http://xml.org/sax/features/external-general-entities", false);
            ...
          }
      - focus-metavariable: $XMLR
    message: "Semgrep found a match"
    languages:
      - java
    severity: WARNING




© 2015 - 2024 Weber Informatics LLC | Privacy Policy