Repository navigation
Add xAI analyzer - #5456
Merged
dustin-decker merged 2 commits intoOct 24, 2026
Merged
Add xAI analyzer#5456
Conversation
Reads key metadata from GET /v1/api-key and turns the key's api-key:endpoint:<name> and api-key:model:<name> ACLs into endpoint and model bindings under the owning team. Models come from GET /v1/models, filtered by the model ACLs (matching ids or aliases); when the key may not list models, the models named in the ACLs are reported instead. Blocked or disabled keys, and keys of blocked teams, are reported as not valid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The xAI API key endpoint does not return an expiry, so the analyzer cannot claim the key never expires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dustin-decker
approved these changes
Oct 24, 2026
Contributor
|
Thanks mate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description:
Closes #5455.
Adds an analyzer for xAI API keys. Today a live xAI key shows "We do not have an analyzer for this secret type yet!" This analyzer reports what the key belongs to and which xAI endpoints and models it can call.
How it works (read-only
GETrequests only):GET https://api.x.ai/v1/api-keyreturns the key's name, ID, redacted key, team, user, creation and modification times,api_key_blocked,api_key_disabled,team_blocked, and its ACLs. These all go into the result metadata.api-key:endpoint:<name>becomeendpoint_accessbindings, and ACLs of the formapi-key:model:<name>becomemodel_accessbindings. Both sit under ateamparent resource, and*is kept as a wildcard resource. Any other ACL form is listed as unrecognized in the CLI output, not mapped to a permission.GET https://api.x.ai/v1/modelssupplies the model list, filtered by the model ACLs. Models match by ID or alias, and*allows every listed model. If the key may not list models (403/404), the models named in its ACLs are reported instead.Valid_Key: falsewith no bindings. This follows the detector change proposed in fix: xAI detector - verified api key condition #5374.Files:
pkg/analyzer/analyzers/xai/: analyzer, requests,permissions.yaml(endpoint_access,model_access) and the generatedpermissions.gopkg/analyzer/analyzers/analyzers.go: newAnalyzerTypeXAI("XAI")pkg/analyzer/cli.go:xaicase. The TUI default single-keyform already fits, so the TUI needs no change.Tests:
TestAnalyzePermissionsuses a stub transport, with no network or credentials. It covers wildcard ACLs, alias matching, ACL-only models, a 403 from/v1/models, blocked keys, disabled keys, 401, and unexpected status codes.TestAnalyzer_Analyzefollows the other analyzers: it readsXAI/XAI_INACTIVEfrom thedetectors5test secret, the same fieldspkg/detectors/xaiuses. I don't have access to those secrets, so this test checks the result's shape rather than comparing against a recordedresult_output.json. I can switch it to a recorded output if a maintainer can capture one.I haven't run this against a live xAI key, and xAI's docs give only the
api-key:endpoint:*andapi-key:model:*ACL examples. If real keys carry other ACL shapes, they will show up as unrecognized rather than being dropped.Checklist:
make test-community)? Every package passed exceptpkg/gitparse, whoseTestLowMemoryScanMatchesSingleProcess/abbreviatedtimed out locally. That package doesn't depend onpkg/analyzer. The newpkg/analyzer/analyzers/xaiunit tests pass too;test-communityexcludes that directory.make lintthis requires golangci-lint)? golangci-lint v2.14.0 with thescripts/lint.shargs reports 0 issues on./pkg/analyzer/....🤖 Generated with Claude Code
Note
Low Risk
Isolated new analyzer code with read-only external API calls; no changes to existing auth or scanning paths beyond registering the new type and CLI case.
Overview
Adds xAI as a new secret analyzer so discovered xAI API keys can be analyzed for team context, validity, and fine-grained access instead of showing “no analyzer” for that secret type.
The analyzer issues read-only
GETcalls to xAI’s/v1/api-keyand/v1/modelsendpoints, mapsapi-key:endpoint:*andapi-key:model:*ACLs intoendpoint_access/model_accessbindings under a team parent, and treats blocked, disabled, or team-blocked keys asValid_Key: falsewith no bindings. When model listing is forbidden, it falls back to models named in the ACLs; unrecognized ACL shapes are surfaced in CLI output only.Wiring includes
AnalyzerTypeXAIin the shared enum, ananalyzeCLIxaibranch, generated permissions frompermissions.yaml, and unit tests (stubbed HTTP plus optional live keys from test secrets).Reviewed by Cursor Bugbot for commit e35bb67. Bugbot is set up for automated code reviews on this repo. Configure here.