Box Detector: Extract Subject ID for Analyzer Integration#4761
Box Detector: Extract Subject ID for Analyzer Integration#4761shahzadhaider1 wants to merge 2 commits intotrufflesecurity:mainfrom
Conversation
9d675d1 to
aa90b79
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| // box supports only one client id and secret pair | ||
| break | ||
| } | ||
| } else { |
There was a problem hiding this comment.
subject_id may attach to wrong credentials
Medium Severity
uniqueSubjectIdMatches is collected once for the entire input and then reused for every client_id/client_secret combination, so any subject_id found anywhere in the chunk can be emitted alongside unrelated credential pairs. This can mis-populate AnalysisInfo and produce incorrect detector→analyzer inputs when multiple Box-related values appear in the same chunk.
mustansir14
left a comment
There was a problem hiding this comment.
A suggestion:
Instead of having an if else flow based on subject IDs found and duplicating results creation logic for both the flows, you can do something similar to how organization IDs are passed to AnalysisInfo in the atlassian detector
The idea is basically to add a dummy (empty) entry for the subject ID to the uniqueMatch map if there are no subject IDs found, and treat it normally as any other credential part by looping over that. This will simplify the detector logic a lot IMO.


Problem
The Box analyzer requires three credentials to run:
client_id,client_secret, andsubject_id(a numeric Box enterprise or user ID). The detector was only verifyingclient_id+client_secretand not populatingAnalysisInfoat all, meaning the analyzer would always fail immediately withsubject_id not found, making the detector:analyzer pipeline non-functional.Changes
boxoauth.gosubjectIdPatregex to extract numeric Box enterprise/user IDs from surrounding context near relevant keywords (enterprise,enterprise_id,user_id,subject,box_subject)detectors.Resultis emitted per found subject ID, each carrying the verifiedclient_id,client_secret, and its respectivesubject_idinAnalysisInfoclient_idandclient_secretverifyMatchis completely unchanged; the existing400/unauthorized_clientverification trick is preserved as-isboxoauth_test.goBehavior Summary
client_id+client_secret+subject_idclient_id+client_secretonlyChecklist:
make test-community)?make lintthis requires golangci-lint)?Note
Medium Risk
Changes detection output cardinality and enriches verified results with analyzer-facing metadata, which could affect downstream processing and result volumes.
Overview
Extends the Box OAuth detector to also extract numeric
subject_idvalues (enterprise/user IDs) and, when a credential pair verifies, populateResult.AnalysisInfowithclient_id,client_secret, andsubject_idfor analyzer consumption.FromDatanow emits one result per discovered subject ID (or a single result when none are present) while keeping the existing client_id/client_secret verification behavior; tests were updated to cover 0/1/multiple subject-ID cases and modernized totestifyassertions.Written by Cursor Bugbot for commit 399a358. This will update automatically on new commits. Configure here.