Add Z.ai detector#5033
Open
moizxsec wants to merge 1 commit into
Open
Conversation
Add a secret detector for Z.ai (Zhipu AI) API keys, used to authenticate against the GLM model APIs. Keys consist of a 32-character hex id and a 16-character secret joined by a period. Verification performs a non-destructive GET against the Z.ai models endpoint and treats 200 as verified and 401 as unverified. The detector is registered behind the ZaiDetectorEnabled feature flag, matching the pattern used for other recently added detectors. Closes trufflesecurity#4658
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
Adds a secret detector for Z.ai (Zhipu AI) API keys, used to authenticate against the GLM model APIs.
0123…cdef.AbCd…5678), pre-filtered by thezai/zhipu/bigmodel/glmkeywords to keep signal high.GET https://api.z.ai/api/paas/v4/modelswith the key as a Bearer token.200→ verified,401→ unverified, anything else is treated as an indeterminate verification error.defaults.gobehind a newZaiDetectorEnabledfeature flag, matching the pattern used for other recently added detectors (Wit, Tly, Datadog, etc.), and enabled by default inmain.go.Checklist
ZAIdetector type toproto/detector_type.protoand regenerated protos (make protos).go test ./pkg/detectors/zai/ -tags=detectors).DefaultDetectorsand added toexcludedFromDefaultListin the defaults test while feature-flag gated.gofmt/go vetclean.Closes #4658
Note
Low Risk
Additive detector and proto enum only; follows existing gated-detector patterns with no changes to core scan or auth flows.
Overview
Adds a Z.ai (Zhipu AI) secret detector for API keys shaped as
32-hex.16-alphanumeric, gated on nearby keywords (zai,zhipu,bigmodel,glm).When verification is on, keys are checked with a read-only
GETtohttps://api.z.ai/api/paas/v4/modelsusing Bearer auth (200verified,401not). The newDetectorType_ZAIproto value is wired into default detectors behindZaiDetectorEnabled, turned on by default inmain.go, with pattern tests inpkg/detectors/zai.Reviewed by Cursor Bugbot for commit 2898425. Bugbot is set up for automated code reviews on this repo. Configure here.