Add dependency resolution job for maven to DS CI template v2
What does this MR do and why?
Add a dependency Resolution job for maven to the Dependency Scanning CI template v2 that attempts to automatically generate a maven.graph.json file for a project using a pom.xml.
Maven projects have no lockfile mechanism. Accurate dependency scanning requires a maven.graph.json file, which today users must generate themselves via a custom CI job. This creates friction and makes it impossible to enforce scanning policies at scale.
The solution relies on coordinating a main dependency resolution job container with the DS analyzer running as a service container:
- The resolution job checks out the repository and signals readiness by creating a
.gitlab_ds/ready_${CI_JOB_ID}file - The service container detects projects needing resolution and writes a shell script to
.gitlab_ds/dependency_resolution.sh - The resolution job executes the script, which runs the appropriate resolution command per project (e.g.
mvn dependency:treefor Maven), producing graph files - Those files are exported as artifacts and picked up by the main dependency scanning job that runs in a later stage.
This MR partially depends on Update Scan Execution Policies EXCLUDED_VARIABL... (!227899 - merged) to ensure resolution jobs can be disabled when using Scan Execution Policies.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- checkout this branch in your GDK
- clone this project: https://gitlab.com/gitlab-org/security-products/tests/java-maven
- adjust CI configuration to just use v2 template:
include: - template: Jobs/Dependency-Scanning.v2.gitlab-ci.yml - Run a pipeline and confirms that:
- a
dependency-scanning:maven-resolutionjob ran in.prestage, emitting amaven.graph.jsonfile - the
dependency-scanningjob ran and successfully scanned this graph file.
- a
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.