Module: Datadog::AppSec::Processor::RuleMerger
- Defined in:
- lib/datadog/appsec/processor/rule_merger.rb
Overview
RuleMerger merge different sources of information into the rules payload
Defined Under Namespace
Classes: RuleVersionMismatchError
Class Method Summary collapse
- .default_waf_processors ⇒ Object
- .default_waf_scanners ⇒ Object
-
.merge(telemetry:, rules:, data: [], overrides: [], exclusions: [], custom_rules: [], processors: nil, scanners: nil) ⇒ Object
TODO: ‘processors` and `scanners` are not provided by the caller, consider removing them.
Class Method Details
.default_waf_processors ⇒ Object
66 67 68 |
# File 'lib/datadog/appsec/processor/rule_merger.rb', line 66 def default_waf_processors @default_waf_processors ||= JSON.parse(Datadog::AppSec::Assets.waf_processors) end |
.default_waf_scanners ⇒ Object
70 71 72 |
# File 'lib/datadog/appsec/processor/rule_merger.rb', line 70 def default_waf_scanners @default_waf_scanners ||= JSON.parse(Datadog::AppSec::Assets.waf_scanners) end |
.merge(telemetry:, rules:, data: [], overrides: [], exclusions: [], custom_rules: [], processors: nil, scanners: nil) ⇒ Object
TODO: ‘processors` and `scanners` are not provided by the caller, consider removing them
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/datadog/appsec/processor/rule_merger.rb', line 23 def merge( telemetry:, rules:, data: [], overrides: [], exclusions: [], custom_rules: [], processors: nil, scanners: nil ) processors ||= begin default_waf_processors rescue StandardError => e Datadog.logger.error("libddwaf rulemerger failed to parse default waf processors. Error: #{e.inspect}") telemetry.report( e, description: 'libddwaf rulemerger failed to parse default waf processors' ) [] end scanners ||= begin default_waf_scanners rescue StandardError => e Datadog.logger.error("libddwaf rulemerger failed to parse default waf scanners. Error: #{e.inspect}") telemetry.report( e, description: 'libddwaf rulemerger failed to parse default waf scanners' ) [] end combined_rules = combine_rules(rules) combined_data = combine_data(data) if data.any? combined_overrides = combine_overrides(overrides) if overrides.any? combined_exclusions = combine_exclusions(exclusions) if exclusions.any? combined_custom_rules = combine_custom_rules(custom_rules) if custom_rules.any? combined_rules['rules_data'] = combined_data if combined_data combined_rules['rules_override'] = combined_overrides if combined_overrides combined_rules['exclusions'] = combined_exclusions if combined_exclusions combined_rules['custom_rules'] = combined_custom_rules if combined_custom_rules combined_rules['processors'] = processors combined_rules['scanners'] = scanners combined_rules end |