-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We check if the path contains '..' to prevent possible path traversal attacks. For example: '..', 'foo/..', '../foo', and 'foo/../bar' are all not allowed
- Loading branch information
1 parent
32fa8ca
commit 1deca41
Showing
4 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
26 changes: 26 additions & 0 deletions
26
src/openforms/registrations/contrib/json_dump/tests/test_config.py
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,26 @@ | ||
from django.test import TestCase | ||
|
||
from openforms.appointments.contrib.qmatic.tests.factories import ServiceFactory | ||
|
||
from ..config import JSONDumpOptions, JSONDumpOptionsSerializer | ||
|
||
|
||
class JSONDumpConfigTests(TestCase): | ||
def test_serializer_raises_validation_error_on_path_traversal(self): | ||
service = ServiceFactory.create(api_root="https://example.com/api/v2") | ||
|
||
data: JSONDumpOptions = { | ||
"service": service.pk, | ||
"path": "", | ||
"variables": ["now"], | ||
} | ||
|
||
# Ensuring that the options are valid in the first place | ||
serializer = JSONDumpOptionsSerializer(data=data) | ||
self.assertTrue(serializer.is_valid()) | ||
|
||
for path in ("..", "../foo", "foo/..", "foo/../bar"): | ||
with self.subTest(path): | ||
data["path"] = path | ||
serializer = JSONDumpOptionsSerializer(data=data) | ||
self.assertFalse(serializer.is_valid()) |