Skip to content

fix(logging): sanitize message strings and migrate printToConsole to os.Logger#492

Open
ManthanNimodiya wants to merge 4 commits into
RunanywhereAI:mainfrom
ManthanNimodiya:fix/logging-sanitize-message-strings-246
Open

fix(logging): sanitize message strings and migrate printToConsole to os.Logger#492
ManthanNimodiya wants to merge 4 commits into
RunanywhereAI:mainfrom
ManthanNimodiya:fix/logging-sanitize-message-strings-246

Conversation

@ManthanNimodiya
Copy link
Copy Markdown
Contributor

@ManthanNimodiya ManthanNimodiya commented Apr 21, 2026

Summary

The logging system was sanitizing metadata keys (e.g. ["apiKey": "..."]) but
letting the message string through raw. So any call like:

logger.info("Initializing with apiKey=\(key)")

would print the key straight to stdout. GitHub Advanced Security flagged this
exact taint path (messageprint()), and it's been open since December.

Also noticed import os was already at the top of the file but os.Logger
was never actually used — we were just calling print(). Fixed that too.

Root Cause

Logging.log() called sanitizeMetadata() on the metadata dict but passed
message into LogEntry untouched. printToConsole() then wrote it out
verbatim via print(). The logError() helper had the same gap — it builds
a message string from error.localizedDescription and additionalInfo, both
of which could carry credential values.

Changes

  • SDKLogger.swift — Added sanitizeMessage(_:) that uses
    NSRegularExpression to redact values after credential-like keywords
    (apiKey=, password:, Bearer <token>, etc.). Hooked it into log()
    right alongside the existing sanitizeMetadata() call, so every path —
    console and Sentry destinations — gets a clean entry. Swapped print() for
    os.Logger with per-category subsystems; output is marked .public because
    the message is already sanitized before it gets there.

  • SecurityLoggingTests.swift — 12 new tests: key=value and key: value
    patterns, Bearer token scheme, metadata regression, logError with sensitive
    additionalInfo, and a check that normal messages aren't touched.

Testing

xcodebuild test \
  -scheme RunAnywhere \
  -destination 'platform=macOS' \
  -only-testing RunAnywhereTests/SecurityLoggingTests

All 12 new cases pass. AudioCaptureManagerTests unaffected.

Checklist

  • Tests added (SecurityLoggingTests.swift, 12 cases)
  • No API surface change — all public signatures are identical
  • Follows the existing sanitizeMetadata pattern, just extended to messages
  • Issue scope was analysed thoroughly before implementing this fix.

Notes

Summary by CodeRabbit

  • Security Improvements

    • Sensitive credentials (API keys, passwords, bearer tokens, and similar patterns) are automatically redacted from log messages and structured metadata, while non-sensitive text remains unchanged.
  • Logging

    • Console output now uses the system logger with level-aware emission and logging continues when destinations are present.
  • Tests

    • Added comprehensive end-to-end tests validating redaction, metadata handling, and logging behavior.

Greptile Summary

