Repository navigation
audit-log syslog: emit RFC 5424 NILVALUE for empty/invalid HOSTNAME - #2417
Merged
sk-keeper merged 1 commit intoOct 23, 2026
Merged
Conversation
adeshmukh-ks
approved these changes
Oct 23, 2026
sk-keeper
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
audit-log --target syslogand--target syslog-portemit syslog lines with an empty HOSTNAME field, producing two consecutive spaces between the timestamp and APP-NAME:<110>1 2026-09-02T17:17:32Z Keeper - 24983911115 [Keeper@Commander ...]
RFC 5424 §6.2.4 defines HOSTNAME as either the NILVALUE (
-) or 1–255 printable US-ASCII characters (codes 33–126). An empty value satisfies neither form, and strict RFC 5424 receivers reject the message entirely.Root cause
AuditLogSyslogBaseExport.convert_event()checked only whether theip_addresskey was present, not whether its value was usable:When the backend returns
ip_addressas an empty string (""), Commander passed it straight into the syslog header, producing an invalid message. The same path also allowed None, whitespace-only strings, and non-printable characters to reach the HOSTNAME field.Change
convert_event()now normalises HOSTNAME before formatting the header:-.-.Testing
Reproduction
Live validation
Reproduced the bug by generating a
device_approvedevent for a Web Vault login where the backend returnedip_address: "". Exported with the unpatched build and confirmed two spaces in the HOSTNAME field. Re-exported with the patched build — the double-space pattern was gone and the event showed- Keeperwith a single NILVALUE hyphen. Events carrying a real IP continued to show that IP in HOSTNAME.Unit tests (
unit-tests/test_audit_log_syslog.py)21 tests covering both
AuditLogSyslogFileExportandAuditLogSyslogPortExport:test_hostname_is_rfc5424_valid(18 cases, parametrised across both exporters) — verifies that None,"", whitespace, tab, non-ASCII, and null-byte values all produce-in HOSTNAME, that leading/trailing whitespace is stripped from otherwise valid values, and that valid IPv4 and IPv6 addresses pass through unchanged. Each case also asserts APP-NAME isKeeperand that no double-space appears in the header.test_missing_key_still_uses_nilvalue— verifies that an event with noip_addresskey at all still produces a correctly formatted header starting with- Keeper.test_hostname_truncated_to_255— verifies that a 300-character value is truncated to exactly 255 characters.test_ip_address_not_duplicated_in_structured_data— verifies that an emptyip_addressvalue does not appear asip_address=anywhere in the structured-data block.Running the tests against the original code yields 15 failed, 6 passed (the 6 passing are the valid-IP cases, which the fix must not change). With the fix applied: 21 passed.
The full existing unit suite (
unit-tests/) continues to pass with no new failures (2423 passed, 59 skipped).