Skip to content

Mask the filter list in Rollbar reports - #2064

Merged
jbirdjavi merged 3 commits into
masterfrom
rollbar-scrub-filter-params
Nov 23, 2026
Merged

jbirdjavi merged 3 commits into
masterfrom
rollbar-scrub-filter-params

Conversation

@jbirdjavi

@jbirdjavi jbirdjavi commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Rollbar reports now mask every name on the app's filter list (token, secret, passw and the rest), plus the session cookie and the Referer header.

Why

With load_defaults 7.1 or later, Rails turns filter_parameters into one compiled Regexp. rollbar 3.8.0 escapes that Regexp into a literal string, so it matches nothing, and Rollbar's request scrubbing ignored the whole filter list. Only Rollbar's own short default list (password, access_token and a few more) was masked.

In this app that means sign-in requests to POST /auth sent google_id_token, facebook_id_token and apple_refresh_token to Rollbar in clear whenever the request raised an error. The same gap affects most of the Rails fleet; cap#968 and global360#549 fix it the same way.

How

  • New config/initializers/rollbar_scrub_fields.rb copies the filter list's plain names into Rollbar's scrub_fields. It has to load after filter_parameter_logging.rb, and 01_rollbar.rb loads before it (a copy there comes out empty), so it lives in its own file.
  • Adds _mobile_content_api_session to scrub_fields and Referer to scrub_headers (a Referer can repeat a token from the page URL). Authorization is already masked by Rollbar's default.
  • Rails' own log filtering is unchanged.

Tests

  • spec/initializers/rollbar_spec.rb runs Rollbar's own request extraction on made-up values: every filter-list name in a form post, the sign-in tokens in a JSON:API body (dashed and underscored names), the invite token, the session cookie, and the Authorization and Referer headers. All 5 examples failed before the fix and pass after.
  • Checked with eager loading on (CI=true): scrub_fields holds every filter-list name and the session cookie.
  • Full suite: 1056 examples. The 4 Google Analytics specs failed locally until the local service-account file was in place, then passed.

🤖 Generated with Claude Code

load_defaults 7.1 and later precompile filter_parameters into one Regexp,
and rollbar 3.8.0 escapes that Regexp into a literal, so Rollbar's request
scrubbing ignored the whole filter list. Sign-in tokens such as
google_id_token, facebook_id_token and apple_refresh_token went to Rollbar
in clear on any error.

Copy the filter list's plain names into Rollbar's scrub_fields, in a new
initializer that loads after filter_parameter_logging.rb (01_rollbar.rb
loads before it, so a copy there is empty). Also mask the session cookie
and the Referer header.

The spec runs Rollbar's own request extraction on made-up values. All five
examples failed before this change.

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

jbirdjavi commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 agent-review · ✅ no blockers · risk HIGH
Rollout: advisory · 4 agents run (Code Review (/code-review xhigh), Security Review Agent, Testing & Quality Review Agent, Standards Compliance Review Agent) · incremental since 2a55483

BLOCKERS: fix or dismiss to pass

✅ No blockers.

OTHER FINDINGS (8)

  • #8 · 6/10 · app/controllers/application_controller.rb:134 · A malformed JSON:API body makes merge_params raise an unrescued JSON::ParserError, and Rollbar 3.8.0 then reports the raw body under the key body.value, which no scrub field matches. Sign-in tokens in that body reach Rollbar unmasked. (code-review)
  • #1 · 5/10 · config/initializers/filter_parameter_logging.rb:7 · apple_auth_code (read at auth_controller.rb:5) and the AccessCode code param match no Rails filter or Rollbar default, so they reach Rollbar and request logs unmasked. The new sign-in spec example leaves apple_auth_code out, so the gap is untested. (code-review)
  • #2 · 4/10 · config/initializers/rollbar_scrub_fields.rb:7 · If anything reads Rails.application.env_config before this initializer runs, Rails replaces config.filter_parameters in place with one compiled Regexp and the Symbol/String select returns an empty list. Rollbar then falls back to its short default list with no error at boot. (code-review)
  • #3 · 4/10 · config/initializers/rollbar_scrub_fields.rb:7 · When a JSON:API body fails to parse, Rollbar sends it as raw text under the key body.value, which no scrub field matches, so sign-in tokens in it go out readable. merge_params (application_controller.rb:134) raises on the same body, so the request becomes a reported 500. (code-review)
  • #4 · 3/10 · config/initializers/rollbar_scrub_fields.rb:7 · Rollbar's URL scrubber matches field names case-sensitively, so query keys like TokenId keep their values in the reported url while the GET section masks them. (code-review, security)
  • #5 · 3/10 · config/initializers/rollbar_scrub_fields.rb:7 · The select silently drops Regexp and Proc filters, and filters Rails adds later (for example from AR encrypts) are never copied, so a future filter would mask Rails logs but not Rollbar reports. (code-review)
  • #6 · 3/10 · spec/initializers/rollbar_spec.rb:1 · The new spec file does not start with the frozen_string_literal magic comment that the repo's standards rule requires on new Ruby files. · ✅ fixed in f23184f
  • #7 · 3/10 · spec/initializers/rollbar_spec.rb:6 · The filter-list example hardcodes the 11 names instead of reading the configured list, so a name added later is never checked against Rollbar. (code-review, testing)
