Skip to content

Commit 8984d17

Browse files
Updated ASM rules to 1.13.1 (#7831)
* Updated ASM rules to 1.13.1
1 parent 7010cb8 commit 8984d17

File tree

4 files changed

+68
-12
lines changed

4 files changed

+68
-12
lines changed

dd-java-agent/appsec/src/main/resources/default_config.json

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "2.2",
33
"metadata": {
4-
"rules_version": "1.13.0"
4+
"rules_version": "1.13.1"
55
},
66
"rules": [
77
{
@@ -6239,7 +6239,6 @@
62396239
{
62406240
"id": "rasp-930-100",
62416241
"name": "Local file inclusion exploit",
6242-
"enabled": false,
62436242
"tags": {
62446243
"type": "lfi",
62456244
"category": "vulnerability_trigger",
@@ -6287,8 +6286,7 @@
62876286
},
62886287
{
62896288
"id": "rasp-932-100",
6290-
"name": "Shell injection exploit",
6291-
"enabled": false,
6289+
"name": "Command injection exploit",
62926290
"tags": {
62936291
"type": "command_injection",
62946292
"category": "vulnerability_trigger",
@@ -6385,7 +6383,7 @@
63856383
},
63866384
{
63876385
"id": "rasp-942-100",
6388-
"name": "SQL injection exploit",
6386+
"name": "SQL injection exploit (legacy)",
63896387
"enabled": false,
63906388
"tags": {
63916389
"type": "sql_injection",
@@ -6395,6 +6393,7 @@
63956393
"confidence": "0",
63966394
"module": "rasp"
63976395
},
6396+
"max_version": "1.19.1",
63986397
"conditions": [
63996398
{
64006399
"parameters": {
@@ -6434,6 +6433,58 @@
64346433
"stack_trace"
64356434
]
64366435
},
6436+
{
6437+
"id": "rasp-942-110",
6438+
"name": "SQL injection exploit",
6439+
"enabled": false,
6440+
"tags": {
6441+
"type": "sql_injection",
6442+
"category": "vulnerability_trigger",
6443+
"cwe": "89",
6444+
"capec": "1000/152/248/66",
6445+
"confidence": "0",
6446+
"module": "rasp"
6447+
},
6448+
"min_version": "1.20.0",
6449+
"conditions": [
6450+
{
6451+
"parameters": {
6452+
"resource": [
6453+
{
6454+
"address": "server.db.statement"
6455+
}
6456+
],
6457+
"params": [
6458+
{
6459+
"address": "server.request.query"
6460+
},
6461+
{
6462+
"address": "server.request.body"
6463+
},
6464+
{
6465+
"address": "server.request.path_params"
6466+
},
6467+
{
6468+
"address": "graphql.server.all_resolvers"
6469+
},
6470+
{
6471+
"address": "graphql.server.resolver"
6472+
}
6473+
],
6474+
"db_type": [
6475+
{
6476+
"address": "server.db.system"
6477+
}
6478+
]
6479+
},
6480+
"operator": "sqli_detector@v2"
6481+
}
6482+
],
6483+
"transformers": [],
6484+
"on_match": [
6485+
"stack_trace"
6486+
]
6487+
},
64376488
{
64386489
"id": "sqr-000-001",
64396490
"name": "SSRF: Try to access the credential manager of the main cloud services",
@@ -9780,4 +9831,4 @@
97809831
}
97819832
}
97829833
]
9783-
}
9834+
}

dd-smoke-tests/appsec/springboot-grpc/src/test/groovy/datadog/smoketest/appsec/ServerMethodTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ServerMethodTest extends AbstractSpringBootWithGRPCAppSecTest {
1515
ProcessBuilder createProcessBuilder() {
1616
// We run this here to ensure it runs before starting the process. Child setupSpec runs after parent setupSpec,
1717
// so it is not a valid location.
18-
appendRules(customRulesPath, [
18+
mergeRules(customRulesPath, [
1919
[
2020
id : '__test_server_method_bock',
2121
name : 'test rule to block on server method',

dd-smoke-tests/appsec/springboot/src/test/groovy/datadog/smoketest/appsec/SpringBootSmokeTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
1818

1919
def prepareCustomRules() {
2020
// Prepare ruleset with additional test rules
21-
appendRules(
21+
mergeRules(
2222
customRulesPath,
2323
[
2424
[
@@ -108,7 +108,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
108108
on_match : ['block']
109109
],
110110
[
111-
id : '__test_lfi_block',
111+
id : 'rasp-930-100', // to replace default rule
112112
name : 'Local File Inclusion exploit',
113113
enable : 'true',
114114
tags : [
@@ -439,7 +439,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
439439
assert rootSpan.meta.get('_dd.appsec.json') != null, '_dd.appsec.json is not set'
440440
def trigger = null
441441
for (t in rootSpan.triggers) {
442-
if (t['rule']['id'] == '__test_lfi_block') {
442+
if (t['rule']['id'] == 'rasp-930-100') {
443443
trigger = t
444444
break
445445
}

dd-smoke-tests/appsec/src/main/groovy/datadog/smoketest/appsec/AbstractAppSecServerSmokeTest.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,21 @@ abstract class AbstractAppSecServerSmokeTest extends AbstractServerSmokeTest {
8282
}
8383

8484
/**
85-
* This method fetches default ruleset included in the agent and appends the selected rules, then it points
85+
* This method fetches default ruleset included in the agent and merges the selected rules, then it points
8686
* the {@code dd.appsec.rules} variable to the new file
8787
*/
88-
void appendRules(final String path, final List<Map<String, Object>> customRules) {
88+
void mergeRules(final String path, final List<Map<String, Object>> customRules) {
8989
// Prepare a file with the new rules
9090
final jarFile = new JarFile(shadowJarPath)
9191
final zipEntry = jarFile.getEntry("appsec/default_config.json")
9292
final content = IOUtils.toString(jarFile.getInputStream(zipEntry), StandardCharsets.UTF_8)
9393
final json = new JsonSlurper().parseText(content) as Map<String, Object>
9494
final rules = json.rules as List<Map<String, Object>>
95+
96+
// remove already existing rules for merge
97+
List<Object> customRulesNames = customRules.collect { it.id }
98+
rules.removeIf { it.id in customRulesNames }
99+
95100
rules.addAll(customRules)
96101
final gen = new JsonGenerator.Options().build()
97102
IOUtils.write(gen.toJson(json), new FileOutputStream(path, false), StandardCharsets.UTF_8)

0 commit comments

Comments
 (0)