Skip to content

Commit 27770dc

Browse files
test(asm): improve fastapi srb query test (#7901)
Small improvement on suspicious request blocking test for query parameters for fastapi to ensure we are decoding query parameters as expected. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that.
1 parent fed5170 commit 27770dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/contrib/fastapi/test_fastapi_appsec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,14 @@ def test_route(toto: str = ""):
187187
# other values must not be blocked
188188
with override_global_config(dict(_asm_enabled=True)), override_env(dict(DD_APPSEC_RULES=RULES_SRB)):
189189
_aux_appsec_prepare_tracer(tracer)
190-
resp = client.get("/index.html?toto=ytrace")
190+
resp = client.get("/index.html?toto=ytrac%65")
191191
assert resp.status_code == 200
192192
assert get_response_body(resp) == "Ok: ytrace"
193+
# same encoded value must be blocked
194+
with override_global_config(dict(_asm_enabled=True)), override_env(dict(DD_APPSEC_RULES=RULES_SRB)):
195+
_aux_appsec_prepare_tracer(tracer)
196+
resp = client.get("/index.html?toto=xtrac%65")
197+
assert resp.status_code == 403
193198
# appsec disabled must not block
194199
with override_global_config(dict(_asm_enabled=False)), override_env(dict(DD_APPSEC_RULES=RULES_SRB)):
195200
_aux_appsec_prepare_tracer(tracer, asm_enabled=False)

0 commit comments

Comments
 (0)