Skip to content

Commit 5be2cd4

Browse files
committed
Address review comments
1 parent 326233e commit 5be2cd4

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const storedBodies = new WeakMap()
4848
let isEnabled = false
4949
let config
5050

51-
function enable (_config) {
51+
function enable (_config, rc) {
5252
if (isEnabled) return
5353

5454
try {
@@ -63,7 +63,10 @@ function enable (_config) {
6363

6464
RuleManager.loadRules(_config.appsec)
6565

66-
appsecRemoteConfig.enableWafUpdate(_config.appsec)
66+
if (rc) {
67+
appsecRemoteConfig.enable(rc, _config, module.exports)
68+
appsecRemoteConfig.enableWafUpdate(_config.appsec)
69+
}
6770

6871
Reporter.init(_config.appsec)
6972

packages/dd-trace/src/proxy.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,17 @@ class Tracer extends NoopProxy {
125125
spanleak.startScrubber()
126126
}
127127

128+
let rc
128129
if (config.remoteConfig.enabled && !config.isCiVisibility) {
129-
const rc = require('./remote_config').enable(config)
130+
rc = require('./remote_config').enable(config)
130131

131132
rc.setProductHandler('APM_TRACING', (action, conf) => {
132133
if (action === 'unapply') {
133134
config.configure({}, true)
134135
} else {
135136
config.configure(conf.lib_config, true)
136137
}
137-
this._enableOrDisableTracing(config)
138+
this._enableOrDisableTracing(config, rc)
138139
})
139140

140141
rc.setProductHandler('AGENT_CONFIG', (action, conf) => {
@@ -156,11 +157,6 @@ class Tracer extends NoopProxy {
156157
this._flare.module.send(conf.args)
157158
})
158159

159-
if (this._modules.appsec) {
160-
const appsecRemoteConfig = require('./appsec/remote_config')
161-
appsecRemoteConfig.enable(rc, config, this._modules.appsec)
162-
}
163-
164160
if (config.dynamicInstrumentation.enabled) {
165161
DynamicInstrumentation.start(config, rc)
166162
}
@@ -194,7 +190,7 @@ class Tracer extends NoopProxy {
194190
runtimeMetrics.start(config)
195191
}
196192

197-
this._enableOrDisableTracing(config)
193+
this._enableOrDisableTracing(config, rc)
198194

199195
this._modules.rewriter.enable(config)
200196

@@ -253,10 +249,10 @@ class Tracer extends NoopProxy {
253249
}
254250
}
255251

256-
_enableOrDisableTracing (config) {
252+
_enableOrDisableTracing (config, rc) {
257253
if (config.tracing !== false) {
258254
if (config.appsec.enabled) {
259-
this._modules.appsec.enable(config)
255+
this._modules.appsec.enable(config, rc)
260256
}
261257
if (config.llmobs.enabled) {
262258
this._modules.llmobs.enable(config)

packages/dd-trace/test/proxy.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ describe('TracerProxy', () => {
450450
const remoteConfigProxy = new RemoteConfigProxy()
451451
remoteConfigProxy.init()
452452

453-
sinon.assert.calledOnceWithExactly(appsec.enable, config)
453+
sinon.assert.calledOnceWithExactly(appsec.enable, config, rc)
454454
sinon.assert.calledOnceWithExactly(iast.enable, config, tracer)
455455

456456
let conf = { tracing_enabled: false }
@@ -461,7 +461,7 @@ describe('TracerProxy', () => {
461461
conf = { tracing_enabled: true }
462462
handlers.get('APM_TRACING')('apply', { lib_config: conf })
463463
sinon.assert.calledTwice(appsec.enable)
464-
sinon.assert.calledWithExactly(appsec.enable.secondCall, config)
464+
sinon.assert.calledWithExactly(appsec.enable.secondCall, config, rc)
465465
sinon.assert.calledTwice(iast.enable)
466466
sinon.assert.calledWithExactly(iast.enable.secondCall, config, tracer)
467467
})

0 commit comments

Comments
 (0)