Skip to main content

GitLab Repositories

Fetches information regarding GitLab repositories, including

  • Repository metadata and settings
  • Merge request and approval configuration
  • Pipeline history and recent runs

This plugin is intended to be run as part of an aggregate agent, and will execute the policy suite for each repository.

This page is for operators who run the plugin-gitlab-repositories plugin with the CCF Agent, and for developers who write policies for it. It documents v0.1.3 and is generated from the plugin's README at v0.1.3.

Requirements​

Authentication​

To authenticate this plugin, you must provide a token which has at minimum the following permissions:

  • read_api (recommended) or api - Required to read groups, projects, merge requests, pipelines, releases, and other repository metadata.
  • read_user alone is not sufficient for this plugin. It only covers user/profile endpoints and does not grant access to group or project APIs.

The token identity must also be able to view the configured group. For private groups, this means the backing user or service account must be a member of that group with enough visibility to read the resources the plugin queries.

Configuration​

plugins:
gitlab_repos:
token: "glpat-abc123"
# Numeric GitLab group ID or full group path. Use "parent/subgroup" for subgroups.
group: platform/security
# The following items are mutually exclusive, so cannot be set together. If neither are set, all repos are
# pulled and tested, otherwise the selection is chosen below
included_repositories: foo,bar,baz
excluded_repositories: quix,quiz

If group is configured as a short name instead of a numeric ID or full path, GitLab can return 404 Not Found for group-scoped endpoints. The plugin now validates the configured group up front and fails with a specific error in that case.

If group-member enumeration is inaccessible after group resolution succeeds, the plugin logs a warning and continues evaluating repositories without group_members data.

Policy input​

The plugin evaluates one kind of resource, a GitLab project (repository), and a policy receives one document per project in the configured group as input. Archived projects are skipped. Every field comes straight from the GitLab REST API, with the API's own names, so the GitLab API documentation describes each value in full. The document has thirteen top-level keys, and all of them are always present. When the plugin cannot read something (the token lacks permission, the feature needs GitLab Premium or Ultimate, or nothing exists), the key is null (an empty list is [] when it was read and nothing exists, and code_owners is an empty string), so test for it with a default or a null check. Fields are listed by their path inside the document. For settings, only the fields policies use most are listed. The object carries every other field the GitLab project API returns for the project, such as the *_access_level feature settings, ci_* settings and compliance_frameworks.

