Skip to content

Improve suspicious string literals/secrets audit - #29

Open
MarkLanser wants to merge 3 commits into
dgtlss:mainfrom
MarkLanser:improve-secret-audit
Open

MarkLanser wants to merge 3 commits into
dgtlss:mainfrom
MarkLanser:improve-secret-audit

Conversation

@MarkLanser

@MarkLanser MarkLanser commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Problem

I noticed that we got a lot of false positives with this check. SourceAuditService -> TextSourceAnalyzer

It flagged:

  • access_token validation in the middleware: access_token => 'required|min:3'
  • password validation in the middleware: required|same:password
  • 'password' key in translation files
  • key names with %_access_token in it

To name a few.

Proposed solution

Also check the value of keys to (somewhat rudimentary) see if there are actually suspicious values. This way it removes all above false positives.

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of suspicious secret-like literals by checking their assigned values, reducing false positives for normal text, validation rules, field names, cache keys, enum values, translation keys, placeholders, patterns and endpoint paths.
    • Continued identifying likely credentials such as hexadecimal keys, symbol-and-digit passwords, Base64 tokens and mixed-case credentials.
  • Tests

    • Added parameterised coverage for credential detection and common non-secret values.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a3ede71b-9176-45b4-98a2-75700230dfac

📥 Commits

Reviewing files that changed from the base of the PR and between 7c08308 and 33d22d1.

📒 Files selected for processing (2)
  • src/Services/Source/TextSourceAnalyzer.php
  • tests/Services/Audits/SourceAuditServiceTest.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Services/Source/TextSourceAnalyzer.php
  • tests/Services/Audits/SourceAuditServiceTest.php

📝 Walkthrough

Walkthrough

The source analyser now filters suspicious secret literals by credential-like value patterns. Parameterised tests cover reported credential formats and excluded non-secret values.

Changes

Suspicious secret literal filtering

Layer / File(s) Summary
Credential value validation
src/Services/Source/TextSourceAnalyzer.php
Suspicious literals are reported only when their values pass looksLikeCredential. The validator rejects whitespace, selected symbols, and alphabetic word sequences with limited separators.
Parameterised audit coverage
tests/Services/Audits/SourceAuditServiceTest.php
A data-driven test verifies hexadecimal, symbol-and-digit, base64, and mixed-case credentials. It also verifies excluded text, validation rules, identifiers, keys, placeholders, patterns, and endpoint paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit checks each secret string,
Rejects plain words with no bling.
Keys and tokens pass the gate,
Text and labels must now wait.
Tests hop through each case with care.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change to suspicious string literal and secret auditing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Services/Source/TextSourceAnalyzer.php`:
- Around line 88-94: Update looksLikeCredential() to reject values containing
placeholder and validation-rule syntax characters, including %, :, , and /,
alongside the existing disallowed characters. Extend the related negative-case
provider to cover %_access_token, required_if:status,active, and
regex:/^[A-Z]+$/, ensuring these values do not produce suspicious-literal
findings.
- Around line 88-95: The credential detection logic in the surrounding analyzer
method must retain alphabetic-only values as possible credentials, including
long passphrases, instead of rejecting them via the final regex and whitespace
check. Replace those unconditional exclusions with context-aware or
confidence-based validation, and add a positive test case for an alphabetic
credential such as the reported api_key example.
🪄 Autofix

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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f13e129-2df6-4956-a6b2-8da88711cd90

📥 Commits

Reviewing files that changed from the base of the PR and between 19a079f and 7c08308.

📒 Files selected for processing (2)
  • src/Services/Source/TextSourceAnalyzer.php
  • tests/Services/Audits/SourceAuditServiceTest.php

Comment thread src/Services/Source/TextSourceAnalyzer.php Outdated
Comment thread src/Services/Source/TextSourceAnalyzer.php Outdated
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