From 5e4900d794722e85c8a3a825aeb6713861941af2 Mon Sep 17 00:00:00 2001 From: simon-id Date: Fri, 18 Oct 2024 10:07:17 +0200 Subject: [PATCH] don't update waf version if it dosn't exist (#4801) --- packages/dd-trace/src/appsec/waf/waf_manager.js | 4 +++- packages/dd-trace/test/appsec/waf/index.spec.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/dd-trace/src/appsec/waf/waf_manager.js b/packages/dd-trace/src/appsec/waf/waf_manager.js index 754f11815ff..b3cc91e6104 100644 --- a/packages/dd-trace/src/appsec/waf/waf_manager.js +++ b/packages/dd-trace/src/appsec/waf/waf_manager.js @@ -51,7 +51,9 @@ class WAFManager { update (newRules) { this.ddwaf.update(newRules) - this.rulesVersion = this.ddwaf.diagnostics.ruleset_version + if (this.ddwaf.diagnostics.ruleset_version) { + this.rulesVersion = this.ddwaf.diagnostics.ruleset_version + } Reporter.reportWafUpdate(this.ddwafVersion, this.rulesVersion) } diff --git a/packages/dd-trace/test/appsec/waf/index.spec.js b/packages/dd-trace/test/appsec/waf/index.spec.js index 0d4fbe55e32..aff0a7e37a0 100644 --- a/packages/dd-trace/test/appsec/waf/index.spec.js +++ b/packages/dd-trace/test/appsec/waf/index.spec.js @@ -181,6 +181,7 @@ describe('WAF Manager', () => { waf.update(rules) expect(DDWAF.prototype.update).to.be.calledOnceWithExactly(rules) + expect(Reporter.reportWafUpdate).to.be.calledOnceWithExactly(wafVersion, '1.0.0') }) it('should call Reporter.reportWafUpdate', () => {