Skip to content

fix: redact git credentials from clone failure logs - #2697

Merged
IsmaelMartinez merged 10 commits into
The-PR-Agent:mainfrom
dwin-gharibi:fix/clone-credential-log-leak
Aug 31, 2026
Merged

IsmaelMartinez merged 10 commits into
The-PR-Agent:mainfrom
dwin-gharibi:fix/clone-credential-log-leak

Conversation

@dwin-gharibi

Copy link
Copy Markdown
Contributor

Closes #2696.

Description

A live token, PAT or bearer token appears in cleartext in the application log on any clone failure.

Root cause

GitProvider.clone (pr_agent/git_providers/git_provider.py:194-196) logged the credential-bearing clone URL and a full traceback. _prepare_clone_url_with_token deliberately embeds secrets: https://<token>@github.com/…, https://oauth2:<pat>@gitlab…, and Bitbucket Server passes -c http.extraHeader='Authorization: Bearer <token>'.

The fix

Add a redact_credentials() helper that strips URL userinfo and masks Authorization: header values, apply it to both the URL and the error text, and use .error() rather than .exception() so the argv traceback is not rendered.

Behaviour change

Before extra.artifact.url = 'https://oauth2:glpat-SECRET987@gitlab.acme.com/team/private.git'
After extra.artifact.url = 'https://gitlab.acme.com/team/private.git'; Bitbucket argv shows Authorization: Bearer <redacted>

Verified for all three credential shapes, including via the real BitbucketServerProvider._clone_inner.

Files changed

pr_agent/git_providers/git_provider.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Testing

  • pytest tests/unittest — 1748 passed, 1 skipped, 1 xfailed (unchanged from main)
  • CI pipeline reproduced locally exactly as .github/workflows/build-and-test.yaml runs it:
    docker build -f docker/Dockerfile --target test .
    docker run --rm <image> pytest -v tests/unittest
    
    → 1748 passed, 1 skipped, 1 xfailed on python:3.12.13-slim
  • Targeted regression check for this defect: reproduced on main, no longer reproducible on this branch
  • ruff — no new findings vs main; isort — clean

Risk / compatibility

Diagnostics are preserved (host, path, dest folder, error text); only secrets are masked. The stack trace is dropped from this one call site because it was the leak vector.

Checklist

  • Focused on a single fix
  • Existing tests pass
  • No new dependencies
  • No user-facing configuration changes
  • Reviewed by a maintainer

Copilot AI lite review requested due to automatic review settings August 17, 2026 17:22

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the bug label Aug 17, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Redact git credentials from clone failure logs

🐞 Bug fix 🕐 20-40 Minutes

Grey Divider

AI Description

• Add credential redaction for git clone URLs and Authorization headers
• Sanitize clone failure logs to avoid leaking tokens/PATs
• Replace exception logging with error logging to prevent argv/traceback leaks
Diagram

