--enable-commit-status posts a commit status (success/failed) to GitLab after scan completes. Repo admins can then require socket-security as a status check on protected branches.
- GitLab project with CI/CD configured
GITLAB_TOKENwithapiscope (orCI_JOB_TOKENwith sufficient permissions)- Merge request pipeline (so
CI_MERGE_REQUEST_PROJECT_IDis set)
- Create MR with no dependency changes (or only safe ones)
- Run:
socketcli --scm gitlab --enable-commit-status - Expected: Commit status
socket-security=success, description = "No blocking issues" - Verify in GitLab: Repository > Commits > (sha) > Pipelines or MR > Pipeline > External tab
- Create MR adding a package with known blocking alerts
- Run:
socketcli --scm gitlab --enable-commit-status - Expected: Commit status =
failed, description = "N blocking alert(s) found"
- Run:
socketcli --scm gitlab(no--enable-commit-status) - Expected: No commit status posted
- Trigger pipeline on a push (no MR context)
- Run:
socketcli --scm gitlab --enable-commit-status - Expected: Commit status skipped (no
mr_project_id), no error
- Use an invalid/revoked
GITLAB_TOKEN - Run:
socketcli --scm gitlab --enable-commit-status - Expected: Error logged ("Failed to set commit status: ..."), scan still completes with correct exit code
- Run:
socketcli --scm github --enable-commit-status - Expected: Flag is accepted but commit status is not posted (GitHub not yet supported)
Since socketcli exits with code 1 when blocking alerts are found, the pipeline fails automatically.
- Go to Settings > General > Merge requests
- Under Merge checks, enable "Pipelines must succeed"
- Save — GitLab will now prevent merging when the pipeline fails
Use the socket-security commit status as a required external check.
- Go to Settings > General > Merge requests > Status checks
- Add an external status check with name
socket-security - MRs will require Socket's
successstatus to merge