Enable gitlab_pipeline_trigger_token for validity checks
What does this MR do and why?
This MR expands the validity checks so that the status of detected gitlab_pipeline_trigger_tokens are now checked.
Database queries
This MR adds the scope with_token to Trigger to facilitate this.
The query this scope produces is
https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/41052/commands/126167
Expand SQL query
SELECT
"ci_triggers".*
FROM
"ci_triggers"
WHERE
"ci_triggers"."token" IN ('glptt-0a9848abdbd4f565fcd9f0c8a74dcaf78b71f28b', 'glptt-0a9848abdbd4f565fcd9f0c8a74dcaf78b71f28c')
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
Step 1: Create a Test Project
Create a new test project in your GDK.
Step 2: Enable Feature Flag and Validity Checks
Open the Rails console:
gdk rails console
Enable the feature flag:
Feature.enable(:validity_checks)
Find your test project and enable validity checks:
# Find your project (replace with actual project ID)
project = Project.find(your_project_id)
# Enable validity checks
project.security_setting.update(validity_checks_enabled: true)
Step 3: Create Pipeline Trigger token
-
Navigate to your project
-
Go to Settings → CI/CD (in the left sidebar)
-
Scroll down and expand the "Pipeline triggers" section
-
Click the "Add trigger" button
-
Enter a description (optional but recommended for identification)
-
Click "Add trigger"
-
Important: Copy and save the token value as you'll need it in the next step.
Step 4: Configure Secret Detection
In your test project, create or update .gitlab-ci.yml:
include:
- template: Jobs/Secret-Detection.gitlab-ci.yml
Step 5: Add Tokens to Repository
Create a README.md file in your project and add the token values you saved earlier:
# Test Project
This project contains test tokens for validity checks:
- Pipeline trigger token: glptt-[your-token-value]
Commit and push the changes to trigger the pipeline.
Step 6: Verify Results
- Wait for the pipeline to complete
- Navigate to Security & Compliance → Vulnerability Report in your project
- Verify that the token appears in the vulnerability report
- Expected Result: The status of each token will show as "active".
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.