FieldTypeDescription
settingsobjectThe project as GitLab returns it from the group's project list. Always present. Fields below are the most used.
settings.idintegerGitLab project ID.
settings.namestringProject name.
settings.pathstringProject path, the last segment of the URL. This is the repository identity label.
settings.path_with_namespacestringFull path including the group and any subgroups.
settings.web_urlstringURL of the project in the GitLab UI.
settings.descriptionstringProject description. Empty when none is set.
settings.visibilitystringprivate, internal or public.
settings.default_branchstringName of the default branch. Empty for an empty repository.
settings.empty_repobooleanTrue when the repository has no commits.
settings.archivedbooleanWhether the project is archived. Always false, because archived projects are not collected.
settings.topicsarray of stringsProject topics.
settings.namespaceobjectThe group or user namespace that owns the project: id, name, path, kind, full_path, parent_id and web_url.
settings.created_atstring (RFC 3339 time)When the project was created. Left out when GitLab returns no date.
settings.last_activity_atstring (RFC 3339 time)Time of the last activity on the project. Left out when GitLab returns no date.
settings.merge_methodstringmerge, rebase_merge or ff.
settings.squash_optionstringnever, always, default_on or default_off.
settings.only_allow_merge_if_pipeline_succeedsbooleanMerge requests can only be merged when the pipeline succeeds.
settings.only_allow_merge_if_all_discussions_are_resolvedbooleanMerge requests can only be merged when all discussions are resolved.
settings.allow_merge_on_skipped_pipelinebooleanA merge request with a skipped pipeline can be merged.
settings.remove_source_branch_after_mergebooleanThe source branch is removed after a merge by default.
settings.request_access_enabledbooleanUsers can request access to the project.
settings.ci_config_pathstringPath of the CI/CD configuration file. Empty when the default is used.
settings.shared_runners_enabledbooleanInstance runners are enabled for the project.
settings.public_jobsbooleanJob logs and artifacts are visible to anyone who can see the project.
settings.auto_devops_enabledbooleanAuto DevOps is enabled.
settings.compliance_frameworksarray of stringsCompliance frameworks applied to the project, when GitLab returns any.
settings.shared_with_groupsarray of objectsGroups the project is shared with, each with group_id, group_name, group_full_path and group_access_level.
settings.forked_from_projectobjectThe parent project when this one is a fork. null otherwise.
settings.mirrorbooleanWhether the project is a pull mirror.
settings.issues_access_levelstringdisabled, private or enabled. The other feature settings (merge_requests_access_level, wiki_access_level, builds_access_level, container_registry_access_level and so on) take the same values.
protected_branchesarray of objectsProtected branches. null when the token cannot read them, [] when there are none.
protected_branches[].idintegerProtected branch ID.
protected_branches[].namestringBranch name or wildcard pattern.
protected_branches[].allow_force_pushbooleanWhether force pushes are allowed.
protected_branches[].code_owner_approval_requiredbooleanWhether pushes to the branch need code owner approval.
protected_branches[].push_access_levelsarray of objectsWho can push. Same shape as merge_access_levels.
protected_branches[].merge_access_levelsarray of objectsWho can merge. Each entry has id, access_level (0 none, 30 developer, 40 maintainer, 60 admin), access_level_description, deploy_key_id, user_id, group_id and member_role_id.
protected_branches[].unprotect_access_levelsarray of objectsWho can unprotect the branch. Same shape as merge_access_levels.
approval_configobjectProject-level merge request approval settings. null when the token cannot read them.
approval_config.approvals_before_mergeintegerApprovals required before merging (deprecated by GitLab in favor of approval rules).
approval_config.reset_approvals_on_pushbooleanApprovals are removed when new commits are pushed.
approval_config.disable_overriding_approvers_per_merge_requestbooleanMerge requests cannot override the approver list.
approval_config.merge_requests_author_approvalbooleanAuthors can approve their own merge requests.
approval_config.merge_requests_disable_committers_approvalbooleanUsers who added commits cannot approve the merge request.
approval_config.require_reauthentication_to_approvebooleanApprovers must authenticate again. Left out when GitLab does not return it.
approval_config.selective_code_owner_removalsbooleanOnly code owner approvals are removed on push. Left out when GitLab does not return it.
approval_config.approversarray of objectsIndividual approvers, each with a user and approved_at.
approval_config.approver_groupsarray of objectsApprover groups.
approval_rulesarray of objectsProject-level approval rules. null when the token cannot read them.
approval_rules[].idintegerRule ID.
approval_rules[].namestringRule name.
approval_rules[].rule_typestringregular, any_approver or code_owner.
approval_rules[].approvals_requiredintegerApprovals the rule needs.
approval_rules[].eligible_approversarray of objectsUsers who can approve under the rule. Each has id, username, name, state, avatar_url and web_url.
approval_rules[].usersarray of objectsUsers named in the rule, same shape as eligible_approvers.
approval_rules[].groupsarray of objectsGroups named in the rule.
approval_rules[].protected_branchesarray of objectsProtected branches the rule applies to.
approval_rules[].applies_to_all_protected_branchesbooleanWhether the rule applies to every protected branch.
approval_rules[].report_typestringReport type for security approval rules. Empty for other rules.
approval_rules[].contains_hidden_groupsbooleanWhether the rule has groups the token cannot see.
last_pipeline_runobjectThe most recent pipeline, whatever its age. null when the project has never had a pipeline.
last_pipeline_run.idintegerPipeline ID. The pipeline_runs[] entries have the same fields.
last_pipeline_run.iidintegerProject-scoped pipeline ID.
last_pipeline_run.project_idintegerProject ID.
last_pipeline_run.statusstringPipeline status, such as success, failed, canceled or running.
last_pipeline_run.sourcestringWhat started the pipeline, such as push, schedule or merge_request_event.
last_pipeline_run.refstringBranch or tag the pipeline ran for.
last_pipeline_run.shastringCommit SHA.
last_pipeline_run.namestringPipeline name. Empty when none is set.
last_pipeline_run.web_urlstringURL of the pipeline.
last_pipeline_run.created_atstring (RFC 3339 time)When the pipeline was created.
last_pipeline_run.updated_atstring (RFC 3339 time)When the pipeline last changed. Use it to measure how long ago CI last ran.
pipeline_runsarray of objectsPipelines updated within the configured look-back window (pipeline_lookback_days), newest first. [] when none ran in the window, and null when the token cannot read pipelines.
merge_requestsarray of objectsOpen merge requests. [] when there are none, null when the token cannot read them. Each entry has the fields of a GitLab merge request list item, listed below, plus approval_state.
merge_requests[].idintegerGlobal merge request ID.
merge_requests[].iidintegerProject-scoped merge request number.
merge_requests[].titlestringTitle.
merge_requests[].statestringAlways opened.
merge_requests[].draftbooleanWhether the merge request is a draft.
merge_requests[].source_branchstringSource branch.
merge_requests[].target_branchstringTarget branch.
merge_requests[].authorobjectAuthor, with id, username, name, state, avatar_url and web_url.
merge_requests[].reviewersarray of objectsAssigned reviewers, same user shape as author.
merge_requests[].assigneesarray of objectsAssignees, same user shape as author.
merge_requests[].created_atstring (RFC 3339 time)When it was opened.
merge_requests[].updated_atstring (RFC 3339 time)When it last changed.
merge_requests[].detailed_merge_statusstringGitLab's merge status, such as mergeable, not_approved or ci_must_pass.
merge_requests[].has_conflictsbooleanWhether the merge request has conflicts.
merge_requests[].labelsarray of stringsLabels.
merge_requests[].web_urlstringURL of the merge request.
merge_requests[].approval_stateobjectApproval state of this merge request. null when it could not be read.
merge_requests[].approval_state.approval_rules_overwrittenbooleanWhether the merge request overrides the project's approval rules.
merge_requests[].approval_state.rulesarray of objectsApproval rules in effect. Each has id, name, rule_type, report_type, section, approvals_required, approved, approved_by, eligible_approvers, users, groups, contains_hidden_groups and source_rule.
last_releaseobjectThe most recent release. null when the project has no releases.
last_release.tag_namestringRelease tag.
last_release.namestringRelease name.
last_release.descriptionstringRelease notes.
last_release.created_atstring (RFC 3339 time)When the release was created.
last_release.released_atstring (RFC 3339 time)When the release was published.
last_release.upcoming_releasebooleanTrue for a release with a future released_at.
last_release.authorobjectWho created the release, same user shape as a merge request author.
last_release.commitobjectThe commit the release tag points to.
last_release.assetsobjectRelease assets: count, sources, links and evidence_file_path.
last_release.evidencesarray of objectsRelease evidence records.
code_ownersstringDecoded content of the CODEOWNERS file, looked for at CODEOWNERS, .gitlab/CODEOWNERS and docs/CODEOWNERS on the default branch (main when the project has none). Empty string when there is no file or it cannot be read.
group_membersarray of objectsMembers of the configured group, including members inherited from parent groups. The same list is given for every project. null when the token cannot list members.
group_members[].idintegerUser ID.
group_members[].usernamestringUsername.
group_members[].namestringDisplay name.
group_members[].statestringAccount state, such as active or blocked.
group_members[].access_levelintegerAccess level in the group: 10 guest, 20 reporter, 30 developer, 40 maintainer, 50 owner.
group_members[].expires_atstring (date)When the membership expires. null when it does not.
group_members[].created_atstring (RFC 3339 time)When the membership was created.
group_members[].web_urlstringURL of the user's profile.
group_members[].emailstringEmail address. Left out when GitLab does not return it.
group_members[].public_emailstringPublic email address. Left out when empty.
group_members[].is_using_seatbooleanWhether the member uses a license seat. Left out when false.
environmentsarray of objectsDeployment environments. [] when there are none, null when the token cannot read them.
environments[].idintegerEnvironment ID.
environments[].namestringEnvironment name.
environments[].slugstringURL-safe name.
environments[].statestringavailable or stopped.
environments[].tierstringproduction, staging, testing, development or other.
environments[].external_urlstringURL of the deployed environment.
environments[].last_deploymentobjectThe last deployment, when there is one. null otherwise.
environments[].created_atstring (RFC 3339 time)When the environment was created.
environments[].updated_atstring (RFC 3339 time)When the environment last changed.
push_rulesobjectProject push rules. null on GitLab Free or when the token cannot read them.
push_rules.prevent_secretsbooleanFiles that are likely to hold secrets are rejected.
push_rules.reject_unsigned_commitsbooleanUnsigned commits are rejected.
push_rules.reject_non_dco_commitsbooleanCommits without a DCO sign-off are rejected.
push_rules.member_checkbooleanCommit authors must be GitLab users.
push_rules.commit_committer_checkbooleanUsers can only push commits they committed with a verified email.
push_rules.commit_committer_name_checkbooleanThe committer name must match the GitLab user name.
push_rules.deny_delete_tagbooleanTags cannot be deleted.
push_rules.commit_message_regexstringCommit messages must match this regular expression. Empty when unset.
push_rules.commit_message_negative_regexstringCommit messages must not match this regular expression. Empty when unset.
push_rules.branch_name_regexstringBranch names must match this regular expression. Empty when unset.
push_rules.author_email_regexstringAuthor emails must match this regular expression. Empty when unset.
push_rules.file_name_regexstringFiles matching this regular expression cannot be pushed. Empty when unset.
push_rules.max_file_sizeintegerLargest file size in MB. 0 for no limit.
push_rules.idintegerPush rule ID. project_id and created_at are also present.
has_ci_configbooleanTrue when last_pipeline_run is set or settings.ci_config_path is not empty, so it stays true when every pipeline is older than the look-back window.

An example input:

{
"settings": {
"id": 48213,
"name": "Billing Service",
"path": "billing-service",
"path_with_namespace": "acme-platform/billing-service",
"web_url": "https://gitlab.example.com/acme-platform/billing-service",
"description": "Invoicing and payment reconciliation API.",
"visibility": "private",
"default_branch": "main",
"empty_repo": false,
"archived": false,
"topics": [
"billing",
"api"
],
"namespace": {
"id": 9120,
"name": "Acme Platform",
"path": "acme-platform",
"kind": "group",
"full_path": "acme-platform",
"parent_id": 0,
"web_url": "https://gitlab.example.com/groups/acme-platform"
},
"created_at": "2024-06-03T09:15:27Z",
"last_activity_at": "2026-05-11T16:42:08Z",
"merge_method": "ff",
"squash_option": "default_on",
"only_allow_merge_if_pipeline_succeeds": true,
"only_allow_merge_if_all_discussions_are_resolved": true,
"allow_merge_on_skipped_pipeline": false,
"remove_source_branch_after_merge": true,
"request_access_enabled": false,
"ci_config_path": "",
"shared_runners_enabled": true,
"public_jobs": false,
"auto_devops_enabled": false,
"compliance_frameworks": [],
"shared_with_groups": [],
"forked_from_project": null,
"mirror": false,
"issues_access_level": "enabled",
"merge_requests_access_level": "enabled"
},
"protected_branches": [
{
"id": 7701,
"name": "main",
"allow_force_push": false,
"code_owner_approval_required": true,
"push_access_levels": [
{
"id": 11001,
"access_level": 0,
"access_level_description": "No one",
"deploy_key_id": 0,
"user_id": 0,
"group_id": 0,
"member_role_id": 0
}
],
"merge_access_levels": [
{
"id": 11002,
"access_level": 40,
"access_level_description": "Maintainers",
"deploy_key_id": 0,
"user_id": 0,
"group_id": 0,
"member_role_id": 0
}
],
"unprotect_access_levels": [
{
"id": 11003,
"access_level": 40,
"access_level_description": "Maintainers",
"deploy_key_id": 0,
"user_id": 0,
"group_id": 0,
"member_role_id": 0
}
]
}
],
"approval_config": {
"approvals_before_merge": 2,
"reset_approvals_on_push": true,
"disable_overriding_approvers_per_merge_request": true,
"merge_requests_author_approval": false,
"merge_requests_disable_committers_approval": true,
"approvers": [],
"approver_groups": []
},
"approval_rules": [
{
"id": 3301,
"name": "Platform reviewers",
"rule_type": "regular",
"report_type": "",
"approvals_required": 2,
"contains_hidden_groups": false,
"applies_to_all_protected_branches": true,
"eligible_approvers": [
{
"id": 5001,
"username": "avery.stone",
"name": "Avery Stone",
"state": "active",
"avatar_url": "",
"web_url": "https://gitlab.example.com/avery.stone"
}
],
"users": [
{
"id": 5001,
"username": "avery.stone",
"name": "Avery Stone",
"state": "active",
"avatar_url": "",
"web_url": "https://gitlab.example.com/avery.stone"
}
],
"groups": [],
"protected_branches": []
}
],
"last_pipeline_run": {
"id": 990412,
"iid": 1873,
"project_id": 48213,
"status": "success",
"source": "push",
"ref": "main",
"sha": "4f1c9a07b3d25e86a1c04d7f9b2e3a581c6d0e42",
"name": "",
"web_url": "https://gitlab.example.com/acme-platform/billing-service/-/pipelines/990412",
"created_at": "2026-05-11T16:30:12Z",
"updated_at": "2026-05-11T16:41:55Z"
},
"pipeline_runs": [
{
"id": 990412,
"iid": 1873,
"project_id": 48213,
"status": "success",
"source": "push",
"ref": "main",
"sha": "4f1c9a07b3d25e86a1c04d7f9b2e3a581c6d0e42",
"name": "",
"web_url": "https://gitlab.example.com/acme-platform/billing-service/-/pipelines/990412",
"created_at": "2026-05-11T16:30:12Z",
"updated_at": "2026-05-11T16:41:55Z"
}
],
"merge_requests": [
{
"id": 331870,
"iid": 212,
"title": "Add retry to the invoice export job",
"state": "opened",
"draft": false,
"source_branch": "feature/invoice-export-retry",
"target_branch": "main",
"author": {
"id": 5002,
"username": "jordan.wells",
"name": "Jordan Wells",
"state": "active",
"avatar_url": "",
"web_url": "https://gitlab.example.com/jordan.wells"
},
"reviewers": [],
"assignees": [],
"labels": [
"backend"
],
"created_at": "2026-05-09T10:04:33Z",
"updated_at": "2026-05-11T08:12:19Z",
"detailed_merge_status": "not_approved",
"has_conflicts": false,
"web_url": "https://gitlab.example.com/acme-platform/billing-service/-/merge_requests/212",
"approval_state": {
"approval_rules_overwritten": false,
"rules": [
{
"id": 3301,
"name": "Platform reviewers",
"rule_type": "regular",
"report_type": "",
"section": "",
"approvals_required": 2,
"approved": false,
"approved_by": [],
"eligible_approvers": [
{
"id": 5001,
"username": "avery.stone",
"name": "Avery Stone",
"state": "active",
"avatar_url": "",
"web_url": "https://gitlab.example.com/avery.stone"
}
],
"users": [],
"groups": [],
"contains_hidden_groups": false
}
]
}
}
],
"last_release": {
"tag_name": "v2.4.0",
"name": "Billing Service 2.4.0",
"description": "Adds multi-currency invoices.",
"created_at": "2026-04-28T13:00:00Z",
"released_at": "2026-04-28T13:00:00Z",
"upcoming_release": false,
"author": {
"id": 5001,
"username": "avery.stone",
"name": "Avery Stone",
"state": "active",
"avatar_url": "",
"web_url": "https://gitlab.example.com/avery.stone"
}
},
"code_owners": "* @acme-platform/platform-reviewers\n/infra/ @avery.stone\n",
"group_members": [
{
"id": 5001,
"username": "avery.stone",
"name": "Avery Stone",
"state": "active",
"access_level": 40,
"expires_at": null,
"created_at": "2023-11-20T09:00:00Z",
"web_url": "https://gitlab.example.com/avery.stone"
},
{
"id": 5002,
"username": "jordan.wells",
"name": "Jordan Wells",
"state": "active",
"access_level": 30,
"expires_at": null,
"created_at": "2024-02-12T14:30:00Z",
"web_url": "https://gitlab.example.com/jordan.wells"
}
],
"environments": [
{
"id": 640,
"name": "production",
"slug": "production",
"state": "available",
"tier": "production",
"external_url": "https://billing.example.com",
"last_deployment": null,
"created_at": "2024-06-10T08:00:00Z",
"updated_at": "2026-04-28T13:20:00Z"
}
],
"push_rules": {
"id": 88,
"project_id": 48213,
"prevent_secrets": true,
"reject_unsigned_commits": true,
"reject_non_dco_commits": false,
"member_check": true,
"commit_committer_check": false,
"commit_committer_name_check": false,
"deny_delete_tag": true,
"commit_message_regex": "",
"commit_message_negative_regex": "",
"branch_name_regex": "",
"author_email_regex": "@example\\.com$",
"file_name_regex": "",
"max_file_size": 50,
"created_at": "2024-06-10T08:05:00Z"
},
"has_ci_config": true
}