This PR adds sanitizeMessage(_:) to redact credential values embedded in log message strings, complementing the existing sanitizeMetadata(), and migrates printToConsole from print() to os.Logger. The approach is sound, but there is a critical test infrastructure bug and a regex false-positive issue that need to be addressed before merging.

  • P1 — Tests never execute sanitization: In setUp, both enableLocalLogging and enableSentryLogging are set to false, triggering an early return in log() before any destination is written. All XCTAssertTrue(msg.contains(\"[REDACTED]\")) assertions operate on an empty string and would fail; the 12 tests don't actually verify sanitization works.
  • P2 — Regex false positives: The separator group [=:\\s] accepts a bare space, so \"token count: 5\"\"token [REDACTED] 5\". The basic keyword exacerbates this with common English prose.

Confidence Score: 4/5

Not safe to merge as-is — the test suite has a structural bug that means none of the 12 new sanitization tests actually verify the fix works.

The production sanitization logic is correctly wired and the os.Logger migration is clean. However, the P1 test guard bypass means the PR's stated test coverage is illusory — merging leaves the security fix unverified and masks future regressions.

SecurityLoggingTests.swift — all 12 tests structurally broken by the early-return guard. SDKLogger.swift regex pattern needs narrowing to avoid false-positive redaction.

Important Files Changed

Filename Overview
sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift Adds sanitizeMessage(_:) using NSRegularExpression for credential pattern redaction and migrates printToConsole from print() to os.Logger. The regex separator pattern [=:\s] is overly broad and basic is too generic a keyword, causing false-positive redaction.
sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift 12 new sanitization tests using a CapturingDestination, but all are structurally broken: setting both enableLocalLogging = false and enableSentryLogging = false in setUp causes log() to early-return before writing to any destination, so sanitization assertions never actually fire.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["log(level:category:message:metadata:)"] --> B{level >= minLogLevel?}
    B -- No --> Z[return]
    B -- Yes --> C{enableLocalLogging\nOR enableSentryLogging?}
    C -- No --> Z2["return ⚠️ CapturingDestination\nnever reached in tests"]
    C -- Yes --> D["sanitizeMessage(message)\n+ sanitizeMetadata(metadata)"]
    D --> E[Create LogEntry]
    E --> F{enableLocalLogging?}
    F -- Yes --> G["printToConsole(entry)\nos.Logger .public"]
    F -- No --> H
    G --> H[Write to registered destinations\nCapturingDestination / SentryDestination]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift
Line: 35-45

Comment:
**Guard in `log()` short-circuits before reaching `CapturingDestination`**

With both `enableLocalLogging = false` and `enableSentryLogging = false`, the guard on line 211 of `SDKLogger.swift`:

```swift
guard config.enableLocalLogging || config.enableSentryLogging else { return }
```

evaluates `false || false` and returns early — **before** the loop that writes to registered destinations. `CapturingDestination.write()` is never called, so `destination.captured` stays empty for every test.

Concretely:
- `destination.captured.first``nil`
- `msg``""` (via `?? ""`)
- `XCTAssertFalse("".contains("sk-prod-abc123"))`**passes vacuously**- `XCTAssertTrue("".contains("[REDACTED]"))`**fails** ✗

The tests don't actually exercise `sanitizeMessage` at all. Fix by enabling local logging in `setUp` while suppressing OS output separately, or extend the guard to account for registered custom destinations:

```swift
// In log() — also proceed if there are registered custom destinations
guard config.enableLocalLogging || config.enableSentryLogging || !currentDestinations.isEmpty else { return }
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift
Line: 305

Comment:
**`\s` in separator character class causes false-positive redaction**

The separator group `(\s*[=:\s]\s*)` includes `\s` inside `[=:\s]`, so a bare space is a valid separator. Any sensitive keyword followed by a space and a non-whitespace word will be redacted even without `=` or `:`. For example:

- `"token count: 5"``"token [REDACTED] 5"` (`count:` is captured as the value)
- `"basic usage example"``"basic [REDACTED] example"` (`basic` is in the keyword list)
- `"auth_key rotation completed"``"auth_key [REDACTED] completed"`

The `basic` keyword is especially problematic as it's a common English word. Consider restricting the separator to only `=` and `:` and removing `basic`:

```suggestion
        let pattern = #"(?i)(api[_\-]?key|apikey|secret|password|token|auth[_\-]?key|credential|bearer)(\s*[:=]\s*)(\S+)"#
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(logging): sanitize message strings a..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.


Note

Medium Risk
Touches core logging behavior and redaction logic; mistakes could either leak sensitive data or over-redact/alter log output, and console logging now depends on os.Logger behavior.

Overview
Prevents credential leaks via log messages. Logging.log() now sanitizes the message string (in addition to existing metadata sanitization) by redacting common secret patterns (e.g., apiKey=..., password: ..., Bearer ...).

Changes console logging implementation. printToConsole() is migrated from print() to os.Logger with a fixed subsystem and per-category logging, and log() will now proceed when custom destinations are registered even if both local and Sentry logging are disabled.

Adds regression coverage. Introduces SecurityLoggingTests to verify message/metadata redaction, avoid false positives, and ensure SDKLogger.logError(...additionalInfo:) also gets sanitized.

Reviewed by Cursor Bugbot for commit 19b12e2. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 58c9fa32-2c95-49f1-babc-8cf80d06f313

📥 Commits

Reviewing files that changed from the base of the PR and between 1fa88b8 and a7226f9.

📒 Files selected for processing (2)
  • sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift
  • sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift
🚧 Files skipped from review as they are similar to previous changes (2)
  • sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift
  • sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift

📝 Walkthrough

Walkthrough

Logging now sanitizes message text and metadata via regex redaction, constructs LogEntry from sanitized content, and emits level-specific output through os.Logger; logging still occurs when registered destinations exist even if local and Sentry flags are false. Tests validate redaction and regression cases.

Changes

Cohort / File(s) Summary
Logging Core
sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift
Sanitize messages and metadata before creating LogEntry (redact Bearer tokens, key=value / key: value credential fields, token-like patterns); allow logging when currentDestinations is non-empty even if local/Sentry flags are false; replace print with os.Logger level-specific emits using privacy: .public.
Security Tests
sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift
Add CapturingDestination and comprehensive tests asserting message and metadata redaction for API keys, bearer/JWT tokens, passwords, token-like patterns, empty/non-sensitive messages, and SDKLogger.logError(...) sanitization.

Sequence Diagram(s)

sequenceDiagram
  participant App as "App / Caller"
  participant SDKLogger as "SDKLogger"
  participant Dest as "Registered Destinations"
  participant OS as "os.Logger"

  App->>SDKLogger: log(level, message, metadata)
  SDKLogger->>SDKLogger: sanitizeMessage(message)\nsanitizeMetadata(metadata)
  alt currentDestinations not empty
    SDKLogger->>Dest: deliver(LogEntry(sanitized))
  end
  SDKLogger->>OS: emit(level, formattedOutput, privacy: .public)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Siddhesh2377

Poem

🐇 I nibbled through logs, soft and steady,
Snipped tokens tidy, kept my paws ready.
Secrets wrapped in "[REDACTED]" so bright,
Hopped home with carrots, safe through the night. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses the primary coding objectives from #246: message sanitization for sensitive patterns, unit tests validating sanitization, and preventing credential leaks. However, Greptile identified critical test infrastructure bugs that prevent the 12 new tests from actually verifying the fix works. Fix the guard condition in log() to proceed when custom destinations are registered, even if both enableLocalLogging and enableSentryLogging are false, so CapturingDestination receives entries and sanitization assertions execute.
Out of Scope Changes check ⚠️ Warning The PR includes a modification to the log() guard condition to proceed when currentDestinations.isEmpty is false, which enables test infrastructure. The regex false-positive issue (overly broad separator and generic 'basic' keyword) represents scope creep in sanitization logic that needs narrowing. Restrict the regex separator to only [=:] (remove \s), remove 'basic' from the keyword list, and ensure the separator pattern only matches explicit delimiters to prevent false-positive redactions in normal prose.
Docstring Coverage ⚠️ Warning Docstring coverage is 19.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding message sanitization and migrating console logging to os.Logger, addressing the core security fix.
Description check ✅ Passed The PR description is comprehensive and covers all required sections: summary, root cause, changes, testing, and a detailed checklist with acknowledgment of scope limitations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift (2)

299-307: Asymmetry between metadata and message keyword lists.

sensitivePatterns (line 299) flags metadata keys containing "auth" or "credential" as a substring, but the message regex only matches auth[_\-]?key and credential as a whole word. As a result, a field like metadata["authorization"] is redacted, while the same substring interpolated into a message ("authorization=...") is not. Consider extracting a single source of truth (e.g. Bearer|Basic|api[_\-]?key|apikey|secret|password|token|auth\w*|credential\w*) so the two paths stay in sync as new keywords are added.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift`
around lines 299 - 307, The message-redaction regex and the metadata keyword
list are out of sync: update the implementation so both use a single source of
truth (e.g., derive the message regex from the sensitivePatterns array or
extract a shared constant) and expand the message pattern to cover substring
variants like auth\w* and credential\w* as well as HTTP schemes (Bearer|Basic);
specifically, change the creation of sensitiveMessagePattern to build its
alternation from the sensitivePatterns symbols (or a shared keywords constant)
ensuring tokens like "authorization" and "credentialX" match the regex in
SDKLogger (referencing sensitivePatterns and sensitiveMessagePattern).

284-294: LGTM — privacy marker is sound given upstream sanitization.

Routing through os.Logger with privacy: .public is acceptable here because both sanitizeMessage and sanitizeMetadata run before the output string is built. Worth noting in passing that the subsystem is a hard-coded "com.runanywhere.sdk" string — if you already expose a bundle identifier or SDK constant, reusing it would avoid drift. Non-blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift`
around lines 284 - 294, Replace the hard-coded subsystem string
"com.runanywhere.sdk" used when constructing the Logger in SDKLogger.swift with
a shared bundle identifier or SDK constant (e.g., use your existing SDK constant
or Bundle.main.bundleIdentifier) so the subsystem stays in sync; update the
Logger instantiation in the logging path that builds `osLog` (where `osLog =
Logger(subsystem: "com.runanywhere.sdk", category: entry.category)`) to
reference that constant instead, leaving the rest of the sanitized output
handling (sanitizeMessage/sanitizeMetadata and the switch over entry.level)
unchanged.
sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift (1)

102-111: Missing regression coverage for false positives.

These two cases verify that messages with no sensitive keywords pass through untouched, but they don't exercise messages that contain a sensitive keyword followed by a benign word (e.g. "password required", "rotate your token soon", "Basic authentication disabled"). Given the current regex behavior flagged on SDKLogger.swift lines 303–307, such messages will be over-redacted. Adding a test here would lock in the intended behavior once the regex is tightened.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift`
around lines 102 - 111, Add regression tests that verify false positives aren't
over-redacted by the current regex: in SecurityLoggingTests.swift add a test
(e.g., testSensitiveKeywordsInBenignContextPassThrough) that calls
Logging.shared.log(level: .info, category: "Test", message: ...) with examples
like "password required", "rotate your token soon", and "Basic authentication
disabled" and assert destination.captured.first?.message equals the original
string; this ensures SDKLogger.swift's redaction logic (lines around the regex)
doesn't redact these benign contexts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift`:
- Around line 303-318: The regex in sensitiveMessagePattern is over-broad and
treats whitespace-only separators as credential separators, causing false
redactions; update the NSRegularExpression in sensitiveMessagePattern to use two
alternations: one that matches generic keywords
(api[_\-]?key|apikey|secret|password|token|auth[_\-]?key|credential) only when
followed by an explicit separator like '=' or ':' (e.g., (\s*[=:]\s*)(\S+)), and
a second alternation that matches Bearer|Basic followed by whitespace and a
token (e.g., (?i)(Bearer|Basic)\s+(\S+)); keep sanitizeMessage using the same
replacement but ensure templates target the correct capture groups, and add
regression tests validating benign phrases like "password required", "Please
rotate your token soon", "Basic authentication disabled", and "Check the secret
menu" remain unredacted while credential forms like "password=secret" and
"Bearer abc123" are redacted.

In `@sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift`:
- Around line 35-50: Snapshot Logging.shared.configuration at the start of
setUp, then apply the test-specific config and add the CapturingDestination as
you already do; in tearDown, remove the destination and restore the previously
saved configuration back onto Logging.shared (i.e., call
Logging.shared.configure(originalConfig)) so the process-wide singleton is
returned to its prior state; keep using the existing
destination/CapturingDestination and ensure restoration happens before calling
super.tearDown().

---

Nitpick comments:
In
`@sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift`:
- Around line 299-307: The message-redaction regex and the metadata keyword list
are out of sync: update the implementation so both use a single source of truth
(e.g., derive the message regex from the sensitivePatterns array or extract a
shared constant) and expand the message pattern to cover substring variants like
auth\w* and credential\w* as well as HTTP schemes (Bearer|Basic); specifically,
change the creation of sensitiveMessagePattern to build its alternation from the
sensitivePatterns symbols (or a shared keywords constant) ensuring tokens like
"authorization" and "credentialX" match the regex in SDKLogger (referencing
sensitivePatterns and sensitiveMessagePattern).
- Around line 284-294: Replace the hard-coded subsystem string
"com.runanywhere.sdk" used when constructing the Logger in SDKLogger.swift with
a shared bundle identifier or SDK constant (e.g., use your existing SDK constant
or Bundle.main.bundleIdentifier) so the subsystem stays in sync; update the
Logger instantiation in the logging path that builds `osLog` (where `osLog =
Logger(subsystem: "com.runanywhere.sdk", category: entry.category)`) to
reference that constant instead, leaving the rest of the sanitized output
handling (sanitizeMessage/sanitizeMetadata and the switch over entry.level)
unchanged.

In `@sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift`:
- Around line 102-111: Add regression tests that verify false positives aren't
over-redacted by the current regex: in SecurityLoggingTests.swift add a test
(e.g., testSensitiveKeywordsInBenignContextPassThrough) that calls
Logging.shared.log(level: .info, category: "Test", message: ...) with examples
like "password required", "rotate your token soon", and "Basic authentication
disabled" and assert destination.captured.first?.message equals the original
string; this ensures SDKLogger.swift's redaction logic (lines around the regex)
doesn't redact these benign contexts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82c16e8c-087e-45d0-b6ab-24f50c6d7db1

📥 Commits

Reviewing files that changed from the base of the PR and between 094d569 and fd38f61.

📒 Files selected for processing (2)
  • sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift
  • sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift

Comment thread sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift`:
- Around line 124-145: The three tests testTokenCountPhraseIsNotRedacted,
testPasswordRequiredPhraseIsNotRedacted, and testBasicEnglishPhraseIsNotRedacted
currently use a nil-coalescing boolean check that silently passes if no log was
captured; change each assertion to assert the captured message equals the
original msg (e.g., use XCTAssertEqual(destination.captured.first?.message,
msg)) so the test both verifies a log entry was captured and that its content
was not redacted; update the assertions in those test methods accordingly
referencing destination.captured and the local msg variable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d05eaf45-5b3d-4624-961e-ff4ece5ddf7b

📥 Commits

Reviewing files that changed from the base of the PR and between fd38f61 and 19b12e2.

📒 Files selected for processing (2)
  • sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift
  • sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 19b12e2. Configure here.

Comment thread sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift Outdated
…r false-positive tests, add authorization keyword
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift`:
- Around line 310-326: The sanitization patterns in SDKLogger.swift are ordered
so the generic key=value regex (containing "authorization") runs before the
Bearer-specific regex, causing "Bearer" to be consumed and the token left
unredacted; fix by reordering sensitiveMessagePatterns so the Bearer pattern
(the regex matching "(?i)(bearer)(\s+)([A-Za-z0-9+/=._\-]{8,})") comes before
the generic key/value pattern (the one containing "authorization") or
alternatively remove "authorization" from the first pattern; update tests (e.g.,
testBearerTokenInMessageIsRedacted) to include cases "Authorization: Bearer …"
and mixed-case scenarios to prevent regressions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 19e0fab2-f68a-4970-b983-740a302202e0

📥 Commits

Reviewing files that changed from the base of the PR and between 19b12e2 and 1fa88b8.

📒 Files selected for processing (2)
  • sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/SDKLogger.swift
  • sdk/runanywhere-swift/Tests/RunAnywhereTests/SecurityLoggingTests.swift

@ManthanNimodiya
Copy link
Copy Markdown
Contributor Author

@Siddhesh2377 - please have a look when you get time

@ManthanNimodiya
Copy link
Copy Markdown
Contributor Author

@sanchitmonga22 - please review when you get chance and let me know if any changes needed.

@Siddhesh2377
Copy link
Copy Markdown
Collaborator

hey @ManthanNimodiya we are in the middle of a Repo-Refactor, I will review Your changes shortly and merge them once we are done with the refactor okay

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.

[Security] Address cleartext logging of potentially sensitive information

2 participants