-
-
Notifications
You must be signed in to change notification settings - Fork 0
Harden policy validation checks #683
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
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 |
|---|---|---|
|
|
@@ -31,25 +31,26 @@ | |
| fi | ||
| # 2. The rule that told repos not to declare dependencies at all. hyperpolymath/ubicity | ||
| # a phrase inside a blockquote or quotation marks is HISTORY, not policy | ||
| live(){ grep -vE '^[[:space:]]*>' "$1" | grep -vE '"[^"]*'"$2"'[^"]*"|“[^”]*'"$2"'[^”]*”'; } | ||
| live(){ grep -vE '^[[:space:]]*>' "$1" | grep -vE '"[^"]*('"$2"')[^"]*"|“[^”]*('"$2"')[^”]*”'; } | ||
|
Check warning on line 34 in tools/policy/check-language-policy.sh
|
||
| # imported zod and glob, shipped no manifest, and could not build under ANY toolchain. | ||
| if live "$f" 'No package.json for runtime deps' | grep -qF 'No package.json for runtime deps'; then | ||
| if live "$f" 'No package.json for runtime deps' | grep -F 'No package.json for runtime deps' >/dev/null; then | ||
| fail "$f:$(grep -nF 'No package.json for runtime deps' "$f" | head -1 | cut -d: -f1)" \ | ||
| 'Forbids declaring dependencies. Bun is npm-compatible; a manifest is REQUIRED.' | ||
| fi | ||
| if live "$f" 'deno.json imports' | grep -qF 'deno.json imports'; then | ||
| if live "$f" 'deno.json imports' | grep -F 'deno.json imports' >/dev/null; then | ||
| fail "$f:$(grep -nF 'deno.json imports' "$f" | head -1 | cut -d: -f1)" \ | ||
| 'Directs dependency declaration into deno.json. Use package.json + bun.lock.' | ||
| fi | ||
| # 3. No tool description may advertise TypeScript. Owner ruling 2026-08-27: | ||
| # "no typescript ... that should not exist at all." | ||
| if grep -nE 'Executes .\.ts. directly|JS/TS runtime' "$f" >/dev/null; then | ||
| fail "$f:$(grep -nE 'Executes .\.ts. directly|JS/TS runtime' "$f" | head -1 | cut -d: -f1)" \ | ||
| typescript_runtime='Executes .\.ts. directly|JS/TS runtime|[Ss]upports? TypeScript|[Rr]uns? [^[:alnum:][:space:]]*\.ts[^[:alnum:][:space:]]* files?' | ||
|
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. ⚪ LOW RISK Suggestion: The regex pattern |
||
| if live "$f" "$typescript_runtime" | grep -E "$typescript_runtime" >/dev/null; then | ||
| fail "$f:$(grep -nE "$typescript_runtime" "$f" | head -1 | cut -d: -f1)" \ | ||
| 'Advertises TypeScript execution. TypeScript is banned; do not describe tools as TS runtimes.' | ||
| fi | ||
| # 4. Blanking scars. A bulk purge substituted a token with an EMPTY STRING, which also | ||
| # produced `rm -rf /lib` in wordpress-tools (the lethal shape is <token>/path -> /path). | ||
| if awk -F'|' 'NF>=4 && $2 ~ /^[[:space:]]*$/{exit 0} END{exit 1}' "$f"; then | ||
| if awk -F'|' 'NF>=4 && $2 ~ /^[[:space:]]*$/{found=1; exit} END{exit !found}' "$f"; then | ||
| fail "$f" 'Policy table row with an EMPTY first cell - blanking scar from a bulk substitution.' | ||
| fi | ||
| if grep -nF '| **** |' "$f" >/dev/null; then | ||
|
|
||
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.
🟡 MEDIUM RISK
The current implementation of
liveusinggrep -vEto exclude quoted patterns can lead to false negatives. If a line contains both a legitimate violation and a quoted historical reference, the entire line is discarded. Instead of excluding the whole line, modify the function to strip the quoted substrings before performing the violation check.