(self, context)
| 27 | """Analyze Jinja specific vulnerabilities such as XSS""" |
| 28 | |
| 29 | def node_Call(self, context): |
| 30 | yield from self.__analyze_jinja_template(context) |
| 31 | f_name = context.node.cached_full_name |
| 32 | |
| 33 | if f_name != "jinja2.Environment": |
| 34 | return |
| 35 | |
| 36 | try: |
| 37 | signature = context.node.apply_signature( |
| 38 | aura_capture_args="args", aura_capture_kwargs="kwargs", autoescape=True |
| 39 | ) |
| 40 | except TypeError: |
| 41 | return |
| 42 | |
| 43 | if signature.arguments.get("autoescape", True) is False: |
| 44 | hit = JinjaVulnerability( |
| 45 | message="Detected jinja environment with autoescaping explicitly disabled", |
| 46 | score=100, |
| 47 | line_no=context.node.line_no, |
| 48 | signature=f"jinja#xss#{context.visitor.normalized_path}#{context.node.line_no}", |
| 49 | ) |
| 50 | yield hit |
| 51 | |
| 52 | def __analyze_jinja_template(self, context): |
| 53 | f_name = context.node.cached_full_name |
nothing calls this directly
no test coverage detected