Skip to content

fix(logs): mask the email codes in the access log, keep error texts private - #2833

Merged
lbesson merged 1 commit into
masterfrom
fix/log-redaction
Dec 3, 2026
Merged

lbesson merged 1 commit into
masterfrom
fix/log-redaction

Conversation

@lbesson

@lbesson lbesson commented Dec 3, 2026

Copy link
Copy Markdown
Member

What

  • Access log: the paths of the email links (/users/validate_register_email/…, validate_new_password/…, validate_change_email/…) are logged with the code masked, e.g. /users/validate_new_password/newpass_***, in the message and in the path field. Follows fix(user): store the hash of the email codes, reset link valid 1 day #2830, which stopped storing these codes in clear.

  • SQL errors: the engines of the API and of the ES scripts are created with hide_parameters=True, so the values of a query stay out of the error texts. Not the Alembic migrations, run by hand.

  • Navitia: errors that are not Navitia's own answers no longer reach the client as raw text:

    • a failed call answers navitia_internal_error (already translated by the UI);
    • an unexpected error while checking a journey answers unknown_error (already translated);
    • a failed job answers job_error / unknown error.

    Navitia's error ids (no_solution, date_out_of_bounds…) are unchanged; the full text goes to the logs.

Tests

Masked paths for the 3 routes (other paths kept), hide_parameters passed by create_app, the Navitia answers above. The new tests fail on master.

The HAProxy access log still writes these paths: a separate change in v6-docker-compose, later.

🤖 Generated with Claude Code

…rivate

- The access log writes the paths of the email links (registration,
  password reset, email change) with the code masked; only its purpose
  stays, for the greps.
- The engines hide the values of the SQL queries in the error texts.
- The Navitia views answer error ids instead of the text of unexpected
  exceptions (URL and query of the call, database errors); the text
  goes to the logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4ff3c2ae-3302-4ad1-a1f7-a6a718a83239
Commits

Reviewing files that changed from the base of the PR and between 5a80c91 and cabc229.

Files selected for processing: 9

  • c2corg_api/__init__.py
  • c2corg_api/scripts/es/fill_index.py
  • c2corg_api/scripts/es/reindex.py
  • c2corg_api/scripts/es/syncer.py
  • c2corg_api/tests/test_engine.py
  • c2corg_api/tests/test_web_access_log.py
  • c2corg_api/tests/views/test_navitia.py
  • c2corg_api/views/navitia.py
  • c2corg_api/web/access_log.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -1 complexity · 2 duplication

Metric Results
Complexity -1
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@lbesson
lbesson merged commit 4022a9d into master Dec 3, 2026
8 checks passed
@lbesson
lbesson deleted the fix/log-redaction branch December 3, 2026 10:46
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