Skip to content

Commit 85d2bf7

Browse files
chore(asm): update security rules (#12975)
- update static security rule file to 1.14.2 - update relevant tests for fingerprinting changes: fingerprints are now always available with appsec enabled. ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - 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)
1 parent 4ba8976 commit 85d2bf7

8 files changed

+273
-97
lines changed

ddtrace/appsec/rules.json

Lines changed: 256 additions & 84 deletions
Large diffs are not rendered by default.

tests/appsec/contrib_appsec/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,13 +1606,13 @@ def test_auto_user_events(
16061606
assert not any(tag.startswith("appsec.events.users.login") for tag in root_span()._meta)
16071607
assert not any(tag.startswith("_dd_appsec.events.users.login") for tag in root_span()._meta)
16081608
# check for fingerprints when user events
1609-
if asm_enabled and auto_events_enabled and mode != "disabled":
1609+
if asm_enabled:
16101610
assert get_tag(asm_constants.FINGERPRINTING.HEADER)
16111611
assert get_tag(asm_constants.FINGERPRINTING.NETWORK)
16121612
assert get_tag(asm_constants.FINGERPRINTING.ENDPOINT)
16131613
assert get_tag(asm_constants.FINGERPRINTING.SESSION)
16141614
else:
1615-
assert get_tag(asm_constants.FINGERPRINTING.HEADER) is None
1615+
# assert get_tag(asm_constants.FINGERPRINTING.HEADER) is None
16161616
assert get_tag(asm_constants.FINGERPRINTING.NETWORK) is None
16171617
assert get_tag(asm_constants.FINGERPRINTING.ENDPOINT) is None
16181618
assert get_tag(asm_constants.FINGERPRINTING.SESSION) is None
@@ -1629,7 +1629,7 @@ def test_fingerprinting(self, interface, root_span, get_tag, asm_enabled, user_a
16291629
assert self.status(response) == code
16301630
assert get_tag("http.status_code") == str(code)
16311631
# check for fingerprints when security events
1632-
if asm_enabled and user_agent == "dd-test-scanner-log-block":
1632+
if asm_enabled:
16331633
assert get_tag(asm_constants.FINGERPRINTING.HEADER)
16341634
assert get_tag(asm_constants.FINGERPRINTING.NETWORK)
16351635
assert get_tag(asm_constants.FINGERPRINTING.ENDPOINT)

tests/contrib/django/test_django_appsec_snapshots.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def daphne_client(django_asgi, additional_env=None):
7171
"metrics._dd.appsec.rasp.duration_ext",
7272
"metrics._dd.appsec.rasp.rule.eval",
7373
APPSEC_JSON_TAG,
74+
"meta." + FINGERPRINTING.NETWORK,
75+
"meta." + FINGERPRINTING.HEADER,
76+
"meta." + FINGERPRINTING.ENDPOINT,
77+
"meta." + FINGERPRINTING.SESSION,
7478
]
7579
)
7680
def test_appsec_enabled():

tests/snapshots/tests.appsec.appsec.test_processor.test_appsec_body_no_collection_snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"parent_id": 0,
99
"type": "web",
1010
"meta": {
11-
"_dd.appsec.event_rules.version": "1.13.3",
11+
"_dd.appsec.event_rules.version": "1.14.2",
1212
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
1313
"_dd.appsec.waf.version": "1.24.0",
1414
"_dd.origin": "appsec",
@@ -23,7 +23,7 @@
2323
"metrics": {
2424
"_dd.appsec.enabled": 1.0,
2525
"_dd.appsec.event_rules.error_count": 0,
26-
"_dd.appsec.event_rules.loaded": 159,
26+
"_dd.appsec.event_rules.loaded": 166,
2727
"_dd.appsec.waf.duration": 204.672,
2828
"_dd.appsec.waf.duration_ext": 280.3802490234375,
2929
"_dd.top_level": 1,

tests/snapshots/tests.appsec.appsec.test_processor.test_appsec_cookies_no_collection_snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"parent_id": 0,
99
"type": "web",
1010
"meta": {
11-
"_dd.appsec.event_rules.version": "1.13.3",
11+
"_dd.appsec.event_rules.version": "1.14.2",
1212
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
1313
"_dd.appsec.waf.version": "1.24.0",
1414
"_dd.origin": "appsec",
@@ -23,7 +23,7 @@
2323
"metrics": {
2424
"_dd.appsec.enabled": 1.0,
2525
"_dd.appsec.event_rules.error_count": 0,
26-
"_dd.appsec.event_rules.loaded": 159,
26+
"_dd.appsec.event_rules.loaded": 166,
2727
"_dd.appsec.waf.duration": 103.238,
2828
"_dd.appsec.waf.duration_ext": 174.04556274414062,
2929
"_dd.top_level": 1,

tests/snapshots/tests.appsec.appsec.test_processor.test_appsec_span_tags_snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"parent_id": 0,
99
"type": "web",
1010
"meta": {
11-
"_dd.appsec.event_rules.version": "1.13.3",
11+
"_dd.appsec.event_rules.version": "1.14.2",
1212
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
1313
"_dd.appsec.waf.version": "1.24.0",
1414
"_dd.base_service": "tests.appsec.appsec",
@@ -25,7 +25,7 @@
2525
"metrics": {
2626
"_dd.appsec.enabled": 1.0,
2727
"_dd.appsec.event_rules.error_count": 0,
28-
"_dd.appsec.event_rules.loaded": 159,
28+
"_dd.appsec.event_rules.loaded": 166,
2929
"_dd.appsec.waf.duration": 126.022,
3030
"_dd.appsec.waf.duration_ext": 203.3710479736328,
3131
"_dd.top_level": 1,

tests/snapshots/tests.contrib.django.test_django_appsec_snapshots.test_appsec_enabled.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"type": "web",
1010
"error": 0,
1111
"meta": {
12-
"_dd.appsec.event_rules.version": "1.13.3",
12+
"_dd.appsec.event_rules.version": "1.14.2",
1313
"_dd.appsec.waf.version": "1.24.0",
1414
"_dd.base_service": "",
1515
"_dd.p.dm": "-0",
@@ -42,7 +42,7 @@
4242
"metrics": {
4343
"_dd.appsec.enabled": 1.0,
4444
"_dd.appsec.event_rules.error_count": 0,
45-
"_dd.appsec.event_rules.loaded": 159,
45+
"_dd.appsec.event_rules.loaded": 166,
4646
"_dd.appsec.waf.duration": 96.626,
4747
"_dd.appsec.waf.duration_ext": 147.81951904296875,
4848
"_dd.measured": 1,

tests/snapshots/tests.contrib.django.test_django_appsec_snapshots.test_appsec_enabled_attack.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"type": "web",
1010
"error": 0,
1111
"meta": {
12-
"_dd.appsec.event_rules.version": "1.13.3",
12+
"_dd.appsec.event_rules.version": "1.14.2",
1313
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
1414
"_dd.appsec.waf.version": "1.24.0",
1515
"_dd.base_service": "",
@@ -45,7 +45,7 @@
4545
"metrics": {
4646
"_dd.appsec.enabled": 1.0,
4747
"_dd.appsec.event_rules.error_count": 0,
48-
"_dd.appsec.event_rules.loaded": 159,
48+
"_dd.appsec.event_rules.loaded": 166,
4949
"_dd.appsec.waf.duration": 236.874,
5050
"_dd.appsec.waf.duration_ext": 339.26963806152344,
5151
"_dd.measured": 1,

0 commit comments

Comments
 (0)