Drop add_headers - headers can now be added to meta[] to be applied for any action. Consilidate Tagging in a service
This commit is contained in:
@@ -226,8 +226,8 @@ class Event < ApplicationRecord
|
||||
# Normalize headers in payload during import phase
|
||||
normalized_payload = normalize_payload_headers(payload)
|
||||
|
||||
# Create the WAF request event
|
||||
create!(
|
||||
# Create the WAF request event with agent-provided tags
|
||||
event = create!(
|
||||
request_id: request_id,
|
||||
timestamp: parse_timestamp(normalized_payload["timestamp"]),
|
||||
payload: normalized_payload,
|
||||
@@ -250,11 +250,18 @@ class Event < ApplicationRecord
|
||||
server_name: normalized_payload["server_name"],
|
||||
environment: normalized_payload["environment"],
|
||||
|
||||
|
||||
# Tags: start with agent-provided tags only
|
||||
tags: normalized_payload["tags"] || [],
|
||||
|
||||
# WAF agent info
|
||||
agent_version: normalized_payload.dig("agent", "version"),
|
||||
agent_name: normalized_payload.dig("agent", "name")
|
||||
)
|
||||
|
||||
# Apply rule tags using EventTagger service
|
||||
EventTagger.tag_event(event)
|
||||
|
||||
event
|
||||
end
|
||||
|
||||
# Normalize headers in payload to lower case during import phase
|
||||
@@ -347,7 +354,10 @@ class Event < ApplicationRecord
|
||||
|
||||
def tags
|
||||
# Use the dedicated tags column (array), fallback to payload during transition
|
||||
super.presence || (payload&.dig("tags") || [])
|
||||
# Ensure we always return an Array, even if payload has malformed data (e.g., {} instead of [])
|
||||
result = super.presence || payload&.dig("tags")
|
||||
return [] if result.nil?
|
||||
result.is_a?(Array) ? result : []
|
||||
end
|
||||
|
||||
def headers
|
||||
|
||||
Reference in New Issue
Block a user