graph TD
  A["GitProvider.clone"] --> B["_prepare_clone_url_with_token"] --> C["clone_url (may include token)"] --> D["_clone_inner (git clone)"] --> E{Exception?}
  E -->|yes| F["redact_credentials"] --> G["logger.error"] --> H["Application logs"]
  E -->|no| I["ScopedClonedRepo"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Central logging filter/redaction layer
  • ➕ Enforces redaction consistently across all log call sites
  • ➕ Reduces risk of future leaks when new logging is added
  • ➖ More invasive; requires logger configuration and broader testing
  • ➖ Harder to ensure all credential formats are covered without false positives
2. Avoid embedding credentials in clone URL (use git credential helpers / env)
  • ➕ Eliminates a major class of leaks at the source
  • ➕ Potentially safer across subprocess boundaries and debug output
  • ➖ May not be feasible across all providers/auth schemes supported today
  • ➖ Requires larger behavioral changes in providers and clone invocation

Recommendation: The PR’s approach is a good, low-risk targeted fix: sanitize the two known leak vectors (credential-bearing URL and error text) at the logging call site and avoid emitting tracebacks. Consider a follow-up to add unit tests for redact_credentials() and/or adopt a broader logging redaction filter to prevent similar issues elsewhere.

Files changed (1) +14 / -2

Bug fix (1) +14 / -2
git_provider.pyRedact credentials and remove traceback from clone failure logs +14/-2

Redact credentials and remove traceback from clone failure logs

• Introduces a redact_credentials() helper that strips URL userinfo tokens and masks Authorization header values using regexes. Updates GitProvider.clone() to log failures via logger.error with sanitized URL/error fields instead of logger.exception to avoid leaking secrets through tracebacks/argv.

pr_agent/git_providers/git_provider.py

@qodo-code-review

qodo-code-review Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. GitLab scheme leaks credentials ✓ Resolved 🐞 Bug ⛨ Security ⭐ New
Description
The GitLab validation log redacts the full repository URL but logs scheme unchanged; for a
malformed URL such as https://user:********@gitlab., scheme contains the credentials and is
emitted in cleartext. This preserves the credential leak on the exact validation-failure path these
changes intend to secure.
Code

pr_agent/git_providers/gitlab_provider.py[1476]

+            get_logger().error(f"Either no access token found, or repo URL: {redact_credentials(repo_url_to_clone)} "
Relevance

●●● Strong

Malformed-URL validation path still logs credential-bearing scheme text; redaction needed for
complete security coverage.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The URL is split at gitlab., so everything before the host—including userinfo—is assigned to
scheme. The changed error statement then interpolates that value directly, while the redaction
helper only sanitizes values explicitly passed to it.

pr_agent/git_providers/gitlab_provider.py[1473-1477]
pr_agent/git_providers/git_provider.py[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The clone URL validation error redacts `repo_url_to_clone` but separately logs credential-bearing URL components without redaction.

## Issue Context
Splitting a URL at `gitlab.` leaves URL userinfo in `scheme`. A malformed URL with an empty suffix reaches this error and logs that userinfo.

## Fix Focus Areas
- pr_agent/git_providers/gitlab_provider.py[1473-1477]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Gitea base credentials leak ✓ Resolved 🐞 Bug ⛨ Security ⭐ New
Description
The Gitea mismatch log sanitizes repo_url_to_clone but emits the derived base_url unchanged,
exposing URL userinfo credentials configured in GITEA.URL. A credential-bearing configured base
reaches this statement whenever the supplied clone URL does not contain that base.
Code

pr_agent/git_providers/gitea_provider.py[769]

+            get_logger().error(f"url to clone: {redact_credentials(repo_url_to_clone)} does not contain {base_url}")
Relevance

●●● Strong

Directly exposes configured Gitea URL userinfo; fixing matches this PR's explicit
credential-redaction security intent.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The provider reads GITEA.URL directly into self.base_url, then removes only its scheme before
assigning base_url. The changed statement logs that derived value directly even though the clone
URL itself is sanitized.

pr_agent/git_providers/gitea_provider.py[40-44]
pr_agent/git_providers/gitea_provider.py[757-769]
pr_agent/git_providers/git_provider.py[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The clone URL mismatch error redacts the repository URL but not the separately derived Gitea base URL.

## Issue Context
`base_url` is derived from `GITEA.URL` and retains any URL userinfo credentials present in that configuration.

## Fix Focus Areas
- pr_agent/git_providers/gitea_provider.py[758-769]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. GitHub base credentials leak ✓ Resolved 🐞 Bug ⛨ Security ⭐ New
Description
The GitHub mismatch log sanitizes repo_url_to_clone but emits github_com unchanged, so
credentials embedded in GITHUB.BASE_URL are logged as cleartext URL userinfo. For an enterprise
base such as https://user:********@ghe.example/api/v3, the derived value retains user:password@
and reaches this error when the clone URL does not match.
Code

pr_agent/git_providers/github_provider.py[1480]

+            get_logger().error(f"url to clone: {redact_credentials(repo_url_to_clone)} does not contain {github_com}")
Relevance

●●● Strong

Directly exposes enterprise GitHub base URL userinfo; fixing matches this PR's explicit
credential-redaction security intent.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
GITHUB.BASE_URL is transformed into base_url_html, then split into github_com; neither
transformation strips URL userinfo. The changed log passes only the clone URL through
redact_credentials and interpolates github_com directly.

pr_agent/git_providers/github_provider.py[56-57]
pr_agent/git_providers/github_provider.py[1467-1480]
pr_agent/git_providers/git_provider.py[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The clone URL mismatch error redacts the repository URL but not the separately derived GitHub base value.

## Issue Context
`github_com` is derived from the configured base URL and can retain URL userinfo credentials.

## Fix Focus Areas
- pr_agent/git_providers/github_provider.py[1475-1480]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Validation-failure logs leak clone URL credentials ✓ Resolved 🐞 Bug ⛨ Security
Description
When _prepare_clone_url_with_token() rejects a repo URL, provider implementations (gitlab, github,
gitea, bitbucket) log repo_url_to_clone unredacted and clone() returns immediately at line
204-206, before the new redacted exception-handler at lines 213-215 is ever reached. Since callers
such as pr_help_docs.py may pass a URL that itself already embeds credentials (e.g. from a stored
PAT-in-URL config), this bypasses the newly added redaction entirely for the validation-failure
path.
Code

pr_agent/git_providers/git_provider.py[R213-215]

+            get_logger().error(f"Clone failed: Could not clone url.",
+                artifact={"error": redact_credentials(e), "url": redact_credentials(clone_url),
+                          "dest_folder": dest_folder})
Relevance

●●● Strong

Direct credential-leak path contradicts PR intent; recent security hardening feedback is accepted.

PR-#2406
PR-#2314

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
clone() calls _prepare_clone_url_with_token() at line 203 and returns at line 206 without
entering the try/except block that now redacts credentials (lines 213-215) whenever preparation
returns None. Provider implementations such as gitlab_provider.py:1471 (`get_logger().error(f"Repo
URL: {repo_url_to_clone} is not a valid gitlab URL.")) and gitlab_provider.py:1476-1477` log the
raw incoming URL, which can already contain embedded credentials when passed in by a caller, and
this log call is never routed through the new redact_credentials() helper introduced by this PR.

pr_agent/git_providers/git_provider.py[200-215]
pr_agent/git_providers/gitlab_provider.py[1469-1478]
pr_agent/git_providers/github_provider.py[1469-1484]
pr_agent/git_providers/gitea_provider.py[759-773]
pr_agent/git_providers/bitbucket_provider.py[667-675]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `redact_credentials()` helper added to `pr_agent/git_providers/git_provider.py` is only applied inside `GitProvider.clone()`'s exception handler. Provider-specific `_prepare_clone_url_with_token()` implementations log the raw `repo_url_to_clone` argument on validation failures, and `clone()` returns before reaching the redacted exception handler in that case, so credentials embedded in an already-credentialed input URL are not masked in these error logs.

## Issue Context
`GitProvider.clone()` in `pr_agent/git_providers/git_provider.py` calls `_prepare_clone_url_with_token(repo_url_to_clone)` and returns immediately if it yields `None`, before entering the try/except block where the PR's new redaction logic runs.

## Fix Focus Areas
- pr_agent/git_providers/git_provider.py[203-206]
- pr_agent/git_providers/gitlab_provider.py[1470-1477]
- pr_agent/git_providers/github_provider.py[1469,1471-1483]
- pr_agent/git_providers/gitea_provider.py[760-772]
- pr_agent/git_providers/bitbucket_provider.py[668-674]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (1)
5. Single-quoted literals in redact_credentials() ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
New string literals use single quotes (e.g., raw regex strings and m.group('scheme')) rather than
double quotes. This violates the project’s Python string-literal quoting convention and may cause
formatting/lint failures.
Code

pr_agent/git_providers/git_provider.py[R17-18]

+_URL_USERINFO_RE = re.compile(r'(?P<scheme>[a-zA-Z][a-zA-Z0-9+.\-]*://)[^/@\s]+@')
+_AUTH_HEADER_RE = re.compile(r'(?i)(authorization\s*:\s*(?:bearer|basic|token)\s+)\S+')
Relevance

●●● Strong

Exact precedent accepted converting newly added single-quoted Python literals to
repository-preferred double quotes.

PR-#2406

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2694657 requires double quotes for Python string literals. The added code in
git_provider.py uses single-quoted literals (e.g., r'...', m.group('scheme'), and
'<redacted>'), violating this rule.

Rule 2694657: Use double quotes for all Python string literals
pr_agent/git_providers/git_provider.py[17-18]
pr_agent/git_providers/git_provider.py[21-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New code introduces single-quoted Python string literals, but the repo’s compliance rule requires double quotes for string literals.

## Issue Context
This includes raw regex patterns like `r'...'` and literals like `m.group('scheme')` / `'<redacted>'`.

## Fix Focus Areas
- pr_agent/git_providers/git_provider.py[17-25]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Grey Divider

Context sources
✅ Compliance rules (platform): 34 rules
Review mode: 🚀 Fast: The latest push only refactors three test fixtures to use __new__ and SimpleNamespace; it changes no runtime behavior and is a localized, low-risk test-only adjustment.

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 9aced27

Results up to commit 2205519 ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 📜 Skill insights (0)


Remediation recommended
1. Single-quoted literals in redact_credentials() ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
New string literals use single quotes (e.g., raw regex strings and m.group('scheme')) rather than
double quotes. This violates the project’s Python string-literal quoting convention and may cause
formatting/lint failures.
Code

pr_agent/git_providers/git_provider.py[R17-18]

+_URL_USERINFO_RE = re.compile(r'(?P<scheme>[a-zA-Z][a-zA-Z0-9+.\-]*://)[^/@\s]+@')
+_AUTH_HEADER_RE = re.compile(r'(?i)(authorization\s*:\s*(?:bearer|basic|token)\s+)\S+')
Relevance

●●● Strong

Exact precedent accepted converting newly added single-quoted Python literals to
repository-preferred double quotes.

PR-#2406

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2694657 requires double quotes for Python string literals. The added code in
git_provider.py uses single-quoted literals (e.g., r'...', m.group('scheme'), and
'<redacted>'), violating this rule.

Rule 2694657: Use double quotes for all Python string literals
pr_agent/git_providers/git_provider.py[17-18]
pr_agent/git_providers/git_provider.py[21-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New code introduces single-quoted Python string literals, but the repo’s compliance rule requires double quotes for string literals.

## Issue Context
This includes raw regex patterns like `r'...'` and literals like `m.group('scheme')` / `'<redacted>'`.

## Fix Focus Areas
- pr_agent/git_providers/git_provider.py[17-25]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit c2562f8 🧠 Deep


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 📜 Skill insights (0)


Remediation recommended
1. Validation-failure logs leak clone URL credentials ✓ Resolved 🐞 Bug ⛨ Security
Description
When _prepare_clone_url_with_token() rejects a repo URL, provider implementations (gitlab, github,
gitea, bitbucket) log repo_url_to_clone unredacted and clone() returns immediately at line
204-206, before the new redacted exception-handler at lines 213-215 is ever reached. Since callers
such as pr_help_docs.py may pass a URL that itself already embeds credentials (e.g. from a stored
PAT-in-URL config), this bypasses the newly added redaction entirely for the validation-failure
path.
Code

pr_agent/git_providers/git_provider.py[R213-215]

+            get_logger().error(f"Clone failed: Could not clone url.",
+                artifact={"error": redact_credentials(e), "url": redact_credentials(clone_url),
+                          "dest_folder": dest_folder})
Relevance

●●● Strong

Direct credential-leak path contradicts PR intent; recent security hardening feedback is accepted.

PR-#2406
PR-#2314

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
clone() calls _prepare_clone_url_with_token() at line 203 and returns at line 206 without
entering the try/except block that now redacts credentials (lines 213-215) whenever preparation
returns None. Provider implementations such as gitlab_provider.py:1471 (`get_logger().error(f"Repo
URL: {repo_url_to_clone} is not a valid gitlab URL.")) and gitlab_provider.py:1476-1477` log the
raw incoming URL, which can already contain embedded credentials when passed in by a caller, and
this log call is never routed through the new redact_credentials() helper introduced by this PR.

pr_agent/git_providers/git_provider.py[200-215]
pr_agent/git_providers/gitlab_provider.py[1469-1478]
pr_agent/git_providers/github_provider.py[1469-1484]
pr_agent/git_providers/gitea_provider.py[759-773]
pr_agent/git_providers/bitbucket_provider.py[667-675]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `redact_credentials()` helper added to `pr_agent/git_providers/git_provider.py` is only applied inside `GitProvider.clone()`'s exception handler. Provider-specific `_prepare_clone_url_with_token()` implementations log the raw `repo_url_to_clone` argument on validation failures, and `clone()` returns before reaching the redacted exception handler in that case, so credentials embedded in an already-credentialed input URL are not masked in these error logs.

## Issue Context
`GitProvider.clone()` in `pr_agent/git_providers/git_provider.py` calls `_prepare_clone_url_with_token(repo_url_to_clone)` and returns immediately if it yields `None`, before entering the try/except block where the PR's new redaction logic runs.

## Fix Focus Areas
- pr_agent/git_providers/git_provider.py[203-206]
- pr_agent/git_providers/gitlab_provider.py[1470-1477]
- pr_agent/git_providers/github_provider.py[1469,1471-1483]
- pr_agent/git_providers/gitea_provider.py[760-772]
- pr_agent/git_providers/bitbucket_provider.py[668-674]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 7df3002

@dwin-gharibi

Copy link
Copy Markdown
Contributor Author

@naorpeled

@dwin-gharibi
dwin-gharibi force-pushed the fix/clone-credential-log-leak branch from 7df3002 to c2562f8 Compare August 19, 2026 11:49
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit c2562f8

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 11f9a33

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The redaction helper works. I confirmed a token leaks through both the traceback and the CalledProcessError argv on main, and that this branch is clean. Two spots still print a credential-bearing value, one of them on the very line this PR is fixing.

Happy for you to take both. The first has a suggestion you can commit directly. If it goes quiet for a few days I will push it myself rather than hold the rest of the fix up.

@IsmaelMartinez

Copy link
Copy Markdown
Collaborator

@dwin-gharibi, the tests you added after the earlier request made it possible to review the whole batch in one pass rather than one at a time. Eight are merged, each closing its companion issue, which took the repository from 122 open items to 105.

  1. Could you pick up the scheme redaction above? There is a suggestion on the line you can commit directly.
  2. Do the force-pushed rebases on fix: render a trailing deletion-only hunk instead of dropping it #2683 and fix: compare configuration skip keys case-insensitively #2689 look right to you? Both were test-only conflicts, and on fix: compare configuration skip keys case-insensitively #2689 I kept the fixture that snapshots the whole CONFIG section over the per-key restore, since Dynaconf ignores dotted unset.

@dwin-gharibi
dwin-gharibi force-pushed the fix/clone-credential-log-leak branch from 11f9a33 to 5ea13e3 Compare August 21, 2026 07:01
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 5ea13e3

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit efe4d45

Comment thread pr_agent/git_providers/git_provider.py Outdated

MAX_FILES_ALLOWED_FULL = 50

_URL_USERINFO_RE = re.compile(r"(?P<scheme>[a-zA-Z][a-zA-Z0-9+.\-]*://)[^/@\s]+@")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nearly there, but this one is quadratic. [a-zA-Z0-9+.\-]* is unbounded before ://, so on text that never completes a match the engine rescans the tail from every start position. Measured on a 32k string: 16x the input costs 131x to 255x the time, 659 ms for a single sub. redact_credentials is called on str(e) from a clone failure and on PR_HELP_DOCS.REPO_URL, so the input is not always short or trusted.

Bounding both quantifiers fixes it. I ran the replacement: identical output on every URL shape I tried, including multi-URL strings and exception text, 1.5 ms instead of 659 ms on the same adversarial input, and your suite stays green at 2044.

Suggested change
_URL_USERINFO_RE = re.compile(r"(?P<scheme>[a-zA-Z][a-zA-Z0-9+.\-]*://)[^/@\s]+@")
_URL_USERINFO_RE = re.compile(r"(?P<scheme>[a-zA-Z][a-zA-Z0-9+.\-]{0,30}://)[^/@\s]{1,512}@")

_AUTH_HEADER_RE is fine as it stands, no change needed there.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correcting my own suggestion here, and I have already pushed the fix.

The {1,512} on the userinfo was wrong. From 512 characters up it leaves the credential in the log where the original stripped it, and Bitbucket builds x-token-auth:<bearer>@, where a JWT can reach that length. So the suggestion I asked you to take traded a slow regex for a leaky one.

The scheme bound alone is what removes the quadratic behaviour: 667 ms to 2.6 ms at 32k, still 2.0x per doubling, and byte-identical to the original across 200k random inputs and scheme lengths to 200. Sorry for the churn.

@IsmaelMartinez

Copy link
Copy Markdown
Collaborator

The redaction itself is right, and I confirmed it end to end: driving the three clone paths with a tokenised URL leaks the token on main and leaks nothing on this branch, including the Gitea copy I only mentioned in passing. Thanks for picking all three up.

Holding the approval on one thing only, the suggestion above. I have to correct myself there: I said earlier the patterns were linear-time and that was wrong, I had reasoned about them rather than timed them. _URL_USERINFO_RE is quadratic. Take the suggestion and this is good to go.

IsmaelMartinez and others added 2 commits August 31, 2026 07:23
The unbounded quantifiers made redact_credentials quadratic on text that never
completes a match, 378 ms for one sub on a 32k string against 0.97 ms bounded,
with identical output on every URL shape tested.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C1F7BmLnLhSrkpo3QJsehP
…tials in logs

The 30-char scheme bound is what removes the quadratic backtracking; {1,512} on
the userinfo added nothing measurable and let a longer credential through, and
Bitbucket builds x-token-auth:<bearer>@ where a JWT can exceed it.
@qodo-code-review

qodo-code-review Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again manually by commenting /agentic_review on this PR.

Grey Divider

Qodo Logo

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @dwin-gharibi, and for turning round both of the leaks I raised the first time.

I have pushed to your branch rather than let it sit: current main merged in to clear the conflict, the regex from the review thread applied, and a test that a long scheme or credential does not open a redaction gap.

I also had to correct my own suggestion, see the thread above. The userinfo bound I asked for would have left long credentials in the log, so only the scheme is bounded now.

All checks green. Approving and merging.

@IsmaelMartinez
IsmaelMartinez merged commit 1040a10 into The-PR-Agent:main Aug 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git credentials are written to the logs whenever a clone fails

4 participants