Skip to content

[cl] Redact task log records before they reach the worker log - #248

Closed
anfimovdm wants to merge 1 commit into
clfrom
al-alts-cl-redact-credentials-in-logs
Closed

anfimovdm wants to merge 1 commit into
clfrom
al-alts-cl-redact-credentials-in-logs

Conversation

@anfimovdm

Copy link
Copy Markdown
Contributor

Follow-up to #247.

Ansible output of install_package and the other playbook steps can contain build repository URLs with the build system token, e.g. in dnf/apk errors. That output is already masked in the uploaded artifacts, but the runner also logs it through the task logger (Cannot install package %s: %s, Repositories: %s, Modified repo url: %s). Those records propagate to the Celery worker's root logger, whose handlers don't use RedactingFormatter, so the token ended up in the worker log.

Changes

  • alts/shared/utils/log_utils.py: add RedactingFilter, which masks the record message, exception text and stack info in place.
  • alts/worker/runners/base.py: attach it to the test task logger. Logger filters run before any handler, including parent loggers' handlers.

Testing

  • tests/shared/test_log_utils.py: new test logs through a child logger into a parent handler with a plain formatter (like the Celery worker log), including an exception; 12 passed.
  • Checked that YAML callback output (stdout_callback = yaml) of dnf/apt/apk errors with credential URLs is still masked by redact_secrets in plain, single- and double-quoted styles.

The same gap exists on master.

🤖 Generated with Claude Code

Ansible output of install_package and other steps can contain build
repository URLs with the build system token, e.g. in package manager
errors, and the runner logs it through the task logger. Its records
propagate to the root logger of the Celery worker, whose handlers don't
use RedactingFormatter, so the token ended up in the worker log.

Mask the records with a logger filter instead, which runs before any
handler, including the ones of parent loggers.
@anfimovdm

Copy link
Copy Markdown
Contributor Author

Superseded by #249.

@anfimovdm anfimovdm closed this Nov 10, 2026
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