Skip to content

feat: owasp security event logging for user, password, and shutdown events#6801

Open
blackboxsw wants to merge 2 commits intocanonical:mainfrom
blackboxsw:owasp-logs-part2
Open

feat: owasp security event logging for user, password, and shutdown events#6801
blackboxsw wants to merge 2 commits intocanonical:mainfrom
blackboxsw:owasp-logs-part2

Conversation

@blackboxsw
Copy link
Collaborator

Delta above #6800 to aid in reviewing. Review top-most commit only for this PR.

Proposed Commit Message

    feat: owasp security event logging for user, password, and shutdown events
    
    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.

Additional Context

Test Steps

make deb
CLOUD_INIT_KEEP_INSTANCE=1 CLOUD_INIT_CLOUD_INIT_SOURCE=cloud-init-base_26.1-19-g8eafe51b-1~bddeb_all.deb  CLOUD_INIT_OS_IMAGE=resolute tox -e integration-tests --tests/integration_tests/modules/test_combined.py::TestCombined::test_security_logs

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

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.
@github-actions github-actions bot added the documentation This Pull Request changes documentation label Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation This Pull Request changes documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant