Skip to content

Commit 8c8a07d

Browse files
fastrevmd-labclaude
andcommitted
fix(vector): redact IPv6 addresses in unifi_other event names
The catch-all replaced a name embedding an IPv4 address, a MAC or an email, but an IPv6 address passed through into ext and the rebuilt raw line. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6ad183f commit 8c8a07d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎infra/vector/vector.toml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ if action == "unifi_other" {
781781
# no addresses. raw is rebuilt from the CEF header; a name that looks like it
782782
# embeds an address or email is replaced.
783783
safe_name = slice!(name, 0, 128)
784-
if match(safe_name, r'@|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|(?i)([0-9a-f]{2}[:-]){5}[0-9a-f]{2}') { safe_name = "redacted" }
784+
# the last alternative is IPv6 (also catches a clock time; when unsure, redact)
785+
if match(safe_name, r'@|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|(?i)([0-9a-f]{2}[:-]){5}[0-9a-f]{2}|[0-9a-f]{0,4}(:[0-9a-f]{0,4}){2,7}') { safe_name = "redacted" }
785786
event_id_text = slice!(string(doc.deviceEventClassId) ?? "", 0, 16)
786787
severity_text = slice!(string(doc.severity) ?? "", 0, 8)
787788
ev.event_kind = "event"
@@ -2467,6 +2468,22 @@ assert!(!contains(string!(.raw), "192.0.2.88"))
24672468
assert!(!contains(string!(.raw), "example.invalid"))
24682469
'''
24692470

2471+
[[tests]]
2472+
name = "unifi_events_unifi_other_redacts_a_name_that_embeds_an_ipv6_address"
2473+
[[tests.inputs]]
2474+
insert_at = "unifi_events"
2475+
type = "raw"
2476+
value = 'Nov 12 10:00:00 ctrl-example CEF:0|Ubiquiti|UniFi Network|11.0.99|778|Login from 2001:db8::88 by someone|3|UNIFIcategory=System msg=x'
2477+
[[tests.outputs]]
2478+
extract_from = "unifi_events"
2479+
[[tests.outputs.conditions]]
2480+
type = "vrl"
2481+
source = '''
2482+
assert_eq!(.event_action, "unifi_other")
2483+
assert_eq!(.ext."unifi.event.name", "redacted")
2484+
assert!(!contains(string!(.raw), "2001:db8"))
2485+
'''
2486+
24702487
[[tests]]
24712488
name = "unifi_events_internet_restored_maps_to_wan_up_event"
24722489
[[tests.inputs]]

0 commit comments

Comments
 (0)