Skip to content

Comments

fix: escape regex metacharacters in workflow file pattern matching#5

Merged
troinine merged 4 commits intochore/pr-approvalfrom
copilot/sub-pr-4
Dec 9, 2025
Merged

fix: escape regex metacharacters in workflow file pattern matching#5
troinine merged 4 commits intochore/pr-approvalfrom
copilot/sub-pr-4

Conversation

Copy link

Copilot AI commented Dec 9, 2025

The sensitive file check in the auto-approval workflow had a regex pattern bug where the unescaped dot in .github/workflows/ acted as a wildcard, allowing false matches like _github/workflows/ or agithub/workflows/ to pass through.

Changes:

  • Escaped the dot literal: .github/workflows/\.github/workflows/
  • Added -E flag to grep for extended regex interpretation
  • Updated to use bash array syntax for SENSITIVE_PATTERNS (merged from base branch)
- SENSITIVE_PATTERNS='
-   .github/workflows/
- '
+ SENSITIVE_PATTERNS=(
+   "\.github/workflows/"
+ )
  CHANGED_FILES=$(gh pr view "$PR_URL" --repo "$REPO" --json files | jq -r '.files[].path')
- for pattern in $SENSITIVE_PATTERNS; do
-   if echo "$CHANGED_FILES" | grep -q "^$pattern"; then
+ for pattern in "${SENSITIVE_PATTERNS[@]}"; do
+   if echo "$CHANGED_FILES" | grep -qE "^$pattern"; then

This ensures only paths starting with .github/workflows/ trigger the sensitive file block, preventing potential security bypass vectors.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: troinine <13124764+troinine@users.noreply.github.com>
@troinine
Copy link
Owner

troinine commented Dec 9, 2025

@copilot please resolve conflicts first.

Copilot AI changed the title [WIP] Fix auto-approval process based on review feedback fix: escape regex metacharacters in workflow file pattern matching Dec 9, 2025
Copilot AI requested a review from troinine December 9, 2025 19:13
Co-authored-by: troinine <13124764+troinine@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 9, 2025

@copilot please resolve conflicts first.

Conflicts resolved in commit 8fa0807. The merge successfully combines the array syntax from the base branch with the security fix (escaped dot and -E flag). The pattern matching now correctly blocks auto-approval for workflow file modifications while preventing false matches.

Copilot AI requested a review from troinine December 9, 2025 19:19
Signed-off-by: Tero Roininen <troinine@users.noreply.github.com>
@troinine troinine marked this pull request as ready for review December 9, 2025 19:25
@troinine troinine merged commit e75e36d into chore/pr-approval Dec 9, 2025
3 checks passed
@troinine troinine deleted the copilot/sub-pr-4 branch December 9, 2025 19:25
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.

2 participants