Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Problem
GitLab jobs carry CI_JOB_TOKEN and any configured id_tokens (OIDC). A job-token allowlist that's too broad, or an OIDC audience scoped wider than needed, lets a compromised or injected step reach other projects and cloud roles. There's no per-job permission block — scoping lives in token allowlists, id_tokens, and protected/unprotected context.
Proposed checks
- Flag
id_tokenswith missing or overly broad audience scoping. - Flag reliance on broad
CI_JOB_TOKENaccess where a narrower allowlist would do. - Flag protected-only secrets/variables consumed in jobs reachable from unprotected refs.
Caveat
Project-level CI_JOB_TOKEN allowlist is project settings, not pipeline YAML — that part needs project settings modeled as a resource, or is out of scope for the emitted .gitlab-ci.yml.
Mechanism
Static on emitted YAML for id_tokens and rules-reachable scoping.
GitHub counterpart: #287
Implementation
- Layer: post-synth checks (pure build). Add one file per check at
lexicons/gitlab/src/lint/post-synth/wgl0NN.ts, each exporting aPostSynthCheck—check(ctx): PostSynthDiagnostic[], synchronous, no I/O; inputctx.outputsis the emitted.gitlab-ci.yml. Auto-discovered viadiscoverPostSynthChecksinplugin.ts— no manual registration. - IDs: assign sequential IDs from
WGL029onward, one per acceptance-criteria item (existing IDs are 001–028). - Helpers: reuse/extend
lint/post-synth/yaml-helpers.ts(extractJobs,extractStages,hasInclude,extractGlobalVariables,extractJobSection,extractJobRules). - Extend existing checks where noted rather than duplicating:
WGL016(hardcoded secrets),WGL017(non-HTTPS registry),WGL026(DinD-TLS),WGL011/WGL023(rules reachability). - Vendored data (where a reference list is needed): create
lexicons/gitlab/src/lint/rules/data/(none today) following the github lexicon'sdata/pattern. - Closest pattern to copy: any existing
lint/post-synth/wgl0NN.ts+ its test; suite entry inpost-synth.test.ts.
Definition of done
- Each acceptance-criteria item is its own
WGL0NNcheck with a unique ID (no collision with 001–028). - Positive and negative fixture test per check.
-
npx vitest rungreen for the gitlab lexicon;just build/just lintclean. - Generated check docs include the new IDs.
- Each diagnostic names the exact job and the fix.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
feat(gitlab): scope CI_JOB_TOKEN and OIDC to least privilege (#298) (#…