-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6478bf
commit f909c5a
Showing
2 changed files
with
18 additions
and
2 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/core_codemods/docs/pixee_python_enable-jinja2-autoescape.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
This codemod ensures you configure jinja2 to turn on autoescaping of HTML content. Unfortunately, the jinja2 | ||
default behavior is to not autoescape when rendering templates, which makes your applications | ||
vulnerable to Cross-Site Scripting (XSS) attacks. | ||
|
||
Our codemod currently checks if you forgot to turn autoescape on or if you explicitly disabled it. The change looks as follows: | ||
|
||
```diff | ||
from jinja2 import Environment | ||
|
||
- env = Environment() | ||
- env = Environment(autoescape=False, loader=some-loader) | ||
+ env = Environment(autoescape=True) | ||
+ env = Environment(autoescape=True, loader=some-loader) | ||
... | ||
``` | ||
|
||
At this time, this codemod will not detect if `autoescape` is assigned to a callable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters