Commit 1e19964
committed
feat(gemini): GM-AG-001 validate auth block in agent MCP servers (#809)
Gemini CLI v0.39.0 added support for an `auth` block inside
`mcp_servers.<name>` entries in local agent markdown frontmatter -
google-gemini/gemini-cli#24770. Two variants:
- type: "google-credentials" - only `scopes` allowed beyond type
- type: "oauth" - client_id, client_secret, scopes, authorization_url,
token_url are all optional strings/arrays
Schema extracted from packages/core/src/agents/agentLoader.ts Zod
definitions in the upstream PR.
- New FileType::GeminiAgent variant; detection for *.md files with
`agents` parent and `.gemini` grandparent.
- New crates/agnix-core/src/rules/gemini_agent.rs with the
GeminiAgentValidator:
- Extracts YAML frontmatter between --- markers
- Parses via serde_yaml (workspace dep)
- Walks mcp_servers.*.auth and validates each block
- Enforces discriminator, rejects unknown fields per variant,
type-checks strings + arrays, validates URL shape for
authorization_url + token_url
- Best-effort line scanner for reporting position
- 24 unit tests covering: both variant happy paths, missing type,
invalid type, non-object auth, unknown field per variant, non-string
client_id, malformed URL, valid URL accepted, scopes shape, per-
server independent validation, disable path, URL classifier unit
tests, frontmatter extractor unit tests.
- Valid/invalid fixtures under tests/fixtures/{valid,invalid}/gemini-agents/.
- New gemini-agents rule category + GM-AG- prefix registered in
rule_parity + "Gemini Agents" label in docs generator.
- total_rules 413 -> 414, validator count 41 -> 42, FileType variants
45 -> 46.
Closes #809.1 parent 029f263 commit 1e19964
21 files changed
Lines changed: 920 additions & 20 deletions
File tree
- crates
- agnix-cli/tests
- agnix-core
- locales
- src
- file_types
- rules
- tests
- agnix-rules
- knowledge-base
- scripts
- tests/fixtures
- invalid/gemini-agents/.gemini/agents
- valid/gemini-agents/.gemini/agents
- website
- docs/rules
- generated
- src/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| |||
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
339 | 344 | | |
340 | 345 | | |
341 | 346 | | |
| |||
526 | 531 | | |
527 | 532 | | |
528 | 533 | | |
| 534 | + | |
529 | 535 | | |
530 | 536 | | |
531 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
809 | 820 | | |
810 | 821 | | |
811 | 822 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
321 | 332 | | |
322 | 333 | | |
323 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| 180 | + | |
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
| 401 | + | |
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
817 | 822 | | |
818 | 823 | | |
819 | 824 | | |
| |||
977 | 982 | | |
978 | 983 | | |
979 | 984 | | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
980 | 989 | | |
981 | 990 | | |
982 | 991 | | |
| |||
1475 | 1484 | | |
1476 | 1485 | | |
1477 | 1486 | | |
| 1487 | + | |
1478 | 1488 | | |
1479 | 1489 | | |
1480 | 1490 | | |
| |||
1963 | 1973 | | |
1964 | 1974 | | |
1965 | 1975 | | |
1966 | | - | |
| 1976 | + | |
1967 | 1977 | | |
1968 | 1978 | | |
1969 | 1979 | | |
| |||
0 commit comments