🔧 Fix suggestions (0)

No automated fixes for this review.

📦 Dependency impact

Index disabled.

📊 Review detail & stats

Generated: 2026-11-19 · Day: Thursday · Files changed this pass: 2 (+3 -0 lines; full PR +97 -0)
Risk score: delta 1 (LOW, ran quick); full PR 7 · HIGH · Required reviewer: experienced

Risk factors detected: config_security_change (full PR)

Deterministic evidence:

  • AST/static rules: none
  • CI snapshot: unavailable (local review)
  • Cross-repo context: none

Agent summary (bands: Critical 9-10 · High 7-8 · Important 5-6 · Suggestions 3-4):

Agent Critical High Important Suggestions Confidence
Code Review (/code-review xhigh) 0 0 1 1 H
Security Review Agent 0 0 0 0 -
Testing & Quality Review Agent 0 0 0 0 H
Standards Compliance Review Agent 0 0 0 0 -
Total 0 0 1 1 -

Per-agent perspectives on blockers: none (no blockers).

Engine: code-review (from config) · effort xhigh (from config) · model opus (from config)
/code-review findings: found 3 · scored 2 · dropped 1 (scored findings under the profile's cutoff may not appear in the lists above)

  • .claude/review/learnings/feedback/address-2064-20261120T010106Z-13591a.jsonl:1 Feedback record uses the new split learnings/feedback layout that the repo CLAUDE.md, .gitignore and config.yml excluded_paths do not describe yet: excluded path: .claude/review/learnings/feedback/**

Review quality:

  • Average agent confidence: High · Ledger matching: 1 of 4 pairs judged the same as an earlier finding (Rename project #5)
  • Findings suppressed by approved learnings: 0
💬 How to act on this review

Every finding above is numbered. Severity ≥ 7 findings carry a checkbox and must each be fixed or
dismissed
before this review counts as passed; lower severities are advisory. This repo runs
reviews locally only, so work this ledger with /agent-review:address in a Claude Code session.
It fixes or dismisses findings (a reason code and explanation are required for a dismissal) and
keeps this comment in sync. Valid codes: false-positive, intentional, pre-existing,
deferred, duplicate, insufficient-evidence, other.

github-actions[bot]
github-actions Bot previously approved these changes Nov 19, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: the agent-review report for this head passes with no open blockers, and no repo rule or recorded check needs a person.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions
github-actions Bot dismissed their stale review November 20, 2026 01:01

agent-review: the bot took back its approval of 2a55483 because the PR changed beyond merging in the default branch. Run /agent-review:re-review (or /agent-review:review) and post the report. The bot approves again when the report passes for the new head.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: the agent-review report for this head passes with no open blockers, and no repo rule or recorded check needs a person.

@stage-branch-merger

Copy link
Copy Markdown

I see you added the "On Staging" label, I'll get this merged to the staging branch!

@jbirdjavi
jbirdjavi merged commit cb3bc07 into master Nov 23, 2026
13 checks passed
@jbirdjavi
jbirdjavi deleted the rollbar-scrub-filter-params branch November 23, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant