Skip to content

Update appsec rules from Remote Config#2654

Merged
simon-id merged 60 commits into
masterfrom
ugaitz/asm_dd-rules-update
Apr 26, 2023
Merged

Update appsec rules from Remote Config#2654
simon-id merged 60 commits into
masterfrom
ugaitz/asm_dd-rules-update

Conversation

@uurien

@uurien uurien commented Jan 4, 2023

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR adds the availability to update more waf configurations from Remote Configuration. It can update the rules based on new rules file coming in new RC ASM event or it can override previously configured rules or add exclusion with data received in ASM_DD RC event.

As we had a bit overengineered waf gateway code, this PR adds a new and simpler approach to do the same stuff.

TODO:

@codecov

codecov Bot commented Jan 4, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2654 (41cc9b2) into master (256271d) will decrease coverage by 0.16%.
The diff coverage is 94.63%.

@@            Coverage Diff             @@
##           master    #2654      +/-   ##
==========================================
- Coverage   87.35%   87.19%   -0.16%     
==========================================
  Files         319      317       -2     
  Lines       11534    11512      -22     
  Branches       33       33              
==========================================
- Hits        10075    10038      -37     
- Misses       1459     1474      +15     
Impacted Files Coverage Δ
packages/dd-trace/src/appsec/addresses.js 100.00% <ø> (ø)
.../dd-trace/src/appsec/remote_config/capabilities.js 100.00% <ø> (ø)
packages/dd-trace/src/appsec/rule_manager.js 88.99% <88.76%> (-11.01%) ⬇️
...ges/dd-trace/src/appsec/waf/waf_context_wrapper.js 92.00% <92.00%> (ø)
packages/dd-trace/src/appsec/waf/index.js 93.33% <93.33%> (ø)
packages/datadog-plugin-http/src/server.js 94.11% <100.00%> (ø)
packages/datadog-plugin-http2/src/server.js 96.15% <100.00%> (ø)
packages/dd-trace/src/appsec/channels.js 100.00% <100.00%> (ø)
packages/dd-trace/src/appsec/index.js 100.00% <100.00%> (ø)
.../dd-trace/src/appsec/remote_config/apply_states.js 100.00% <100.00%> (ø)
... and 5 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@uurien
uurien force-pushed the ugaitz/asm_dd-rules-update branch from e488c36 to 57c1e98 Compare January 4, 2023 16:05
@pr-commenter

pr-commenter Bot commented Jan 4, 2023

Copy link
Copy Markdown

Benchmarks

Comparing candidate commit cb0d967 in PR branch ugaitz/asm_dd-rules-update with baseline commit 256271d in branch master.

Found 2 performance improvements and 2 performance regressions! Performance is the same for 662 metrics, 42 unstable metrics.

scenario:appsec-appsec-enabled-with-attacks-14

  • 🟥 cpu_usage_percentage [+7.994%; +9.708%]
  • 🟩 execution_time [-45.367ms; -36.880ms] or [-10.359%; -8.421%]

scenario:appsec-appsec-enabled-with-attacks-16

  • 🟥 cpu_usage_percentage [+8.648%; +9.889%]
  • 🟩 execution_time [-46.419ms; -39.687ms] or [-10.342%; -8.842%]

@uurien
uurien force-pushed the ugaitz/asm_dd-rules-update branch 2 times, most recently from 15cca4c to 139d70a Compare January 4, 2023 17:04
@uurien
uurien force-pushed the ugaitz/asm_dd-rules-update branch from 139d70a to 4219955 Compare January 9, 2023 12:00
@uurien
uurien marked this pull request as ready for review January 9, 2023 12:00
@uurien
uurien requested a review from a team as a code owner January 9, 2023 12:00
Qard
Qard previously approved these changes Jan 9, 2023
Qard
Qard previously approved these changes Jan 11, 2023
Comment thread packages/dd-trace/src/appsec/remote_config/index.js Outdated
Comment thread packages/dd-trace/src/appsec/remote_config/index.js Outdated
@github-actions

github-actions Bot commented Jan 19, 2023

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 3.98 MB
Deduped: 64.2 MB
No deduping: 64.25 MB

Dependency sizes

name version self size total size
@datadog/native-iast-taint-tracking 1.4.0 14.89 MB 14.9 MB
@datadog/pprof 2.2.0 13.71 MB 14.59 MB
@datadog/native-appsec 3.1.0 13.31 MB 13.32 MB
@datadog/native-metrics 1.6.0 7.88 MB 7.89 MB
protobufjs 7.1.2 2.76 MB 6.55 MB
@datadog/native-iast-rewriter 2.0.1 2.09 MB 2.1 MB
opentracing 0.14.7 194.81 kB 194.81 kB
semver 7.3.8 88.2 kB 118.6 kB
@datadog/sketches-js 2.1.0 109.9 kB 109.9 kB
lodash.sortby 4.7.0 75.76 kB 75.76 kB
lru-cache 7.14.0 74.95 kB 74.95 kB
ipaddr.js 2.0.1 59.52 kB 59.52 kB
ignore 5.2.0 48.87 kB 48.87 kB
import-in-the-middle 1.3.5 34.34 kB 38.81 kB
istanbul-lib-coverage 3.2.0 29.34 kB 29.34 kB
retry 0.10.1 27.44 kB 27.44 kB
lodash.uniq 4.5.0 25.01 kB 25.01 kB
limiter 1.1.5 23.17 kB 23.17 kB
lodash.kebabcase 4.1.1 17.75 kB 17.75 kB
lodash.pick 4.4.0 16.33 kB 16.33 kB
node-abort-controller 3.0.1 14.33 kB 14.33 kB
crypto-randomuuid 1.0.0 11.18 kB 11.18 kB
diagnostics_channel 1.1.0 7.07 kB 7.07 kB
path-to-regexp 0.1.7 6.78 kB 6.78 kB
koalas 1.0.2 6.47 kB 6.47 kB
methods 1.1.2 5.29 kB 5.29 kB
module-details-from-path 1.0.3 4.47 kB 4.47 kB

🤖 This report was automatically generated by heaviest-objects-in-the-universe

Qard
Qard previously approved these changes Jan 19, 2023
@uurien
uurien requested a review from simon-id January 20, 2023 13:18
Comment thread packages/dd-trace/src/appsec/remote_config/index.js Outdated
Qard
Qard previously approved these changes Jan 20, 2023
Comment thread packages/dd-trace/src/appsec/rule_manager.js Outdated
Comment thread packages/dd-trace/test/appsec/remote_config/index.spec.js Outdated
Comment thread packages/dd-trace/test/appsec/remote_config/index.spec.js Outdated
Comment thread packages/dd-trace/test/appsec/remote_config/index.spec.js Outdated
@simon-id
simon-id marked this pull request as ready for review April 25, 2023 15:40
@hoolioh
hoolioh self-requested a review April 25, 2023 15:45
hoolioh
hoolioh previously approved these changes Apr 26, 2023
@hoolioh
hoolioh self-requested a review April 26, 2023 13:50
@simon-id
simon-id merged commit a0c2514 into master Apr 26, 2023
tlhunter added a commit that referenced this pull request Apr 27, 2023
CarlesDD pushed a commit that referenced this pull request Apr 28, 2023
* Add rules update and refactor whole waf

* move appsec channels file

* Add changes to work with libddwaf update method and support more RC properties

* update waf bindings to 3.1.0

* simplify reporter

* remove unnecesary virtual addresses

* cleanup outdated comment

* simplify incomingHttpStartHandler

* simplify waf_manager.js

* add pre update hook to RC manager

* update rc manager

* batch all waf update RC subscriptions

* put apply_states codes in a constant file

* inline function

* add update to waf manager

* completely rework RC waf updates

* renamed a few things in tests

* fix dc path

* fix webpack not parsing class fields

* lazy load everything

* fix unapply configs not being emitted

---------

Co-authored-by: simon-id <[email protected]>
Co-authored-by: Julio Gonzalez <[email protected]>
CarlesDD pushed a commit that referenced this pull request Apr 28, 2023
* Add rules update and refactor whole waf

* move appsec channels file

* Add changes to work with libddwaf update method and support more RC properties

* update waf bindings to 3.1.0

* simplify reporter

* remove unnecesary virtual addresses

* cleanup outdated comment

* simplify incomingHttpStartHandler

* simplify waf_manager.js

* add pre update hook to RC manager

* update rc manager

* batch all waf update RC subscriptions

* put apply_states codes in a constant file

* inline function

* add update to waf manager

* completely rework RC waf updates

* renamed a few things in tests

* fix dc path

* fix webpack not parsing class fields

* lazy load everything

* fix unapply configs not being emitted

---------

Co-authored-by: simon-id <[email protected]>
Co-authored-by: Julio Gonzalez <[email protected]>
CarlesDD pushed a commit that referenced this pull request Apr 28, 2023
* Add rules update and refactor whole waf

* move appsec channels file

* Add changes to work with libddwaf update method and support more RC properties

* update waf bindings to 3.1.0

* simplify reporter

* remove unnecesary virtual addresses

* cleanup outdated comment

* simplify incomingHttpStartHandler

* simplify waf_manager.js

* add pre update hook to RC manager

* update rc manager

* batch all waf update RC subscriptions

* put apply_states codes in a constant file

* inline function

* add update to waf manager

* completely rework RC waf updates

* renamed a few things in tests

* fix dc path

* fix webpack not parsing class fields

* lazy load everything

* fix unapply configs not being emitted

---------

Co-authored-by: simon-id <[email protected]>
Co-authored-by: Julio Gonzalez <[email protected]>
CarlesDD pushed a commit that referenced this pull request Apr 28, 2023
* Add rules update and refactor whole waf

* move appsec channels file

* Add changes to work with libddwaf update method and support more RC properties

* update waf bindings to 3.1.0

* simplify reporter

* remove unnecesary virtual addresses

* cleanup outdated comment

* simplify incomingHttpStartHandler

* simplify waf_manager.js

* add pre update hook to RC manager

* update rc manager

* batch all waf update RC subscriptions

* put apply_states codes in a constant file

* inline function

* add update to waf manager

* completely rework RC waf updates

* renamed a few things in tests

* fix dc path

* fix webpack not parsing class fields

* lazy load everything

* fix unapply configs not being emitted

---------

Co-authored-by: simon-id <[email protected]>
Co-authored-by: Julio Gonzalez <[email protected]>
@simon-id
simon-id deleted the ugaitz/asm_dd-rules-update branch January 8, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants