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
16 changes: 10 additions & 6 deletions .claude/skills/triage-issue/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,28 @@ If the issue is complex or the fix is unclear, skip this section and instead not
Use the Python script at `assets/post_linear_comment.py` to handle the entire Linear API interaction. This avoids all shell escaping issues with GraphQL (`$input`, `CommentCreateInput!`) and markdown content (backticks, `$`, quotes).

The script reads `LINEAR_CLIENT_ID` and `LINEAR_CLIENT_SECRET` from environment variables (set from GitHub Actions secrets), obtains an OAuth token, checks for duplicate triage comments, and posts the comment.
1. **Write the report body to a temp file** using the Write tool (not Bash). This keeps markdown completely out of shell.

Write the triage report to `/tmp/triage_report.md`.
1. **Write the report body to a file** using the Write tool (not Bash). This keeps markdown completely out of shell.
- **In CI:** Write to `triage_report.md` in the repository root. The CI sandbox only allows writes inside the working directory; `/tmp` and Bash output redirection are blocked.
- **Locally:** You may use `/tmp/triage_report.md` or `triage_report.md` in the repo root.

2. **Run the script:**

```bash
python3 .claude/skills/triage-issue/assets/post_linear_comment.py "JS-XXXX" "/tmp/triage_report.md"
python3 .claude/skills/triage-issue/assets/post_linear_comment.py "JS-XXXX" "triage_report.md"
```

(Use the same path you wrote to: `triage_report.md` in CI, or `/tmp/triage_report.md` locally if you used that.)

If the script fails (non-zero exit), fall back to printing the full report to the terminal.

Clean up temp files after:
Clean up after:

```bash
rm -f /tmp/triage_report.md
rm -f triage_report.md
```

(In CI only `triage_report.md` in the repo root is writable; use that path for write, script, and rm.)

## Important Rules

**CRITICAL — READ-ONLY POLICY:**
Expand Down
14 changes: 11 additions & 3 deletions .claude/skills/triage-issue/assets/post_linear_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

TIMEOUT_SECONDS = 30
IDENTIFIER_PATTERN = re.compile(r"^[A-Z]+-\d+$")
ALLOWED_REPORT_DIR = "/tmp/"
# /tmp/ is allowed for local runs; repo cwd is required in CI (sandbox only allows writes in working dir)
ALLOWED_REPORT_PREFIXES = ("/tmp/", os.path.abspath(os.getcwd()) + os.sep)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path validation fails when script runs from root

Low Severity

When the script runs from the root directory /, the path validation logic creates the prefix // by appending os.sep to /. This causes validation to fail for files in the current directory like /file.md because they don't start with //. While running from / is unlikely in practice, the validation prevents the intended behavior of allowing writes to the current working directory.

Fix in Cursor Fix in Web



def _report_path_allowed(path: str) -> bool:
abs_path = os.path.abspath(path)
return any(abs_path.startswith(p) for p in ALLOWED_REPORT_PREFIXES)


def graphql(token, query, variables=None):
Expand Down Expand Up @@ -32,8 +38,10 @@ def graphql(token, query, variables=None):
print(f"Invalid identifier format: {identifier}")
sys.exit(1)

if not os.path.abspath(report_path).startswith(ALLOWED_REPORT_DIR):
print(f"Report path must be under {ALLOWED_REPORT_DIR}")
if not _report_path_allowed(report_path):
print(
f"Report path must be under /tmp/ or under current working directory ({os.getcwd()})"
)
sys.exit(1)

client_id = os.environ["LINEAR_CLIENT_ID"]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/triage-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ jobs:
/triage-issue ${{ steps.parse-issue.outputs.issue_number }} --ci
IMPORTANT: Do NOT wait for approval.
claude_args: |
--max-turns 20 --allowedTools "Write(//tmp/triage_report.md),Bash(gh api *),Bash(gh pr list *),Bash(python3 .claude/skills/triage-issue/assets/post_linear_comment.py *),Bash(rm -f /tmp/triage_report.md)"
--max-turns 20 --allowedTools "Write(triage_report.md),Bash(gh api *),Bash(gh pr list *),Bash(python3 .claude/skills/triage-issue/assets/post_linear_comment.py *),Bash(rm -f triage_report.md)"
Loading