-
Notifications
You must be signed in to change notification settings - Fork 0
fix: protect security contract files from autofix deletion #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7c50c44
7fb95ac
1c0ae26
b2ecfc1
306de72
936b93b
923feea
7a1d599
3382370
275b275
4386df6
b77d999
c7f9c09
0cb174b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -463,6 +463,32 @@ jobs: | |
| --snapshot "$ordinary_scope_snapshot" \ | ||
| --allowed-paths "$allowed_paths_zlist" | ||
|
|
||
| - name: Reject protected security-contract deletions and renames | ||
| run: | | ||
| set -euo pipefail | ||
| cd "$TARGET_WORKSPACE" | ||
| # Security-contract files may be edited only when a review explicitly | ||
| # names them, but an autofix must never delete or rename them. This | ||
| # keeps an unrelated optimization from removing origin validation, | ||
| # its regression evidence, or the standards record. | ||
| protected_security_paths=( | ||
| "backend/core/local_http.py" | ||
| "backend/core/url_validation.py" | ||
| "backend/tests/test_local_http.py" | ||
| "backend/tests/test_url_validation.py" | ||
| "docs/doctoring/local-http-origin-port-validation.md" | ||
| ) | ||
| for protected_path in "${protected_security_paths[@]}"; do | ||
| while IFS=$'\t' read -r status _; do | ||
| case "$status" in | ||
| D|R*) | ||
| echo "::error::Autofix cannot delete or rename protected security-contract path: $protected_path" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done < <(git diff HEAD --name-status -- "$protected_path") | ||
|
Comment on lines
+482
to
+489
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: exit inside while loop works via process substitution
Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| done | ||
|
seonghobae marked this conversation as resolved.
seonghobae marked this conversation as resolved.
|
||
|
|
||
| - name: Validate changed files | ||
| if: env.RESOLVE_CONFLICT != 'true' | ||
| run: | | ||
|
|
@@ -494,6 +520,7 @@ jobs: | |
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| changed_python_files=() | ||
| changed_workflows=() | ||
| for changed_file in "${changed_files[@]}"; do | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Protected paths live only in sibling repos
The hardcoded protected paths do not exist in this repo; the workflow runs in each sibling repo's context. Where the files are absent,
git diffyields nothing and the loop is a harmless no-op, so no false positives.Was this helpful? React with 👍 or 👎 to provide feedback.