-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1208 from userlocalhost/fix/security/path_traversal
Added supplemental tests that were detected by OWASP ZAP.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import json | ||
|
||
from rest_framework import status | ||
|
||
from airone.lib.test import AironeViewTest | ||
from group.models import Group | ||
|
||
|
||
class ViewTest(AironeViewTest): | ||
def test_path_traversal(self): | ||
self.admin_login() | ||
|
||
# create a group to be tested | ||
group = Group.objects.create(name="hoge") | ||
|
||
# This is a parameter that has path traverasl attacking command | ||
update_params = { | ||
"name": "fuga", | ||
"members": ["1", 2, "cat ../../../../../../../etc/os-release"], | ||
} | ||
resp = self.client.put( | ||
"/group/api/v2/groups/%s" % group.id, json.dumps(update_params), "application/json" | ||
) | ||
self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual( | ||
resp.json(), | ||
{"members": {"2": [{"message": "A valid integer is required.", "code": "AE-121000"}]}}, | ||
) |