Skip to content

Commit 70cb56c

Browse files
authored
Merge branch 'main' into tyler.finethy/debugger-probe-budgets
2 parents ef1ee77 + bf45ded commit 70cb56c

36 files changed

+183
-148
lines changed

Diff for: pyproject.toml

+3-8
Original file line numberDiff line numberDiff line change
@@ -201,39 +201,31 @@ ignore = [
201201
"B007", # 23 occurences [ ] unused-loop-control-variable
202202
"DTZ005", # 23 occurences [ ] call-datetime-now-without-tzinfo
203203
"INP001", # 22 occurences [ ] implicit-namespace-package
204-
"ARG001", # 21 occurences [ ] unused-function-argument
205-
"UP031", # 17 occurences [ ] printf-string-formatting
206204
"ANN205", # 16 occurences [ ] missing-return-type-static-method
207205
"T201", # 15 occurences [*] print
208206
"FBT001", # 12 occurences [ ] boolean-type-hint-positional-argument
209207
"SLF001", # 12 occurences [ ] private-member-access
210208
"UP035", # 12 occurences [ ] deprecated-import
211209
"S105", # 10 occurences [ ] hardcoded-password-string
212-
"B015", # 10 occurences [ ] useless-comparison
213210
"RET503", # 9 occurences [*] implicit-return
214211
"SIM115", # 9 occurences [ ] open-file-with-context-handler
215-
"PGH004", # 9 occurences [ ] blanket-noqa
216-
"RUF001", # 9 occurences [ ] ambiguous-unicode-character-string
217212
"RUF015", # 9 occurences [*] unnecessary-iterable-allocation-for-first-element
218213
"SIM108", # 8 occurences [*] if-else-block-instead-of-if-exp
219214
"PTH120", # 8 occurences [ ] os-path-dirname
220-
"PGH003", # 8 occurences [ ] blanket-type-ignore
221215
"TRY301", # 8 occurences [ ] raise-within-try
222216
"ANN206", # 7 occurences [ ] missing-return-type-class-method
223217
"B011", # 7 occurences [*] assert-false
224218
"PT015", # 7 occurences [ ] pytest-assert-always-false
225219
"N815", # 7 occurences [ ] mixed-case-variable-in-class-scope
226220
"PT006", # 6 occurences [*] pytest-parametrize-names-wrong-type
227221
"N803", # 6 occurences [ ] invalid-argument-name
228-
"E741", # 6 occurences [ ] ambiguous-variable-name
229222
"S113", # 5 occurences [ ] request-without-timeout
230223
"PT011", # 5 occurences [ ] pytest-raises-too-broad
231224
"E731", # 5 occurences [*] lambda-assignment
232225
"RUF005", # 5 occurences [ ] collection-literal-concatenation
233226
"PTH103", # 4 occurences [ ] os-makedirs
234227
"PLW2901", # 4 occurences [ ] redefined-loop-name
235228
"PTH112", # 3 occurences [ ] os-path-isdir
236-
"ANN002", # 2 occurences [ ] missing-type-args
237229
"ASYNC230", # 2 occurences [ ] blocking-open-call-in-async-function
238230
"S605", # 2 occurences [ ] start-process-with-a-shell
239231
"PTH100", # 2 occurences [ ] os-path-abspath
@@ -253,6 +245,9 @@ ignore = [
253245
"RET505", # superfluous-else-return: requires a slightly higher cognitive effort to understand the code
254246
"S108", # hardcoded-temp-file: test code may contains weird things
255247
]
248+
"tests/fuzzer/request_mutator.py" = [
249+
"RUF001", # ambiguous-unicode-character-string: the mutator contains weird strings on purpose
250+
]
256251
"utils/build/*" = ["ALL"]
257252
"lib-injection/*" = ["ALL"]
258253
"utils/{k8s_lib_injection/*,_context/_scenarios/k8s_lib_injection.py}" = [

Diff for: tests/appsec/test_automated_login_events.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -877,11 +877,11 @@ def test_login_success_local(self):
877877
assert meta["usr.id"] == USER_HASH
878878

879879
# deprecated
880-
"appsec.events.users.login.success.username" not in meta
881-
"appsec.events.users.login.success.email" not in meta
882-
"usr.email" not in meta
883-
"usr.username" not in meta
884-
"usr.login" not in meta
880+
# "appsec.events.users.login.success.username" not in meta
881+
# "appsec.events.users.login.success.email" not in meta
882+
# "usr.email" not in meta
883+
# "usr.username" not in meta
884+
# "usr.login" not in meta
885885

886886
assert_priority(span, trace)
887887

@@ -898,11 +898,11 @@ def test_login_success_basic(self):
898898
assert meta["usr.id"] == USER_HASH
899899

900900
# deprecated
901-
"appsec.events.users.login.success.username" not in meta
902-
"appsec.events.users.login.success.email" not in meta
903-
"usr.email" not in meta
904-
"usr.username" not in meta
905-
"usr.login" not in meta
901+
# "appsec.events.users.login.success.username" not in meta
902+
# "appsec.events.users.login.success.email" not in meta
903+
# "usr.email" not in meta
904+
# "usr.username" not in meta
905+
# "usr.login" not in meta
906906

907907
assert_priority(span, trace)
908908

Diff for: tests/appsec/test_conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def setup_obfuscation_parameter_key(self):
7272
def test_obfuscation_parameter_key(self):
7373
"""Test DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP"""
7474

75-
def validate_appsec_span_tags(span, appsec_data): # pylint: disable=unused-argument
75+
def validate_appsec_span_tags(span, appsec_data): # noqa: ARG001
7676
assert not nested_lookup(
7777
self.SECRET, appsec_data, look_in_keys=True
7878
), "The security events contain the secret value that should be obfuscated"
@@ -90,7 +90,7 @@ def setup_obfuscation_parameter_value(self):
9090
def test_obfuscation_parameter_value(self):
9191
"""Test DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP"""
9292

93-
def validate_appsec_span_tags(span, appsec_data): # pylint: disable=unused-argument
93+
def validate_appsec_span_tags(span, appsec_data): # noqa: ARG001
9494
assert not nested_lookup(
9595
self.SECRET_WITH_HIDDEN_VALUE, appsec_data, look_in_keys=True
9696
), "The security events contain the secret value that should be obfuscated"

Diff for: tests/appsec/test_remote_config_rule_changes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ def test_update_rules(self):
178178
expected_rules_version_tag = "_dd.appsec.event_rules.version"
179179
expected_version_regex = r"[0-9]+\.[0-9]+\.[0-9]+"
180180

181-
def validate_waf_rule_version_tag(span, appsec_data):
181+
def validate_waf_rule_version_tag(span, appsec_data): # noqa: ARG001
182182
"""Validate the mandatory event_rules.version tag is added to the request span having an attack"""
183183
meta = span["meta"]
184184
assert expected_rules_version_tag in meta, f"missing span meta tag `{expected_rules_version_tag}` in meta"
185185
assert re.match(expected_version_regex, meta[expected_rules_version_tag])
186186
return True
187187

188-
def validate_waf_rule_version_tag_by_rc(span, appsec_data):
188+
def validate_waf_rule_version_tag_by_rc(span, appsec_data): # noqa: ARG001
189189
"""Validate the mandatory event_rules.version tag is added to the request span having an attack with expected rc version"""
190190
meta = span["meta"]
191191
assert expected_rules_version_tag in meta, f"missing span meta tag `{expected_rules_version_tag}` in meta"

Diff for: tests/appsec/test_reports.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def check_http_code_legacy(event):
2323

2424
return True
2525

26-
def check_http_code(span, appsec_data):
26+
def check_http_code(span, appsec_data): # noqa: ARG001
2727
status_code = span["meta"]["http.status_code"]
2828
assert status_code == "404", f"404 should have been reported, not {status_code}"
2929

@@ -51,7 +51,7 @@ def _check_service_legacy(event):
5151

5252
return True
5353

54-
def _check_service(span, appsec_data):
54+
def _check_service(span, appsec_data): # noqa: ARG001
5555
name = span.get("service")
5656
environment = span.get("meta", {}).get("env")
5757
assert name == "weblog", f"weblog should have been reported, not {name}"

Diff for: tests/appsec/test_traces.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_appsec_obfuscator_key(self):
150150
# Note that this value must contain an attack pattern in order to be part of the security event data
151151
# that is expected to be obfuscated.
152152

153-
def validate_appsec_span_tags(span, appsec_data):
153+
def validate_appsec_span_tags(span, appsec_data): # noqa: ARG001
154154
assert not nested_lookup(
155155
self.SECRET_VALUE_WITH_SENSITIVE_KEY, appsec_data, look_in_keys=True
156156
), "The security events contain the secret value that should be obfuscated"
@@ -199,7 +199,7 @@ def test_appsec_obfuscator_value(self):
199199
# The following payload will be sent as a raw encoded string via the request params
200200
# and matches an XSS attack. It contains an access token secret we shouldn't have in the event.
201201

202-
def validate_appsec_span_tags(span, appsec_data):
202+
def validate_appsec_span_tags(span, appsec_data): # noqa: ARG001
203203
assert not nested_lookup(
204204
self.VALUE_WITH_SECRET, appsec_data, look_in_keys=True
205205
), "The security events contain the secret value that should be obfuscated"
@@ -222,7 +222,7 @@ def test_appsec_obfuscator_key_with_custom_rules(self):
222222
# Note that this value must contain an attack pattern in order to be part of the security event data
223223
# that is expected to be obfuscated.
224224

225-
def validate_appsec_span_tags(span, appsec_data): # pylint: disable=unused-argument
225+
def validate_appsec_span_tags(span, appsec_data): # noqa: ARG001
226226
assert not nested_lookup(
227227
self.SECRET_VALUE_WITH_SENSITIVE_KEY, appsec_data, look_in_keys=True
228228
), "The security events contain the secret value that should be obfuscated"
@@ -247,7 +247,7 @@ def test_appsec_obfuscator_cookies_with_custom_rules(self):
247247
# Note that this value must contain an attack pattern in order to be part of the security event data
248248
# that is expected to be obfuscated.
249249

250-
def validate_appsec_span_tags(span, appsec_data): # pylint: disable=unused-argument
250+
def validate_appsec_span_tags(span, appsec_data): # noqa: ARG001
251251
assert not nested_lookup(
252252
self.SECRET_VALUE_WITH_SENSITIVE_KEY_CUSTOM, appsec_data, look_in_keys=True
253253
), "Sensitive cookie is not obfuscated"

Diff for: tests/appsec/waf/test_reports.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_waf_monitoring(self):
2626

2727
# Tags that are expected to be reported at least once at some point
2828

29-
def validate_waf_monitoring_span_tags(span, appsec_data):
29+
def validate_waf_monitoring_span_tags(span, appsec_data): # noqa: ARG001
3030
"""Validate the mandatory waf monitoring span tags are added to the request span having an attack"""
3131

3232
meta = span["meta"]
@@ -131,7 +131,7 @@ def test_waf_monitoring_optional(self):
131131
expected_bindings_duration_metric = "_dd.appsec.waf.duration_ext"
132132
expected_metrics_tags = [expected_waf_duration_metric, expected_bindings_duration_metric]
133133

134-
def validate_waf_span_tags(span, appsec_data):
134+
def validate_waf_span_tags(span, appsec_data): # noqa: ARG001
135135
metrics = span["metrics"]
136136
for m in expected_metrics_tags:
137137
if m not in metrics:

Diff for: tests/appsec/waf/test_telemetry.py

+20-18
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,33 @@
55
TELEMETRY_REQUEST_TYPE_DISTRIBUTIONS = "distributions"
66

77

8-
def _setup(self):
9-
"""Common setup for all tests in this module. They all depend on the same set
10-
of requests, which must be run only once.
11-
"""
12-
# Run only once, even across multiple class instances.
13-
if hasattr(Test_TelemetryMetrics, "__common_setup_done"):
14-
return
15-
weblog.get("/", headers={"x-forwarded-for": "80.80.80.80"})
16-
weblog.get("/", headers={"x-forwarded-for": "80.80.80.80", "user-agent": "Arachni/v1"})
17-
weblog.get(
18-
"/",
19-
headers={"x-forwarded-for": "80.80.80.80", "user-agent": "dd-test-scanner-log-block"},
20-
# Hack to prevent rid inhibiting the dd-test-scanner-log-block rule
21-
rid_in_user_agent=False,
22-
)
23-
Test_TelemetryMetrics.__common_setup_done = True
24-
25-
268
@rfc("https://docs.google.com/document/d/1qBDsS_ZKeov226CPx2DneolxaARd66hUJJ5Lh9wjhlE")
279
@rfc("https://docs.google.com/document/d/1D4hkC0jwwUyeo0hEQgyKP54kM1LZU98GL8MaP60tQrA")
2810
@scenarios.appsec_waf_telemetry
2911
@features.waf_telemetry
3012
class Test_TelemetryMetrics:
3113
"""Test instrumentation telemetry metrics, type of metrics generate-metrics"""
3214

15+
__common_setup_done = False
16+
17+
def _setup(self):
18+
"""Common setup for all tests in this module. They all depend on the same set
19+
of requests, which must be run only once.
20+
"""
21+
# Run only once, even across multiple class instances.
22+
if Test_TelemetryMetrics.__common_setup_done:
23+
return
24+
25+
weblog.get("/", headers={"x-forwarded-for": "80.80.80.80"})
26+
weblog.get("/", headers={"x-forwarded-for": "80.80.80.80", "user-agent": "Arachni/v1"})
27+
weblog.get(
28+
"/",
29+
headers={"x-forwarded-for": "80.80.80.80", "user-agent": "dd-test-scanner-log-block"},
30+
# Hack to prevent rid inhibiting the dd-test-scanner-log-block rule
31+
rid_in_user_agent=False,
32+
)
33+
Test_TelemetryMetrics.__common_setup_done = True
34+
3335
setup_headers_are_correct = _setup
3436

3537
@bug(context.library < "[email protected]", reason="APMRP-360")

Diff for: tests/auto_inject/test_auto_inject_chaos.py

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class TestAutoInjectChaos(BaseAutoInjectChaos):
9292
{"vm_branch": "amazon_linux2", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
9393
{"vm_branch": "centos_7_amd64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
9494
{"vm_branch": "redhat", "vm_cpu": "arm64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
95+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
96+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
9597
]
9698
)
9799
def test_install_after_ld_preload(self, virtual_machine):
@@ -106,6 +108,8 @@ def test_install_after_ld_preload(self, virtual_machine):
106108
{"vm_branch": "amazon_linux2", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
107109
{"vm_branch": "centos_7_amd64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
108110
{"vm_branch": "redhat", "vm_cpu": "arm64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
111+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
112+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
109113
]
110114
)
111115
def test_remove_ld_preload(self, virtual_machine):

Diff for: tests/auto_inject/test_auto_inject_install.py

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class TestHostAutoInjectInstallScript(base.AutoInjectBaseTest):
1313
{"vm_branch": "amazon_linux2", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
1414
{"vm_branch": "centos_7_amd64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
1515
{"vm_branch": "redhat", "vm_cpu": "arm64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
16+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
17+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
1618
]
1719
)
1820
def test_install(self, virtual_machine):
@@ -37,6 +39,7 @@ class TestSimpleInstallerAutoInjectManualProfiling(base.AutoInjectBaseTest):
3739
{"vm_name": "Ubuntu_24_amd64", "weblog-variant": "test-app-nodejs", "reason": "PROF-11264"},
3840
{"vm_name": "Ubuntu_24_arm64", "weblog-variant": "test-app-nodejs", "reason": "PROF-11264"},
3941
{"weblog_variant": "test-app-python-alpine", "reason": "PROF-11296"},
42+
{"weblog_variant": "test-app-python", "reason": "INPLAT-479"},
4043
]
4144
)
4245
def test_profiling(self, virtual_machine):
@@ -53,6 +56,8 @@ class TestHostAutoInjectInstallScriptProfiling(base.AutoInjectBaseTest):
5356
{"vm_cpu": "arm64", "weblog_variant": "test-app-dotnet", "reason": "PROF-10783"},
5457
{"vm_name": "Ubuntu_24_amd64", "weblog-variant": "test-app-nodejs", "reason": "PROF-11264"},
5558
{"vm_name": "Ubuntu_24_arm64", "weblog-variant": "test-app-nodejs", "reason": "PROF-11264"},
59+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
60+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
5661
]
5762
)
5863
def test_profiling(self, virtual_machine):
@@ -158,6 +163,8 @@ class TestInstallerAutoInjectManual(base.AutoInjectBaseTest):
158163
{"vm_branch": "amazon_linux2", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
159164
{"vm_branch": "centos_7_amd64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
160165
{"vm_branch": "redhat", "vm_cpu": "arm64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
166+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
167+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
161168
]
162169
)
163170
def test_install_uninstall(self, virtual_machine):
@@ -178,6 +185,8 @@ class TestSimpleInstallerAutoInjectManual(base.AutoInjectBaseTest):
178185
{"vm_branch": "amazon_linux2", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
179186
{"vm_branch": "centos_7_amd64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
180187
{"vm_branch": "redhat", "vm_cpu": "arm64", "weblog_variant": "test-app-ruby", "reason": "INPLAT-103"},
188+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
189+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
181190
]
182191
)
183192
def test_install(self, virtual_machine):

Diff for: tests/auto_inject/test_blocklist_auto_inject.py

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class TestAutoInjectBlockListInstallManualHost(_AutoInjectBlockListBaseTest):
7373
{"vm_branch": "amazon_linux2", "library": "ruby", "reason": "INPLAT-103"},
7474
{"vm_branch": "centos_7_amd64", "library": "ruby", "reason": "INPLAT-103"},
7575
{"vm_branch": "redhat", "vm_cpu": "arm64", "library": "ruby", "reason": "INPLAT-103"},
76+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
77+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
7678
]
7779
)
7880
@irrelevant(
@@ -93,6 +95,8 @@ def test_builtIn_block_commands(self, virtual_machine):
9395
{"vm_branch": "amazon_linux2", "library": "ruby", "reason": "INPLAT-103"},
9496
{"vm_branch": "centos_7_amd64", "library": "ruby", "reason": "INPLAT-103"},
9597
{"vm_branch": "redhat", "vm_cpu": "arm64", "library": "ruby", "reason": "INPLAT-103"},
98+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
99+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
96100
]
97101
)
98102
@irrelevant(
@@ -115,6 +119,8 @@ def test_builtIn_block_args(self, virtual_machine):
115119
{"vm_branch": "amazon_linux2", "library": "ruby", "reason": "INPLAT-103"},
116120
{"vm_branch": "centos_7_amd64", "library": "ruby", "reason": "INPLAT-103"},
117121
{"vm_branch": "redhat", "vm_cpu": "arm64", "library": "ruby", "reason": "INPLAT-103"},
122+
{"vm_name": "Ubuntu_24_10_amd64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
123+
{"vm_name": "Ubuntu_24_10_arm64", "weblog_variant": "test-app-python", "reason": "INPLAT-478"},
118124
]
119125
)
120126
@irrelevant(

Diff for: tests/debugger/test_debugger_exception_replay.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def skip_runtime(value, skip_condition, del_filename=None):
153153

154154
return __scrub(value)
155155

156-
def __scrub_dotnet(key, value, parent):
156+
def __scrub_dotnet(key, value, parent): # noqa: ARG001
157157
if key == "Id":
158158
return "<scrubbed>"
159159
elif key == "StackTrace" and isinstance(value, dict):
@@ -178,7 +178,7 @@ def __scrub_dotnet(key, value, parent):
178178
return scrubbed
179179
return __scrub(value)
180180

181-
def __scrub_python(key, value, parent):
181+
def __scrub_python(key, value, parent): # noqa: ARG001
182182
if key == "@exception":
183183
value["fields"] = "<scrubbed>"
184184
return value
@@ -199,7 +199,7 @@ def __scrub_python(key, value, parent):
199199
return scrubbed
200200
return __scrub(value)
201201

202-
def __scrub_none(key, value, parent):
202+
def __scrub_none(key, value, parent): # noqa: ARG001
203203
return __scrub(value)
204204

205205
scrub_language = None

0 commit comments

Comments
 (0)