Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .agents/rules/code-style.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
trigger: glob
description: Cross-language code style, control flow, and CLI conventions
globs: "*.py,*.sh,*.cc,*.h,*.go,*.bzl,*.bazel"
globs: "*.py,*.sh,*.cc,*.h,*.go,*.bzl,*.bazel,*.yaml,*.yml"
---

# Code Style Rules
Expand Down Expand Up @@ -31,6 +31,9 @@ Order definitions within a file as:
domain state.
* Do not write nested comprehensions or comprehensions with multiple `for`
clauses; use explicit loops.
* Avoid long or complex inline expressions (e.g. multi-condition ternaries,
compound boolean chains, or dense one-liners). Break them into named
intermediate variables, prior preparation steps, or explicit statements.

## CLI & Flags
* Comment non-obvious flags (`--force`), non-default schemes, subtle arguments
Expand Down
13 changes: 9 additions & 4 deletions .agents/rules/github_actions_workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ globs: ".github/workflows/**,.github/actions/**,.github/dependabot.yml"
* **Untrusted Git Ref Names (`github.head_ref`, `github.ref_name`)**: Treat
branch and tag names as untrusted input. Git ref names allow quotes (`'`, `"`)
and shell metacharacters (`;`, `&`, `|`, `$()`, `` ` ``); reject or guard
against quotes and `#` before writing refs to `.bazelrc`.
against quotes and `#` before writing refs to `.bazelrc`. Sanitize the value
in a dedicated prior step (e.g. stripping characters outside
`[a-zA-Z0-9._/-]`) and output to `$GITHUB_OUTPUT` rather than writing complex
inline expression guards.
* **CLI Argument & Option-Flag Injection**: Validate untrusted inputs (such as
slash-command arguments from issue or PR comments) against strict allowlist
regexes before writing to `$GITHUB_OUTPUT` or passing to tools. Separate
Expand All @@ -74,16 +77,18 @@ globs: ".github/workflows/**,.github/actions/**,.github/dependabot.yml"
* **Authorize Before Mutating State**: In comment- or event-triggered workflows,
verify actor authorization (`author_association` or user allowlist) before
writing to `$GITHUB_OUTPUT` or `$GITHUB_ENV`, posting reactions, or triggering
failure-reporting jobs.
failure-reporting jobs. In failure-reporting jobs, gate on
`needs.parse_step.result == 'success' && contains(needs.*.result, 'failure')`
without adding redundant `outputs.command != ''` predicates.
* **Single-Line `$GITHUB_OUTPUT` and `$GITHUB_ENV` Writes**: Reject `\n` and
`\r` in keys and values before writing `key=value` lines to `$GITHUB_OUTPUT`
or `$GITHUB_ENV`. In line-anchored regexes over comment or PR bodies, match
horizontal whitespace (`[ \t]`) and non-linebreak characters (`[^\r\n]`)
rather than `\s` or `.`.
* **Suppress Untrusted Stdout in Privileged Jobs**: Never echo raw PR bodies,
titles, or comment bodies to stdout (pass `--quiet` to `grep`, and use
`printf '%s\n'` instead of `echo`), preventing `::...::` workflow command
injection.
`printf '%s\n'` instead of `echo` to avoid option-flag parsing and escape
expansion), preventing `::...::` workflow command injection.

## Workflow Scripts & Testing
* **Separate Script Files (No Inline Scripts)**: Factor non-trivial scripts
Expand Down
Loading