Understanding Sparse Checkout for SCM Scanning

Understanding Sparse Checkout for SCM Scanning

When Sonatype Lifecycle performs Source Control Management (SCM) scans, it uses sparse checkout to efficiently analyze repositories without checking out all repository files into the working directory.

What is Sparse Checkout?

Sparse checkout is a Git feature that allows Lifecycle to check out only the specific files needed for component analysis, rather than every file in your repository. This approach:

Significant Scan Files

Lifecycle identifies open source components by examining a limited set of significant scan files, rather than all files in a repository.

  1. Manifest and Lock Files : These files are used during component analysis.

Examples include:

  1. Binary and Archive Files : These files can also be relevant for identifying open source components.

Examples include:

Note

Lifecycle may include files beyond manifests, such as archives and .js files, because they can be used for hash-based identification of open source components.

Why JavaScript Files Are Included

JavaScript files (*.js) are included for the same reason archive files such as *.jar are included: they can be used for hash-based identification of distributed code artifacts.

In the npm ecosystem, artifacts are distributed as .tgz packages that contain .js files. These files are extracted into the node_modules directory of a project. Lifecycle can use hash-based identification against .js files or .tgz packages.

How Sparse Checkout Works

Execution Flow

Note

When partial clone is not available, Git may fetch and store compressed contents for all files in the latest commit, while sparse checkout materializes only the files needed for component analysis.

Requirements

Sparse checkout requires:

Note

JGit (Java implementation of Git) does not support sparse checkout and will perform a full clone if used instead of the native Git client.

Best Practices

  1. For Self-Hosted Installations

Sonatype strongly recommends configuring IQ Server with a native Git client to take advantage of sparse checkout. See Source Control Integration Best Practices for configuration details.

  1. For Lifecycle Cloud (SaaS)

Lifecycle Cloud uses partial clone when available and sparse checkout for SCM scanning. Instead of materializing all repository files in the working directory, it materializes only the files required for component analysis.

Troubleshooting

Empty Scan Results

If sparse checkout finds no files to check out, you may see this error:

Sparse checkout leaves no entry on working directory

Resolution

Unexpected Components Missing

If expected components are not being detected: