Skip to content

Added sanitization of journald keys#751

Open
IDisposable wants to merge 2 commits intors:masterfrom
IDisposable:fix/sanitize-keys
Open

Added sanitization of journald keys#751
IDisposable wants to merge 2 commits intors:masterfrom
IDisposable:fix/sanitize-keys

Conversation

@IDisposable
Copy link
Contributor

@IDisposable IDisposable commented Jan 26, 2026

Also, raised text coverage for the journald sub-package to 92.6%
Fixes #668

Also, raised text coverage for the journald sub-package to 92.2%
Fixes rs#668
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds sanitization of journald keys to handle invalid characters (such as dots) that are not allowed by journald, addressing issue #668. It also increases test coverage for the journald sub-package to 92.2%.

Changes:

  • Implemented SanitizeKey function that converts keys to uppercase and replaces invalid characters with underscores
  • Added SendFunc global variable for mocking journald interactions in tests
  • Added comprehensive test coverage including tests for key sanitization, various data types, all log levels, and error handling

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
journald/journald.go Implements key sanitization logic and test hook for mocking
journald/journald_test.go Adds comprehensive tests for sanitization and various edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Made sanitizeKey package-private.
Ensure the key starts with a letter.
Added warning when SendFunc is replaced about parallel threads
Moved test into package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should journald keys be sanitized to strip/replace invalid characters?

2 participants