Skip to content

Consolidate 36 Jules PRs: pre-compile regex, harden log sanitization, add dry-run plan details#175

Merged
abhimehro merged 3 commits intomainfrom
copilot/analyze-and-update-pull-requests
Feb 9, 2026
Merged

Consolidate 36 Jules PRs: pre-compile regex, harden log sanitization, add dry-run plan details#175
abhimehro merged 3 commits intomainfrom
copilot/analyze-and-update-pull-requests

Conversation

Copy link

Copilot AI commented Feb 8, 2026

Jules generated 36 overlapping PRs across three categories (Bolt/Sentinel/Palette) with heavy duplication. This PR cherry-picks the best change from each category, incorporates bot review feedback (Gemini Code Assist, Copilot reviewer, CodeQL), and consolidates into a single mergeable PR.

⚡ Performance: Pre-compile regex (from PR #173)

Moved PROFILE_ID_PATTERN, RULE_PATTERN, and two sanitization patterns to module-level compiled constants. Used in is_valid_rule, is_valid_profile_id_format, validate_profile_id, and sanitize_for_log.

PROFILE_ID_PATTERN = re.compile(r"^[a-zA-Z0-9_-]+$")
RULE_PATTERN = re.compile(r"^[a-zA-Z0-9.\-_:*\/]+$")
_BASIC_AUTH_PATTERN = re.compile(r"://[^/@]+@")
_SENSITIVE_PARAM_PATTERN = re.compile(
    r"([?&#])(token|key|secret|password|auth|access_token|api_key)=[^&#\s]*",
    flags=re.IGNORECASE,
)

🛡️ Security: Redact credentials from logs (from PR #172 + review feedback)

sanitize_for_log() now strips Basic Auth (://user:pass@host) and sensitive query params before logging. Handles # fragment separators per Gemini review. Uses [^&#\s]* to avoid consuming trailing punctuation per Copilot review.

🎨 UX: Dry-run plan details + fix duplicate function (from PR #174)

  • Added print_plan_details() showing per-folder rule counts during --dry-run
  • Removed duplicate render_progress_bar definition (first copy was dead code shadowed by second)

PRs superseded (close these)

Category PRs to close
Bolt (regex) #140, #143, #152, #155, #158, #161, #167, #173
Sentinel (security) #142, #145, #148, #151, #154, #157, #160, #169, #172
Palette (UX) #139, #141, #144, #147, #150, #153, #156, #159, #162, #165, #168, #171, #174

Keep open (independent features): #146, #149, #164 (parallel deletion), #163 (RTLO fix), #166 (.env perms), #170 (combined API calls).


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Author

Copilot AI commented Feb 8, 2026

@abhimehro Unfortunately, I hit an error while trying to use the custom Copilot setup steps configured for this repository and had to close this PR. The error I am seeing is:

no `copilot-setup-steps` job found in your `copilot-setup-steps.yml` workflow file. Please ensure you have a single job named `copilot-setup-steps`. For more details, see https://gh.io/copilot/actions-setup-steps

Once you or someone with the necessary access fixes the problem, please unassign and then reassign issue #0 to me and I'll retry. Thanks!

@trunk-io
Copy link

trunk-io bot commented Feb 8, 2026

😎 Merged manually by @abhimehro - details.

…itization, add dry-run plan details

Incorporates the best changes from 36 Jules PRs, addressing review feedback:

Bolt (Performance) - from PR #173:
- Pre-compile PROFILE_ID_PATTERN and RULE_PATTERN at module level
- Use compiled patterns in is_valid_profile_id_format, validate_profile_id, and is_valid_rule
- Supersedes PRs: #140, #143, #152, #155, #158, #161, #167, #170, #173

Sentinel (Security) - from PR #172 with review feedback:
- Enhance sanitize_for_log to redact Basic Auth credentials in URLs
- Redact sensitive query parameters (token, key, secret, password, etc.)
- Handle fragment separators (#) per Gemini Code Assist review
- Use [^&#\s]* pattern per Copilot reviewer suggestion
- Update docstring per reviewer suggestion
- Supersedes PRs: #142, #145, #148, #151, #154, #157, #160, #169, #172

Palette (UX) - from PR #174 with lint fixes:
- Add print_plan_details function for dry-run visibility
- Fix duplicate render_progress_bar definition bug
- Supersedes PRs: #139, #141, #144, #147, #150, #153, #156, #159, #162, #165, #168, #171, #174

Also: #146, #149, #164 (parallel folder deletion) and #166 (auto-fix .env perms) are independent features not consolidated here.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
…odule level

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Copilot AI changed the title [WIP] Review and prepare pull requests for merging Consolidate 36 Jules PRs: pre-compile regex, harden log sanitization, add dry-run plan details Feb 8, 2026
Copilot AI requested a review from abhimehro February 8, 2026 23:55
@abhimehro abhimehro marked this pull request as ready for review February 9, 2026 00:14
Copilot AI review requested due to automatic review settings February 9, 2026 00:14
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

👋 Development Partner is reviewing this PR. Will provide feedback shortly.

@github-actions github-actions bot added the python label Feb 9, 2026
captured = capsys.readouterr()
output = captured.out

assert "Plan Details for test_profile:" in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
output = captured.out

assert "Plan Details for test_profile:" in output
assert " - Folder A: 10 rules" in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

assert "Plan Details for test_profile:" in output
assert " - Folder A: 10 rules" in output
assert " - Folder B: 5 rules" in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert " - Folder A: 10 rules" in output
assert " - Folder B: 5 rules" in output
# Verify alphabetical ordering (A before B)
assert output.index("Folder A") < output.index("Folder B")

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
captured = capsys.readouterr()
output = captured.out

assert "Plan Details for test_profile:" in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
output = captured.out

assert "Plan Details for test_profile:" in output
assert "No folders to sync." in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
captured = capsys.readouterr()
output = captured.out

assert "📝 Plan Details for test_profile:" in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
output = captured.out

assert "📝 Plan Details for test_profile:" in output
assert "Folder A" in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

assert "📝 Plan Details for test_profile:" in output
assert "Folder A" in output
assert "10 rules" in output

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
s = s.replace(TOKEN, "[REDACTED]")

# Redact Basic Auth in URLs (e.g. https://user:pass@host)
s = _BASIC_AUTH_PATTERN.sub("://[REDACTED]@", s)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "s" doesn't conform to snake_case naming style Warning

Variable name "s" doesn't conform to snake_case naming style
s = _BASIC_AUTH_PATTERN.sub("://[REDACTED]@", s)

# Redact sensitive query parameters (handles ?, &, and # separators)
s = _SENSITIVE_PARAM_PATTERN.sub(r"\1\2=[REDACTED]", s)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "s" doesn't conform to snake_case naming style Warning

Variable name "s" doesn't conform to snake_case naming style
s = s.replace(TOKEN, "[REDACTED]")

# Redact Basic Auth in URLs (e.g. https://user:pass@host)
s = _BASIC_AUTH_PATTERN.sub("://[REDACTED]@", s)

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "s" doesn't conform to snake_case naming style Warning

Variable name "s" doesn't conform to snake_case naming style
s = _BASIC_AUTH_PATTERN.sub("://[REDACTED]@", s)

# Redact sensitive query parameters (handles ?, &, and # separators)
s = _SENSITIVE_PARAM_PATTERN.sub(r"\1\2=[REDACTED]", s)

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "s" doesn't conform to snake_case naming style Warning

Variable name "s" doesn't conform to snake_case naming style
captured = capsys.readouterr()
output = captured.out

assert "Plan Details for test_profile:" in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
output = captured.out

assert "Plan Details for test_profile:" in output
assert " - Folder A: 10 rules" in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

assert "Plan Details for test_profile:" in output
assert " - Folder A: 10 rules" in output
assert " - Folder B: 5 rules" in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert " - Folder A: 10 rules" in output
assert " - Folder B: 5 rules" in output
# Verify alphabetical ordering (A before B)
assert output.index("Folder A") < output.index("Folder B")

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
captured = capsys.readouterr()
output = captured.out

assert "Plan Details for test_profile:" in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
output = captured.out

assert "Plan Details for test_profile:" in output
assert "No folders to sync." in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
captured = capsys.readouterr()
output = captured.out

assert "📝 Plan Details for test_profile:" in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
output = captured.out

assert "📝 Plan Details for test_profile:" in output
assert "Folder A" in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

assert "📝 Plan Details for test_profile:" in output
assert "Folder A" in output
assert "10 rules" in output

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates prior overlapping changes into a single update that improves runtime efficiency and security of log output, and enhances --dry-run UX by showing a folder/rule breakdown.

Changes:

  • Pre-compiles hot-path validation regexes and log-sanitization regexes at module scope and switches call sites to reuse them.
  • Hardens sanitize_for_log() to redact Basic Auth credentials in URLs and sensitive query parameters (in addition to TOKEN), while continuing to escape control characters.
  • Adds print_plan_details() and calls it during --dry-run, plus adds/extends tests covering dry-run output and new sanitization behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
main.py Adds pre-compiled regex constants, strengthens sanitize_for_log, introduces print_plan_details, and wires it into dry-run flow.
tests/test_plan_details.py New pytest tests validating dry-run plan detail output ordering and no-folder behavior.
tests/test_log_sanitization.py Adds unittest coverage for Basic Auth and sensitive query parameter redaction in sanitize_for_log.

@abhimehro abhimehro merged commit cf4c32b into main Feb 9, 2026
24 of 25 checks passed
@abhimehro abhimehro deleted the copilot/analyze-and-update-pull-requests branch February 9, 2026 00:25
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.

3 participants