Add 1Password service account token detector#4891
Add 1Password service account token detector#4891tanishq-sf wants to merge 2 commits intotrufflesecurity:mainfrom
Conversation
Adds a new detector for 1Password service account tokens (ops_eyJ... prefix). These tokens are used to authenticate automated workflows and CI/CD pipelines with 1Password vaults. Detection is pattern-match only since these tokens use SRP-based authentication and cannot be verified with a simple HTTP request. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 1ef9b41. Configure here.
| [DEBUG] Using Key=ops_abcdefghijklmnopqrstuvwxyzABCDEF | ||
| [INFO] Response received: 200 OK | ||
| `, | ||
| want: []string{ "ops_abcdefghijklmnopqrstuvwxyzABCDEF" }, |
There was a problem hiding this comment.
Test token doesn't match detector's keyword or regex
High Severity
The "valid pattern" test uses the token ops_abcdefghijklmnopqrstuvwxyzABCDEF, but the detector's keyword is ops_eyJ and the regex requires an ops_eyJ prefix followed by 50+ characters. This token has neither the correct prefix nor sufficient length. The AhoCorasick keyword pre-filter won't find ops_eyJ in the test input, so the test fails immediately at the keyword check — meaning the regex matching is never actually exercised. The "invalid pattern" test also lacks ops_eyJ in its input, so it too fails at the keyword check rather than validating that the regex correctly rejects invalid tokens.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 1ef9b41. Configure here.
| t.Run(test.name, func(t *testing.T) { | ||
| matchedDetectors := ahoCorasickCore.FindDetectorMatches([]byte(test.input)) | ||
| if len(matchedDetectors) == 0 { | ||
| t.Errorf("test %%q failed: expected keywords %%v to be found in the input", test.name, d.Keywords()) |
There was a problem hiding this comment.
Double-percent format verbs produce literal percent signs
Medium Severity
All t.Errorf calls use %%q, %%v, %%d, %%s instead of %q, %v, %d, %s. In Go, %% is an escape that produces a literal % character, so the format arguments (test.name, d.Keywords(), etc.) won't be interpolated into the error messages. Every other detector test in the codebase uses single % for format verbs.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 1ef9b41. Configure here.


Summary
ops_eyJ...prefix)Changes
pkg/detectors/onepasswordserviceaccount/— detector + testsproto/detector_type.proto—OnepasswordServiceAccount = 1045pkg/pb/detector_typepb/detector_type.pb.go— generated enum constantpkg/engine/defaults/defaults.go— import + scanner registrationRegex
Test plan
make protosand test suitego test ./pkg/detectors/onepasswordserviceaccount/ -vNote
Low Risk
Primarily additive changes (new detector + enum value + registration) with no verification/network behavior; main risk is minor integration/regeneration issues around the updated detector type proto/enum.
Overview
Adds a new
onepasswordserviceaccountdetector to identify 1Password service account tokens by regex (ops_eyJ...) and return matches without attempting verification.Registers the detector in the default detector list and extends the detector type enum/proto with
OnepasswordServiceAccount = 1045, including a basic pattern-matching unit test.Reviewed by Cursor Bugbot for commit 1ef9b41. Bugbot is set up for automated code reviews on this repo. Configure here.