27 lines
847 B
Rego
27 lines
847 B
Rego
# METADATA
|
|
# scope: package
|
|
# title: Block Frontend Linter Config (Bash)
|
|
# description: Blocks Bash edits to frontend linter config files
|
|
# custom:
|
|
# routing:
|
|
# required_events: ["PreToolUse"]
|
|
# required_tools: ["Bash"]
|
|
package cupcake.policies.opencode.block_linter_config_frontend_bash
|
|
import rego.v1
|
|
|
|
pattern := `(rm|mv|cp|sed|awk|chmod|chown|touch|truncate|tee|>|>>)\s.*client/.*(?:biome\.json|tsconfig\.json|\.?eslint(?:rc|\.config)|\.?prettier(?:rc|\.config)|\.?rustfmt\.toml|\.?clippy\.toml)`
|
|
|
|
deny contains decision if {
|
|
input.hook_event_name == "PreToolUse"
|
|
input.tool_name == "Bash"
|
|
|
|
command := input.tool_input.command
|
|
regex.match(pattern, command)
|
|
|
|
decision := {
|
|
"rule_id": "TS-CONFIG-001",
|
|
"reason": "Frontend linter/config file edits are prohibited.",
|
|
"severity": "HIGH"
|
|
}
|
|
}
|