feat: owasp security event logging for user, password, and shutdown events#6801
Open
blackboxsw wants to merge 2 commits intocanonical:mainfrom
Open
feat: owasp security event logging for user, password, and shutdown events#6801blackboxsw wants to merge 2 commits intocanonical:mainfrom
blackboxsw wants to merge 2 commits intocanonical:mainfrom
Conversation
Perform preliminary refactor to be used by securirity event logging. Split add_user method into separate methods: - _add_user_preprocess_kwargs: filter distro-specific args before cmd - _build_add_user_cmd: return tuple of cmd and log_command for the useradd - _post_add_user: distro-specific post-creation steps for Alpine - _user_groups_to_list: normalize group input to a list Move util.is_user check into create_user and make add_user raise on failure instead of returning bool. Subclasse now only override the separate methods instead of duplicating add_user. Refactor shutdown_command introducing a new _build_shutdown_command which is overridden in subclasses.
…vents Add a security event logging subsystem following the OWASP Logging Vocabulary Cheat Sheet. Events are emitted as JSON Lines on a new SECURITY log level which is routed to a separate log file (default: /var/log/cloud-init-security.log). Add cloudinit/log/security_event_log.py which provides: - OWASPEventType / OWASPEventLevel enums for standardised event strings - Four decorators consumed by Distro methods: sec_log_user_created, sec_log_password_changed, sec_log_password_changed_batch, sec_log_system_shutdown cloudinit/log/loggers.py now has a custom SecurityFormatter that injects an ISO-8601 timestamp into log records. Apply decorators to the Distro class, and prevent subclassing of decorated methods. Use _get_elevated_roles helper exposes sudo/doas membership to the decorator.
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.
Delta above #6800 to aid in reviewing. Review top-most commit only for this PR.
Proposed Commit Message
Additional Context
Test Steps
Merge type