Loading
Add a validity check for HashiCorp Terraform API tokens
🤖 AI wrote this code from my instructions.Unreviewed AI output often lands on reviewers and costs them time.
This MR is human verified: I read the full diff and ran the tests myself, because your time is as valuable as mine.
This merge request adds a validity check for HashiCorp Terraform user and organization API tokens.
Resolves #631848 (closed). Stacked on !260314 (merged), which lets the vendor definition use the real rule ID.
Gap
- GitLab detects
Hashicorp Terraform user/org API tokenrule, but validity checks did not verify it.
Fix
- We generated
HashicorpTerraformClientand its spec from a vendor definition using the generator. - The check calls
GET /api/v2/account/detailson HCP Terraform, and is only enabled for GSS findings. - Every mapping decision was measured against real tokens:
- Live user and organization tokens return
200. - Revoked user and organization tokens return
401.
- Live user and organization tokens return
- The rule has no capture group, so the finding keeps the surrounding quotes.
BaseClientnow strips one pair of quotes before the request.
Notes
- HashiCorp reserves
401for token problems.- A valid token without access gets
404, which stays unmapped and reads asunknown.
- A valid token without access gets
- Self-hosted Terraform Enterprise tokens share the same format.
- We can only verify against HCP Terraform, so a live Terraform Enterprise token reads as inactive.
MR acceptance checklist
I have evaluated this MR against the MR acceptance checklist.
Edited by Ahmed Hemdan