Skip to content

Commit

Permalink
update DTL
Browse files Browse the repository at this point in the history
  • Loading branch information
xanhacks committed May 5, 2024
1 parent 76ce639 commit d9a9f33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions content/docs/framework/ssti/django-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Django ships built-in backends for its own template system, creatively called th

Basic example of DTL:

```html
```jinja
My first name is {{ first_name }}. My last name is {{ last_name }}.
{{ my_dict.key }}
{{ my_object.attribute }}
Expand Down Expand Up @@ -62,37 +62,43 @@ DTL vs Jinja2:

## Built-in

- List of all tags and filters: [Django - Built-in template tags and filters](https://docs.djangoproject.com/en/5.0/ref/templates/builtins/)

### Debug

```js
```jinja
{% debug %}
```

### CSRF

```js
```jinja
{% csrf_token %}
```

### Secret Key Leak

When `messages` is present in the template context and `CookieStorage` is being used we can walk through attributes of `messages` to access app's `SECRET_KEY`:

```js
```jinja
{{ messages.storages.0.signer.key }}
```

### Filters
### Include Template

You can include other templates in your page:

List of all filters: [Built-in filter reference](https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#built-in-filter-reference)
```jinja
{% include 'admin/base.html' %}
```

### XSS

- `safe`: Marks a string as not requiring further HTML escaping prior to output. When autoescaping is off, this filter has no effect.
- `escape`: Escapes a string's HTML (HTML entity).
- `force_escape`: Applies HTML escaping to a string.

```html
```jinja
{% autoescape off %}
{{ message }}
{% endautoescape %}
Expand Down
1 change: 1 addition & 0 deletions hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@
"http",
"httponly",
"in-scope",
"include-template",
"infinite-levels-deep",
"information-leakage",
"innerhtml-vs-innertext",
Expand Down

0 comments on commit d9a9f33

Please sign in to comment.