Skip to content

Commit 24ad524

Browse files
CarlesDDrochdev
authored andcommitted
Bump native-appsec package + ASM multi DD config capability (#6049)
1 parent bcb4d92 commit 24ad524

File tree

11 files changed

+59
-46
lines changed

11 files changed

+59
-46
lines changed

integration-tests/appsec/graphql.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ describe('graphql', () => {
7272
const result = {
7373
triggers: [
7474
{
75-
rule:
76-
{
75+
rule: {
7776
id: 'test-rule-id-1',
7877
name: 'test-rule-name-1',
7978
tags:
8079
{
81-
category: 'attack_attempt',
82-
type: 'security_scanner'
83-
}
80+
type: 'security_scanner',
81+
category: 'attack_attempt'
82+
},
83+
on_match: []
8484
},
8585
rule_matches: [
8686
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
],
112112
"dependencies": {
113113
"@datadog/libdatadog": "0.7.0",
114-
"@datadog/native-appsec": "9.0.0",
114+
"@datadog/native-appsec": "10.0.0",
115115
"@datadog/native-iast-taint-tracking": "4.0.0",
116116
"@datadog/native-metrics": "3.1.1",
117117
"@datadog/pprof": "5.9.0",

packages/dd-trace/src/appsec/reporter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,21 +430,21 @@ function isRaspAttack (events) {
430430
return events.some(e => e.rule?.tags?.module === 'rasp')
431431
}
432432

433-
function isFingerprintDerivative (derivative) {
434-
return derivative.startsWith('_dd.appsec.fp')
433+
function isFingerprintAttribute (attribute) {
434+
return attribute.startsWith('_dd.appsec.fp')
435435
}
436436

437-
function reportDerivatives (derivatives) {
438-
if (!derivatives) return
437+
function reportAttributes (attributes) {
438+
if (!attributes) return
439439

440440
const req = storage('legacy').getStore()?.req
441441
const rootSpan = web.root(req)
442442

443443
if (!rootSpan) return
444444

445445
const tags = {}
446-
for (let [tag, value] of Object.entries(derivatives)) {
447-
if (!isFingerprintDerivative(tag)) {
446+
for (let [tag, value] of Object.entries(attributes)) {
447+
if (!isFingerprintAttribute(tag)) {
448448
const gzippedValue = zlib.gzipSync(JSON.stringify(value))
449449
value = gzippedValue.toString('base64')
450450
}
@@ -543,7 +543,7 @@ module.exports = {
543543
reportAttack,
544544
reportWafUpdate: incrementWafUpdatesMetric,
545545
reportRaspRuleSkipped: updateRaspRuleSkippedMetricTags,
546-
reportDerivatives,
546+
reportAttributes,
547547
finishRequest,
548548
mapHeaderAndTags,
549549
truncateRequestBody

packages/dd-trace/src/appsec/waf/waf_context_wrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class WAFContextWrapper {
135135
this.setUserIdCache(userId, result)
136136
}
137137

138-
metrics.duration = result.totalRuntime / 1e3
138+
metrics.duration = result.duration / 1e3
139139
metrics.blockTriggered = blockTriggered
140140
metrics.ruleTriggered = ruleTriggered
141141
metrics.wafTimeout = result.timeout
@@ -144,7 +144,7 @@ class WAFContextWrapper {
144144
Reporter.reportAttack(result.events)
145145
}
146146

147-
Reporter.reportDerivatives(result.derivatives)
147+
Reporter.reportAttributes(result.attributes)
148148

149149
return result
150150
} catch (err) {

packages/dd-trace/src/remote_config/capabilities.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ module.exports = {
2727
ASM_SESSION_FINGERPRINT: 1n << 33n,
2828
ASM_NETWORK_FINGERPRINT: 1n << 34n,
2929
ASM_HEADER_FINGERPRINT: 1n << 35n,
30-
ASM_RASP_CMDI: 1n << 37n
30+
ASM_RASP_CMDI: 1n << 37n,
31+
ASM_DD_MULTICONFIG: 1n << 42n
3132
}

packages/dd-trace/src/remote_config/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function enableWafUpdate (appsecConfig) {
9393
rc.updateCapabilities(RemoteConfigCapabilities.ASM_SESSION_FINGERPRINT, true)
9494
rc.updateCapabilities(RemoteConfigCapabilities.ASM_NETWORK_FINGERPRINT, true)
9595
rc.updateCapabilities(RemoteConfigCapabilities.ASM_HEADER_FINGERPRINT, true)
96+
rc.updateCapabilities(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, true)
9697

9798
if (appsecConfig.rasp?.enabled) {
9899
rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SQLI, true)
@@ -128,6 +129,7 @@ function disableWafUpdate () {
128129
rc.updateCapabilities(RemoteConfigCapabilities.ASM_SESSION_FINGERPRINT, false)
129130
rc.updateCapabilities(RemoteConfigCapabilities.ASM_NETWORK_FINGERPRINT, false)
130131
rc.updateCapabilities(RemoteConfigCapabilities.ASM_HEADER_FINGERPRINT, false)
132+
rc.updateCapabilities(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, false)
131133

132134
rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SQLI, false)
133135
rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SSRF, false)

packages/dd-trace/test/appsec/reporter.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,20 +696,20 @@ describe('reporter', () => {
696696
})
697697
})
698698

699-
describe('reportDerivatives', () => {
699+
describe('reportAttributes', () => {
700700
it('should not call addTags if parameter is undefined', () => {
701-
Reporter.reportDerivatives(undefined)
701+
Reporter.reportAttributes(undefined)
702702
expect(span.addTags).not.to.be.called
703703
})
704704

705705
it('should call addTags with an empty array', () => {
706-
Reporter.reportDerivatives([])
706+
Reporter.reportAttributes([])
707707
expect(span.addTags).to.be.calledOnceWithExactly({})
708708
})
709709

710710
it('should call addTags', () => {
711711
const schemaValue = [{ key: [8] }]
712-
const derivatives = {
712+
const attributes = {
713713
'_dd.appsec.fp.http.endpoint': 'endpoint_fingerprint',
714714
'_dd.appsec.fp.http.header': 'header_fingerprint',
715715
'_dd.appsec.fp.http.network': 'network_fingerprint',
@@ -722,7 +722,7 @@ describe('reporter', () => {
722722
'custom.processor.output': schemaValue
723723
}
724724

725-
Reporter.reportDerivatives(derivatives)
725+
Reporter.reportAttributes(attributes)
726726

727727
const schemaEncoded = zlib.gzipSync(JSON.stringify(schemaValue)).toString('base64')
728728
expect(span.addTags).to.be.calledOnceWithExactly({

packages/dd-trace/test/appsec/waf/index.spec.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('WAF Manager', () => {
4949
sinon.stub(Reporter.metricsQueue, 'set')
5050
sinon.stub(Reporter, 'reportMetrics')
5151
sinon.stub(Reporter, 'reportAttack')
52-
sinon.stub(Reporter, 'reportDerivatives')
52+
sinon.stub(Reporter, 'reportAttributes')
5353
sinon.spy(Reporter, 'reportWafInit')
5454
sinon.spy(Reporter, 'reportWafConfigUpdate')
5555

@@ -333,7 +333,7 @@ describe('WAF Manager', () => {
333333
})
334334

335335
it('should call ddwafContext.run with params', () => {
336-
ddwafContext.run.returns({ totalRuntime: 1, durationExt: 1 })
336+
ddwafContext.run.returns({ duration: 1, durationExt: 1 })
337337

338338
wafContextWrapper.run({
339339
persistent: {
@@ -354,7 +354,7 @@ describe('WAF Manager', () => {
354354

355355
it('should report attack when ddwafContext returns events', () => {
356356
const result = {
357-
totalRuntime: 1,
357+
duration: 1,
358358
durationExt: 1,
359359
events: ['ATTACK DATA']
360360
}
@@ -373,7 +373,7 @@ describe('WAF Manager', () => {
373373

374374
it('should report if rule is triggered', () => {
375375
const result = {
376-
totalRuntime: 1,
376+
duration: 1,
377377
durationExt: 1,
378378
events: ['ruleTriggered']
379379
}
@@ -395,7 +395,7 @@ describe('WAF Manager', () => {
395395

396396
it('should report raspRuleType', () => {
397397
const result = {
398-
totalRuntime: 1,
398+
duration: 1,
399399
durationExt: 1
400400
}
401401

@@ -414,7 +414,7 @@ describe('WAF Manager', () => {
414414

415415
it('should not report raspRuleType when it is not provided', () => {
416416
const result = {
417-
totalRuntime: 1,
417+
duration: 1,
418418
durationExt: 1
419419
}
420420

@@ -432,7 +432,7 @@ describe('WAF Manager', () => {
432432
})
433433

434434
it('should not report attack when ddwafContext does not return events', () => {
435-
ddwafContext.run.returns({ totalRuntime: 1, durationExt: 1 })
435+
ddwafContext.run.returns({ duration: 1, durationExt: 1 })
436436
const params = {
437437
persistent: {
438438
'server.request.headers.no_cookies': { header: 'value' }
@@ -445,7 +445,7 @@ describe('WAF Manager', () => {
445445
})
446446

447447
it('should not report attack when ddwafContext returns empty data', () => {
448-
ddwafContext.run.returns({ totalRuntime: 1, durationExt: 1, events: [] })
448+
ddwafContext.run.returns({ duration: 1, durationExt: 1, events: [] })
449449
const params = {
450450
persistent: {
451451
'server.request.headers.no_cookies': { header: 'value' }
@@ -459,7 +459,7 @@ describe('WAF Manager', () => {
459459

460460
it('should return waf result', () => {
461461
const result = {
462-
totalRuntime: 1, durationExt: 1, events: [], actions: ['block']
462+
duration: 1, durationExt: 1, events: [], actions: ['block']
463463
}
464464
ddwafContext.run.returns(result)
465465

@@ -474,11 +474,11 @@ describe('WAF Manager', () => {
474474
expect(wafResult).to.be.equals(result)
475475
})
476476

477-
it('should report schemas when ddwafContext returns schemas in the derivatives', () => {
477+
it('should report schemas when ddwafContext returns schemas in the attributes', () => {
478478
const result = {
479-
totalRuntime: 1,
479+
duration: 1,
480480
durationExt: 1,
481-
derivatives: [{ '_dd.appsec.s.req.body': [8] }]
481+
attributes: [{ '_dd.appsec.s.req.body': [8] }]
482482
}
483483
const params = {
484484
persistent: {
@@ -492,14 +492,14 @@ describe('WAF Manager', () => {
492492
ddwafContext.run.returns(result)
493493

494494
wafContextWrapper.run(params)
495-
expect(Reporter.reportDerivatives).to.be.calledOnceWithExactly(result.derivatives)
495+
expect(Reporter.reportAttributes).to.be.calledOnceWithExactly(result.attributes)
496496
})
497497

498-
it('should report fingerprints when ddwafContext returns fingerprints in results derivatives', () => {
498+
it('should report fingerprints when ddwafContext returns fingerprints in results attributes', () => {
499499
const result = {
500-
totalRuntime: 1,
500+
duration: 1,
501501
durationExt: 1,
502-
derivatives: {
502+
attributes: {
503503
'_dd.appsec.s.req.body': [8],
504504
'_dd.appsec.fp.http.endpoint': 'http-post-abcdefgh-12345678-abcdefgh',
505505
'_dd.appsec.fp.http.network': 'net-1-0100000000',
@@ -514,7 +514,7 @@ describe('WAF Manager', () => {
514514
'server.request.body': 'foo'
515515
}
516516
})
517-
sinon.assert.calledOnceWithExactly(Reporter.reportDerivatives, result.derivatives)
517+
sinon.assert.calledOnceWithExactly(Reporter.reportAttributes, result.attributes)
518518
})
519519
})
520520
})

packages/dd-trace/test/appsec/waf/waf_context_wrapper.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('WAFContextWrapper', () => {
2525
const ddwafContext = {
2626
run: sinon.stub().returns({
2727
events: {},
28-
derivatives: {}
28+
attributes: {}
2929
})
3030
}
3131
const wafContextWrapper = new WAFContextWrapper(ddwafContext, 1000, '1.14.0', '1.8.0', knownAddresses)
@@ -72,7 +72,7 @@ describe('WAFContextWrapper', () => {
7272
const ddwafContext = {
7373
run: sinon.stub().returns({
7474
events: {},
75-
derivatives: {}
75+
attributes: {}
7676
})
7777
}
7878
const wafContextWrapper = new WAFContextWrapper(ddwafContext, 1000, '1.14.0', '1.8.0', knownAddresses)
@@ -178,13 +178,13 @@ describe('WAFContextWrapper', () => {
178178
const ddwafContext = {
179179
run: sinon.stub().returns({
180180
events: [{ rule_matches: [] }],
181-
derivatives: [],
181+
attributes: [],
182182
actions: {
183183
redirect_request: {
184184
status_code: 301
185185
}
186186
},
187-
totalRuntime: 123456,
187+
duration: 123456,
188188
timeout: false,
189189
metrics: {
190190
maxTruncatedString: 5000,

packages/dd-trace/test/remote_config/index.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ describe('Remote Config index', () => {
248248
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_SHI, true)
249249
expect(rc.updateCapabilities)
250250
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_CMDI, true)
251+
expect(rc.updateCapabilities)
252+
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, true)
251253

252254
expect(rc.setProductHandler).to.have.been.calledWith('ASM_DATA')
253255
expect(rc.setProductHandler).to.have.been.calledWith('ASM_DD')
@@ -296,6 +298,8 @@ describe('Remote Config index', () => {
296298
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_SHI, true)
297299
expect(rc.updateCapabilities)
298300
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_CMDI, true)
301+
expect(rc.updateCapabilities)
302+
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, true)
299303

300304
expect(rc.setProductHandler).to.have.been.calledWith('ASM_DATA')
301305
expect(rc.setProductHandler).to.have.been.calledWith('ASM_DD')
@@ -346,6 +350,8 @@ describe('Remote Config index', () => {
346350
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_SHI, true)
347351
expect(rc.updateCapabilities)
348352
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_CMDI, true)
353+
expect(rc.updateCapabilities)
354+
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, true)
349355
})
350356

351357
it('should not activate rasp capabilities if rasp is disabled', () => {
@@ -391,6 +397,8 @@ describe('Remote Config index', () => {
391397
.to.not.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_SHI)
392398
expect(rc.updateCapabilities)
393399
.to.not.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_CMDI)
400+
expect(rc.updateCapabilities)
401+
.to.not.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_DD_MULTICONFIG)
394402
})
395403
})
396404

@@ -436,6 +444,8 @@ describe('Remote Config index', () => {
436444
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_SHI, false)
437445
expect(rc.updateCapabilities)
438446
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_RASP_CMDI, false)
447+
expect(rc.updateCapabilities)
448+
.to.have.been.calledWithExactly(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, false)
439449

440450
expect(rc.removeProductHandler).to.have.been.calledWith('ASM_DATA')
441451
expect(rc.removeProductHandler).to.have.been.calledWith('ASM_DD')

0 commit comments

Comments
 (0)