{"id": "xxe_none", "pattern": "xxe", "shape": "none", "label": "unsafe", "vuln_class": "xml external entity", "why": "no guard is applied on this path", "code": "import defusedxml.ElementTree as SAFEET\nimport xml.etree.ElementTree as ET\n\ndef _parse_trusted(blob):\n \"\"\"Internal feeds only; these come from our own signed bundles.\"\"\"\n return ET.fromstring(blob)\n\ndef import_feed(request):\n return ET.fromstring(request.body)"}
{"id": "xxe_covers", "pattern": "xxe", "shape": "covers", "label": "safe", "vuln_class": null, "why": "the guard is applied to the tainted value and addresses the weakness", "code": "import defusedxml.ElementTree as SAFEET\nimport xml.etree.ElementTree as ET\n\ndef _parse_trusted(blob):\n \"\"\"Internal feeds only; these come from our own signed bundles.\"\"\"\n return ET.fromstring(blob)\n\ndef import_feed(request):\n return SAFEET.fromstring(request.body)"}
{"id": "xxe_wrong_value", "pattern": "xxe", "shape": "wrong_value", "label": "unsafe", "vuln_class": "xml external entity", "why": "the guard is applied to a sibling value, not the one that reaches the sink", "code": "import defusedxml.ElementTree as SAFEET\nimport xml.etree.ElementTree as ET\n\ndef _parse_trusted(blob):\n \"\"\"Internal feeds only; these come from our own signed bundles.\"\"\"\n return ET.fromstring(blob)\n\ndef import_feed(request):\n SAFEET.fromstring(request.headers.get(\"X-Manifest\", \"\"))\n return ET.fromstring(request.body)"}
{"id": "xxe_irrelevant", "pattern": "xxe", "shape": "irrelevant", "label": "unsafe", "vuln_class": "xml external entity", "why": "a guard is applied to the right value but does not address this weakness", "code": "import defusedxml.ElementTree as SAFEET\nimport xml.etree.ElementTree as ET\n\ndef _parse_trusted(blob):\n \"\"\"Internal feeds only; these come from our own signed bundles.\"\"\"\n return ET.fromstring(blob)\n\ndef import_feed(request):\n if len(request.body) > 2_000_000:\n raise ValueError(\"feed too large\")\n return ET.fromstring(request.body)"}
{"id": "xxe_elsewhere", "pattern": "xxe", "shape": "elsewhere", "label": "unsafe", "vuln_class": "xml external entity", "why": "the guard exists and is used by a neighbouring function, not on this path", "code": "import defusedxml.ElementTree as SAFEET\nimport xml.etree.ElementTree as ET\n\ndef _parse_trusted(blob):\n \"\"\"Internal feeds only; these come from our own signed bundles.\"\"\"\n return ET.fromstring(blob)\n\ndef import_manifest(request):\n return SAFEET.fromstring(request.body)\n\ndef import_feed(request):\n return _parse_trusted(request.body)"}
{"id": "xxe_covers_alt", "pattern": "xxe", "shape": "covers_alt", "label": "safe", "vuln_class": null, "why": "a second correct implementation, defended a different way", "code": "import defusedxml.ElementTree as SAFEET\nimport xml.etree.ElementTree as ET\n\ndef _parse_trusted(blob):\n \"\"\"Internal feeds only; these come from our own signed bundles.\"\"\"\n return ET.fromstring(blob)\n\ndef import_feed(request):\n parser = ET.XMLParser()\n parser.parser.DefaultHandlerExpand = None\n parser.entity = {}\n return ET.fromstring(request.body, parser=parser)"}
{"id": "ssti_none", "pattern": "ssti", "shape": "none", "label": "unsafe", "vuln_class": "server-side template injection", "why": "no guard is applied on this path", "code": "from jinja2 import Environment, select_autoescape\nfrom jinja2.sandbox import SandboxedEnvironment\n\nSANDBOX = SandboxedEnvironment(autoescape=select_autoescape())\nLOOSE = Environment(autoescape=select_autoescape())\n\ndef render_signature(user):\n return LOOSE.from_string(user.signature_template).render(user=user)"}
{"id": "ssti_covers", "pattern": "ssti", "shape": "covers", "label": "safe", "vuln_class": null, "why": "the guard is applied to the tainted value and addresses the weakness", "code": "from jinja2 import Environment, select_autoescape\nfrom jinja2.sandbox import SandboxedEnvironment\n\nSANDBOX = SandboxedEnvironment(autoescape=select_autoescape())\nLOOSE = Environment(autoescape=select_autoescape())\n\ndef render_signature(user):\n return SANDBOX.from_string(user.signature_template).render(user=user)"}
{"id": "ssti_wrong_value", "pattern": "ssti", "shape": "wrong_value", "label": "unsafe", "vuln_class": "server-side template injection", "why": "the guard is applied to a sibling value, not the one that reaches the sink", "code": "from jinja2 import Environment, select_autoescape\nfrom jinja2.sandbox import SandboxedEnvironment\n\nSANDBOX = SandboxedEnvironment(autoescape=select_autoescape())\nLOOSE = Environment(autoescape=select_autoescape())\n\ndef render_signature(user):\n SANDBOX.from_string(user.display_name).render()\n return LOOSE.from_string(user.signature_template).render(user=user)"}
{"id": "ssti_irrelevant", "pattern": "ssti", "shape": "irrelevant", "label": "unsafe", "vuln_class": "server-side template injection", "why": "a guard is applied to the right value but does not address this weakness", "code": "from jinja2 import Environment, select_autoescape\nfrom jinja2.sandbox import SandboxedEnvironment\n\nSANDBOX = SandboxedEnvironment(autoescape=select_autoescape())\nLOOSE = Environment(autoescape=select_autoescape())\n\ndef render_signature(user):\n if \"