Subject templates​

The subject templates this plugin registers. Each example is built from sample data.

gitlab-repository​

A GitLab repository (project) in the configured group. Title: GitLab Repository: {{ .repository }}. The repository value is the project path, not the full path with the group. The evidence also carries provider (gitlab) and type (repository) labels that are not part of the identity.

Identity keyDescription
repositoryPath of the GitLab project, such as billing-service.
groupThe group setting of the plugin: the numeric ID or full path of the GitLab group that owns the repository.

Example:

{
"name": "gitlab-repository",
"type": "component",
"title": "GitLab Repository: billing-service",
"description": "GitLab repository billing-service in group acme-platform",
"purpose": "Represents a GitLab repository being monitored for compliance",
"identityLabels": {
"repository": "billing-service",
"group": "acme-platform"
}
}

Policies​

The policy bundles that work with this plugin, at their newest releases. The controls are the ones the bundle's policies list in their metadata.

BundleLatest versionControls coveredCompatible plugin lines
plugin-gitlab-repositories-policiesv0.1.1none listedlatest

When writing OPA/Rego policies for this plugin, they must be added under the compliance_framework Rego package:

# deny_critical_severity.rego
# package compliance_framework.[YOUR_RULE_PATH]
package compliance_framework.deny_critical_severity

Policy data​

Any policy_data set on this plugin's block in the agent configuration is passed to every policy evaluation and is available to Rego as data.<key>:

plugins:
gitlab_repos:
# ...plugin settings as above...
policy_data:
allowed_visibility:
- private