This commit is contained in:
Dan Milne
2025-11-15 10:51:58 +11:00
parent d9701e4af6
commit 90823a1389
10 changed files with 425 additions and 84 deletions

View File

@@ -46,8 +46,23 @@ class Api::EventsController < ApplicationController
rules = Rule.active.sync_order
end
response_data[:rules] = rules.map(&:to_agent_format)
agent_rules = rules.map(&:to_agent_format)
response_data[:rules] = agent_rules
response_data[:rules_changed] = true
# Include path segments dictionary for path_pattern rules
path_segment_ids = agent_rules
.select { |r| r[:waf_rule_type] == 'path_pattern' }
.flat_map { |r| r.dig(:conditions, :segment_ids) }
.compact
.uniq
if path_segment_ids.any?
response_data[:path_segments] = PathSegment
.where(id: path_segment_ids)
.pluck(:id, :segment)
.to_h
end
else
response_data[:rules_changed] = false
end