GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow parsing of graphQL queries by dpup · Pull Request #14 · majorcontext/keep

Conversation

@dpup

@dpup dpup commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
claude added 4 commits November 2, 2026 06:52
@claude
feat(cel): add graphql() request parser
1a47892
graphql(params.body) parses a GraphQL-over-HTTP request body into
{valid, error, operations, queries, mutations, subscriptions}. Each root
field carries its real name, alias, and args with variables and variable
defaults substituted. Every operation is reported regardless of
operationName, root fragment spreads and inline fragments are expanded,
and directives are ignored, so rules see every root field the document
contains. Malformed input returns valid=false with empty lists.

The function is registered for the original-params rewrite so it parses
the body as sent, even in case-insensitive scopes: GraphQL names and node
IDs are case-sensitive.

The rewrite now skips call text inside string literals and at the end of
longer identifiers; previously `'hasSecrets(x)'` in a literal was
rewritten and corrupted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181tDqDyMAGnCcqMAd2JEWf
@claude
feat(engine): add RequiresBodyFor
eac28a5
Engine.RequiresBodyFor(scope, call) narrows RequiresBody by operation: a
rule that reads params.body counts only when its operation glob matches
the call (normalized as Evaluate normalizes it). Pinning a body rule to
one endpoint, e.g. `post api.github.com/graphql`, lets a gatekeeper
buffer bodies for that endpoint alone instead of making the whole scope
JSON-only. An unknown scope returns true.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181tDqDyMAGnCcqMAd2JEWf
@claude
docs: add graphql() and RequiresBodyFor to CHANGELOG
70b52f1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181tDqDyMAGnCcqMAd2JEWf
@claude
fix: substitute defs when validating rule bytes
4630cf0
ValidateRuleBytes compiled each when expression as written, without
substituting defs or injecting original-case params, so a rule file
that LoadFromBytes accepts failed validation with "undeclared
reference". Both paths now prepare expressions through
keepcel.PrepareWhen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181tDqDyMAGnCcqMAd2JEWf
@claude

claude Bot commented Nov 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Claude finished @dpup's task in 34s —— View job


Review of #14: graphql() request parser

I read the diff but didn't run the tests or linter. I found no blocking issues.

What I checked

  • Fail-closed behavior: ParseGraphQLRequest never errors. Malformed input returns valid=false with empty lists, so .exists() is safe.
  • Operation reporting: Every operation in the document is reported regardless of operationName. This closes the "run a different operation" bypass.
  • Expansion limits: Fragment expansion is bounded by depth (32), a root-field cap (1000) and a cycle check. Every leaf of the expansion is a field, so the field cap also bounds fan-out from repeated spreads, and the 32-level depth cap keeps recursion shallow.
  • Variable defaults: lookup calls r.value(d.DefaultValue) on a default. gqlparser parses defaults as const values, so a variable can't appear there and the recursion can't loop.
  • RequiresBodyFor: It uses the same normalization as Evaluate, and an empty glob matches everything, as documented. An unknown scope returns true, which fails safe.
  • PrepareWhen: Sharing it between NewEvaluator and ValidateRuleBytes fixes the def-substitution validation mismatch.

Minor, non-blocking

  1. findCall and raw strings (internal/cel/rewrite.go): The scanner treats \ as an escape in all string literals. CEL raw strings (r'a\') don't process escapes, so a raw string ending in a backslash could desync the quote tracking. If it does, the graphql( call after it would not be rewritten and would silently fall back to the lowercased body. The same escape logic already exists in the paren scanner, so this is an edge case. You could either handle the r/R prefix or add a test that documents the limitation.
  2. Lowercased variables on fallback (originalGraphQLBody): When the heuristic falls back to the first argument, which is the case-normalized body, variable values are lowercased too. A policy that compares an argument supplied via a variable (such as a node ID) is then case-sensitive in one path and not in the other. This only happens when the argument isn't a plain params.X path. A line in the graphql() docs would help, if there isn't one already.
  3. ValidateRuleBytes aliases: It passes nil aliases, so a profile alias used in a when expression is not resolved. This was already true before the PR. It's only worth a comment if aliases can appear in standalone rule files.

Otherwise the code is tidy. The tests cover cycles, limits and the rewrite edge cases, and the docs and CHANGELOG are updated.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dpup
dpup merged commit 41266c0 into main Nov 2, 2026
4 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@dpup
dpup deleted the claude/moat-github-access-policy-b43vj7 branch November 2, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@dpup @claude
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.