Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(iast): move inner funcions #11570

Merged
merged 21 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
403da2f
chore(ci): more django iast tests
avara1986 Nov 28, 2024
e4e3414
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Nov 29, 2024
9983708
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Nov 29, 2024
7d659de
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Nov 29, 2024
cd644f7
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Dec 5, 2024
d88dedc
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Dec 18, 2024
2891bf3
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Dec 18, 2024
a4a720b
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Dec 19, 2024
91cff3f
feat: add bcrypt
avara1986 Dec 19, 2024
03cc10d
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Dec 19, 2024
0f56b9c
chore(iast): move inner funcionts
avara1986 Dec 19, 2024
0bfeef1
chore(iast): move inner funcionts
avara1986 Dec 19, 2024
807c25e
chore(iast): move inner funcionts
avara1986 Dec 19, 2024
0561f3f
chore(iast): move inner funcionts
avara1986 Dec 19, 2024
f572ca4
Merge branch 'avara1986/move_iast_inner_functions' into avara1986/dja…
avara1986 Dec 19, 2024
f9df102
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Dec 19, 2024
b40a951
itr:noskip circleci:all
avara1986 Dec 19, 2024
7a26f5a
Merge branch 'main' into avara1986/django_iast_tests
avara1986 Dec 23, 2024
7791e93
chore(iast): move inner funcions
avara1986 Dec 23, 2024
56823cc
chore(iast): move inner funcions
avara1986 Dec 23, 2024
993f723
chore(iast): move inner funcions
avara1986 Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/contrib/django/django_app/appsec_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ def checkuser_view(request, user_id):


def sqli_http_request_parameter(request):
import bcrypt
from django.contrib.auth.hashers import BCryptSHA256PasswordHasher

password_django = BCryptSHA256PasswordHasher()
obj = password_django.encode("i'm a password", bcrypt.gensalt())
with connection.cursor() as cursor:
# label iast_enabled_sqli_http_request_parameter
cursor.execute(request.GET["q"])
cursor.execute(add_aspect(add_aspect(request.GET["q"], obj), "'"))

return HttpResponse(request.META["HTTP_USER_AGENT"], status=200)

Expand Down
10 changes: 6 additions & 4 deletions tests/contrib/django/test_django_appsec_iast.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ def test_django_tainted_user_agent_iast_disabled(client, test_spans, tracer):
@pytest.mark.django_db()
@pytest.mark.skipif(not python_supported_by_iast(), reason="Python version not supported by IAST")
def test_django_tainted_user_agent_iast_enabled_sqli_http_request_parameter(client, test_spans, tracer):
with override_global_config(dict(_iast_enabled=True)):
with override_global_config(dict(_iast_enabled=True, _deduplication_enabled=False, _iast_request_sampling=100.0)):
root_span, response = _aux_appsec_get_root_span(
client,
test_spans,
tracer,
payload=urlencode({"mytestingbody_key": "mytestingbody_value"}),
content_type="application/x-www-form-urlencoded",
url="/appsec/sqli_http_request_parameter/?q=SELECT 1 FROM sqlite_master",
url="/appsec/sqli_http_request_parameter/?q=SELECT 1 FROM sqlite_master WHERE name='",
headers={"HTTP_USER_AGENT": "test/1.2.3"},
)

Expand All @@ -228,7 +228,7 @@ def test_django_tainted_user_agent_iast_enabled_sqli_http_request_parameter(clie
{
"name": "q",
"origin": "http.request.parameter",
"pattern": "abcdefghijklmnopqrstuvwxyzA",
"pattern": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN",
"redacted": True,
}
]
Expand All @@ -238,7 +238,9 @@ def test_django_tainted_user_agent_iast_enabled_sqli_http_request_parameter(clie
"valueParts": [
{"source": 0, "value": "SELECT "},
{"pattern": "h", "redacted": True, "source": 0},
{"source": 0, "value": " FROM sqlite_master"},
{"source": 0, "value": " FROM sqlite_master WHERE name='"},
{"redacted": True},
{"value": "'"},
]
}
assert loaded["vulnerabilities"][0]["location"]["path"] == TEST_FILE
Expand Down
Loading