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:

  1. The resolution job checks out the repository and signals readiness by creating a .gitlab_ds/ready_${CI_JOB_ID} file
  2. The service container detects projects needing resolution and writes a shell script to .gitlab_ds/dependency_resolution.sh
  3. The resolution job executes the script, which runs the appropriate resolution command per project (e.g. mvn dependency:tree for Maven), producing graph files
  4. 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

  1. checkout this branch in your GDK
  2. clone this project: https://gitlab.com/gitlab-org/security-products/tests/java-maven
  3. adjust CI configuration to just use v2 template:
     include:
       - template: Jobs/Dependency-Scanning.v2.gitlab-ci.yml
  4. Run a pipeline and confirms that:
    1. a dependency-scanning:maven-resolution job ran in .pre stage, emitting a maven.graph.json file
    2. the dependency-scanning job ran and successfully scanned this graph file.

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.

Edited by Olivier Gonzalez

Merge request reports

Loading
Loading