Skip to content

Add Figma Personal Access Token v3 Detector#4790

Open
shahzadhaider1 wants to merge 7 commits intotrufflesecurity:mainfrom
shahzadhaider1:INS-381-figma-v3
Open

Add Figma Personal Access Token v3 Detector#4790
shahzadhaider1 wants to merge 7 commits intotrufflesecurity:mainfrom
shahzadhaider1:INS-381-figma-v3

Conversation

@shahzadhaider1
Copy link
Copy Markdown
Contributor

@shahzadhaider1 shahzadhaider1 commented Mar 5, 2026

Summary

Adds a v3 detector for Figma Personal Access Tokens to support the new figp_ prefixed token format. Also refactors the shared verification logic across all three detector versions to eliminate code duplication.

Changes

New v3 detector (figp_ prefix)

  • Regex pattern: figp_[a-zA-Z0-9_=-]{40,54} as specified by Figma
  • Keyword pre-filter uses figp_ for efficient chunk matching
  • No word boundary (\b) assertions used since the token character set includes non-word characters (=, -) which are incompatible with \b

Verification logic refactored into shared VerifyMatch function

  • Extracted the common verification logic into an exported VerifyMatch function in the v1 package
  • v2 and v3 now import and call v1.VerifyMatch instead of duplicating the HTTP verification inline

Verification details

  • Endpoint: GET https://api.figma.com/v1/me with X-Figma-Token header
  • 200 -> verified
  • 403 -> unverified (Figma returns 403 for invalid, expired, or revoked tokens, as well as valid tokens that lack the required scopes for the requested resource)
  • Any other status -> unverified with verification error (indeterminate)

Testing

  • Unit tests added for v3 covering valid pattern matching and invalid pattern rejection
  • Integration tests added for v3 but currently skipped as the new figp_ token format is not yet available for generation in Figma. Tests will be unskipped once v3 secrets are provisioned in GCP.
  • Existing v1 and v2 tests remain unchanged and continue to pass

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?
image image

Note

Medium Risk
Adds a new detector variant and changes verification behavior for existing Figma token detectors by centralizing the HTTP verification code path; mistakes here could impact verification results and outbound API calls.

Overview
Adds a new Figma Personal Access Token v3 detector to recognize the new figp_ token format (including keyword prefiltering) and registers it in pkg/engine/defaults/defaults.go.

Refactors v1/v2 verification to call a shared figmapersonalaccesstoken.VerifyMatch helper (including draining/closing response bodies), and updates integration tests to expect AnalysisInfo on verified results and to ignore the new primarySecret field in result comparisons.

Reviewed by Cursor Bugbot for commit 25d9bac. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread pkg/detectors/figmapersonalaccesstoken/v3/figmapersonalaccesstoken.go Outdated
@shahzadhaider1 shahzadhaider1 changed the title added v3 for figma pat Add Figma Personal Access Token v3 Detector Mar 6, 2026
@shahzadhaider1 shahzadhaider1 marked this pull request as ready for review March 6, 2026 17:40
@shahzadhaider1 shahzadhaider1 requested a review from a team March 6, 2026 17:40
@shahzadhaider1 shahzadhaider1 requested a review from a team as a code owner March 6, 2026 17:40
amanfcp

This comment was marked as duplicate.

Comment thread pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2.go Outdated
Copy link
Copy Markdown
Contributor

@amanfcp amanfcp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit ff9b319. Configure here.


switch res.StatusCode {
case http.StatusOK:
return true, nil
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored verification narrows accepted success status codes

Low Severity

The shared VerifyMatch function only treats http.StatusOK (200) as verified, but the original v1 and v2 inline logic treated the entire 2xx range (StatusCode >= 200 && StatusCode < 300) as verified. Any non-200 success response (e.g., 201, 204) now falls into the default case and is reported as an unexpected error instead of being marked as verified. This is a behavioral regression introduced during the refactoring.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ff9b319. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants