Skip to content

Commit

Permalink
refactor: move remote_config code to the root of dd-trace
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Jul 19, 2024
1 parent 1cf552f commit fa7998a
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/dd-trace/src/appsec/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const log = require('../log')
const RuleManager = require('./rule_manager')
const remoteConfig = require('./remote_config')
const remoteConfig = require('../remote_config')
const {
bodyParser,
cookieParser,
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/appsec/rule_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const fs = require('fs')
const waf = require('./waf')
const { ACKNOWLEDGED, ERROR } = require('./remote_config/apply_states')
const { ACKNOWLEDGED, ERROR } = require('../remote_config/apply_states')

let defaultRules

Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { setStartupLogPluginManager } = require('./startup-log')
const telemetry = require('./telemetry')
const nomenclature = require('./service-naming')
const PluginManager = require('./plugin_manager')
const remoteConfig = require('./appsec/remote_config')
const remoteConfig = require('./remote_config')
const AppsecSdk = require('./appsec/sdk')
const dogstatsd = require('./dogstatsd')
const NoopDogStatsDClient = require('./noop/dogstatsd')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const Activation = require('../activation')
const Activation = require('../appsec/activation')

const RemoteConfigManager = require('./manager')
const RemoteConfigCapabilities = require('./capabilities')
const apiSecuritySampler = require('../api_security_sampler')
const apiSecuritySampler = require('../appsec/api_security_sampler')

let rc

Expand Down Expand Up @@ -63,7 +63,7 @@ function enableOrDisableAppsec (action, rcConfig, config, appsec) {
function enableWafUpdate (appsecConfig) {
if (rc && appsecConfig && !appsecConfig.rules) {
// dirty require to make startup faster for serverless
const RuleManager = require('../rule_manager')
const RuleManager = require('../appsec/rule_manager')

rc.updateCapabilities(RemoteConfigCapabilities.ASM_IP_BLOCKING, true)
rc.updateCapabilities(RemoteConfigCapabilities.ASM_USER_BLOCKING, true)
Expand All @@ -86,7 +86,7 @@ function enableWafUpdate (appsecConfig) {

function disableWafUpdate () {
if (rc) {
const RuleManager = require('../rule_manager')
const RuleManager = require('../appsec/rule_manager')

rc.updateCapabilities(RemoteConfigCapabilities.ASM_IP_BLOCKING, false)
rc.updateCapabilities(RemoteConfigCapabilities.ASM_USER_BLOCKING, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
const { URL, format } = require('url')
const uuid = require('crypto-randomuuid')
const { EventEmitter } = require('events')
const tracerVersion = require('../../../../../package.json').version
const request = require('../../exporters/common/request')
const log = require('../../log')
const { getExtraServices } = require('../../service-naming/extra-services')
const tracerVersion = require('dd-trace/package.json').version
const request = require('../exporters/common/request')
const log = require('../log')
const { getExtraServices } = require('../service-naming/extra-services')
const { UNACKNOWLEDGED, ACKNOWLEDGED, ERROR } = require('./apply_states')
const Scheduler = require('./scheduler')

Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/appsec/rule_manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { loadRules, clearAllRules, updateWafFromRC } = require('../../src/appsec/rule_manager')
const Config = require('../../src/config')
const { ACKNOWLEDGED } = require('../../src/appsec/remote_config/apply_states')
const { ACKNOWLEDGED } = require('../../src/remote_config/apply_states')

const rules = require('../../src/appsec/recommended.json')
const waf = require('../../src/appsec/waf')
Expand Down
10 changes: 5 additions & 5 deletions packages/dd-trace/test/proxy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('TracerProxy', () => {
'./appsec': appsec,
'./appsec/iast': iast,
'./telemetry': telemetry,
'./appsec/remote_config': remoteConfig,
'./remote_config': remoteConfig,
'./appsec/sdk': AppsecSdk,
'./dogstatsd': dogStatsD,
'./noop/dogstatsd': NoopDogStatsDClient,
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('TracerProxy', () => {
'./tracer': DatadogTracer,
'./appsec': appsec,
'./appsec/iast': iast,
'./appsec/remote_config': remoteConfig,
'./remote_config': remoteConfig,
'./appsec/sdk': AppsecSdk
})

Expand Down Expand Up @@ -345,7 +345,7 @@ describe('TracerProxy', () => {
'./config': Config,
'./appsec': appsec,
'./appsec/iast': iast,
'./appsec/remote_config': remoteConfig,
'./remote_config': remoteConfig,
'./appsec/sdk': AppsecSdk
})

Expand Down Expand Up @@ -508,7 +508,7 @@ describe('TracerProxy', () => {
'./profiler': null, // this will cause the import failure error
'./appsec': appsec,
'./telemetry': telemetry,
'./appsec/remote_config': remoteConfig
'./remote_config': remoteConfig
})

const profilerImportFailureProxy = new ProfilerImportFailureProxy()
Expand All @@ -535,7 +535,7 @@ describe('TracerProxy', () => {
'./config': Config,
'./appsec': appsec,
'./appsec/iast': iast,
'./appsec/remote_config': remoteConfig,
'./remote_config': remoteConfig,
'./appsec/sdk': AppsecSdk,
'./appsec/standalone': standalone,
'./telemetry': telemetry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const RemoteConfigCapabilities = require('../../../src/appsec/remote_config/capabilities')
const { kPreUpdate } = require('../../../src/appsec/remote_config/manager')
const RemoteConfigCapabilities = require('../../src/remote_config/capabilities')
const { kPreUpdate } = require('../../src/remote_config/manager')

let config
let rc
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('Remote Config index', () => {
disable: sinon.spy()
}

remoteConfig = proxyquire('../src/appsec/remote_config', {
remoteConfig = proxyquire('../src/remote_config', {
'./manager': RemoteConfigManager,
'../rule_manager': RuleManager,
'../api_security_sampler': apiSecuritySampler,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const Capabilities = require('../../../src/appsec/remote_config/capabilities')
const { UNACKNOWLEDGED, ACKNOWLEDGED, ERROR } = require('../../../src/appsec/remote_config/apply_states')
const Capabilities = require('../../src/remote_config/capabilities')
const { UNACKNOWLEDGED, ACKNOWLEDGED, ERROR } = require('../../src/remote_config/apply_states')

const noop = () => {}

Expand Down Expand Up @@ -34,7 +34,7 @@ describe('RemoteConfigManager', () => {

extraServices = []

RemoteConfigManager = proxyquire('../src/appsec/remote_config/manager', {
RemoteConfigManager = proxyquire('../src/remote_config/manager', {
'crypto-randomuuid': uuid,
'./scheduler': Scheduler,
'../../../../../package.json': { version: '3.0.0' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const Scheduler = require('../../../src/appsec/remote_config/scheduler')
const Scheduler = require('../../src/remote_config/scheduler')

const INTERVAL = 5e3

Expand Down

0 comments on commit fa7998a

Please sign in to comment.