Skip to content

Owasp logs part3#39

Open
blackboxsw wants to merge 3 commits intomainfrom
owasp-logs-part3
Open

Owasp logs part3#39
blackboxsw wants to merge 3 commits intomainfrom
owasp-logs-part3

Conversation

@blackboxsw
Copy link
Owner

Proposed Commit Message

<type>(optional scope): <summary>  # no more than 72 characters

A description of what the change being made is and why it is being
made if the summary line is insufficient.  This should be wrapped at
72 characters.

If you need to write multiple paragraphs, feel free.

Fixes GH-NNNNN (GitHub Issue number. Remove line if irrelevant)
LP: #NNNNNN (Launchpad bug number. Remove line if irrelevant)

Additional Context

Test Steps

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.
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.

1 participant