Skip to content

fix(hooks): allow a jq filter after read-only GraphQL queries - #180

Merged
furedea merged 2 commits into
mainfrom
fix/allow-graphql-queries-with-jq
Nov 12, 2026
Merged

furedea merged 2 commits into
mainfrom
fix/allow-graphql-queries-with-jq

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

概要

gh api graphql -f query='query ...' の読み取り専用ルールに,末尾の --jq '<式>' または -q '<式>' を任意で許可しました.これまでは jq フィルタを付けると手動承認が必要でした.

  • 変更: agents/hooks/rules/allowed_commands.json の GraphQL ルール末尾に ( (--jq|-q) '[^']*')? を追加
  • テスト: tests/hooks/test_allowed_graphql.py を新設(test_allowed_command.py は 500 行の file-length 上限のため分離)
    • 複数行クエリ+--jq,{始まりのクエリ+-q は許可
    • mutation(--jq あり/なし),引用符の外への ;・&&・| の追記,2つ目の -f は引き続き ask

検証

  • uv run pytest: 全件成功
  • uv run ruff check / ruff format --check / ty check: 成功

計画からの逸脱: なし.

Closes #179

🤖 Generated with Claude Code

@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T06:15:17.276225Z 9ec651a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Review summary: no findings.

The new optional suffix ( (--jq|-q) '[^']*')? comes after the query's closing quote, and the jq filter must be a single-quoted literal, so it can't expand anything or break out of its quotes. Chains, and-lists and pipes are still caught by the shell-syntax segmentation in guard_command.command_verdict. A second -f query=... is still rejected because $ anchors the end of the pattern. Queries that start with mutation are still excluded, with or without --jq. The new tests cover both the allow cases and the ask cases.

I did not run the tests locally; this review is based on reading the diff and the guard code.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9863a79bb0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

pytest.param("gh api graphql -f query='{ viewer { login } }' -q '.data'", id="a shorthand query with -q"),
],
)
def test_read_only_queries_with_a_jq_filter_are_allowed(command: str) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 新しい GraphQL テストを関連テストに登録する

関連テスト選択を確認すると,.agents/hooks/rules/related_test_extensions.json の allowed_commands.json 向け一覧にこの新規ファイルが含まれていないため,allowed_commands.json だけを変更した通常の後続作業では test_allowed_graphql.py が実行対象になりません.このコミットではテスト自身も変更されているので実行されますが,以後この正規表現が退行しても Stop 検証が見逃すため,新しいテストを同マッピングへ追加してください.

Useful? React with 👍 / 👎.

@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No findings (P0: 0, P1: 0, P2: 0, P3: 0).

  • The new optional suffix ( (--jq|-q) '[^']*')? accepts only one single-quoted filter. Single quotes stop any shell expansion, and anything else after the query (a second -f, -F, a redirection, or a double-quoted filter) still fails the anchored regex and falls back to ask.
  • shell_syntax.parse splits chains, pipes and lists before the rule is checked. The new tests cover these cases (;, &&, |), plus mutations with and without --jq and a second query.
  • A jq filter only reshapes the response that gh prints. It cannot make the query write anything, so the rule stays read-only.
  • The new test file is registered in related_test_extensions.json.

I could not run the test suite in this review environment; this review is based on reading the code.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 9ec651a7a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit cfb80d8 into main Nov 12, 2026
27 checks passed
@furedea
furedea deleted the fix/allow-graphql-queries-with-jq branch November 12, 2026 06:20
furedea pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.2](v0.1.1...v0.1.2)
(2026-11-12)


### Features

* **hooks:** add Go and Rust model rules with eval fixtures
([#158](#158))
([9731488](9731488))
* **hooks:** show model-rule timing and skip rule fixtures
([#157](#157))
([d0c32ae](d0c32ae))
* **hooks:** show the model rules as one result line with cost
([#170](#170))
([41b9033](41b9033))


### Bug Fixes

* **hooks:** allow a jq filter after read-only GraphQL queries
([#180](#180))
([cfb80d8](cfb80d8))
* **hooks:** keep model-rule eval fixtures out of Stop test verification
([#160](#160))
([a4f1c6c](a4f1c6c))
* **hooks:** read paths literally in every jev-lint child process
([#173](#173))
([0d2c683](0d2c683))
* **hooks:** remove model-rule false positives with principles and eval
fixtures ([#163](#163))
([b07fc4e](b07fc4e))
* **hooks:** report one count per runner in the Stop test lines
([#177](#177))
([0f36b82](0f36b82))
* **hooks:** take the model-rule cached count from the dry-run plan
([#167](#167))
([c87fdfd](c87fdfd))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
furedea-agent Bot pushed a commit to furedea/dotfiles that referenced this pull request Nov 12, 2026
Also picks up the jq filter after read-only GraphQL queries
(furedea/agent-config#180).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow read-only gh api graphql queries that end with --jq

1 participant