Safeguard
Security Guides•

Which dependency files to commit for Go, Rust, .NET, PHP, Ruby, Swift?

A one-table answer: the manifest and lockfile each ecosystem needs for a useful scan, from go.mod to Package.resolved, plus where Gradle and Kotlin fit.

Safeguard Security Team
3 min read

Commit both the manifest and the file that records exact versions. That is go.mod for Go, Cargo.lock for Rust, the project file for .NET, composer.lock for PHP, Gemfile.lock for Ruby, and Package.resolved for Swift apps. A scanner needs those exact versions to match advisories accurately.

The table

EcosystemFile that matters mostAlso readNote
Gogo.modgo.sumgo.sum is hashes, not a lockfile
RustCargo.lockCargo.tomlCommit the lock for applications
.NETProject file such as csprojpackages.config, nuspecSee our NuGet lock file post
PHPcomposer.lockcomposer.jsonLibraries need not commit the lock
RubyGemfile.lockGemfile, gemspecCommit for apps and gems per Bundler docs
SwiftPackage.resolvedPackage.swiftIgnored when your package is a dependency
Java and Kotlinpom.xml, or Gradle build filesGradle lockfile if enabledCheck how your tool resolves Gradle

The first columns follow the file names in GitHub's dependency graph reference, which lists go.mod for Go, Cargo.lock for Rust, composer.lock for Composer, Gemfile.lock for RubyGems, Package.resolved for Swift and pom.xml for Maven. That reference lists no recommended file for Gradle, and the page does not list Kotlin separately.

Why the lockfile matters

A manifest holds ranges. A lockfile holds the resolved result. Advisories are written against specific versions, so a scan that sees only ranges can only guess which version you run.

For the reasons behind each choice, see what a lockfile is and why to commit it.

Application or library

  • Applications should commit the lock file so every build and every scan uses the same versions.
  • Libraries have more discretion. Composer says it is not necessary, and SwiftPM says a library's Package.resolved does not pin anything for its users.

A short checklist

  1. List the build tools in your repository. Monorepos often have several.
  2. Confirm each one has its exact-version file committed.
  3. For Go, rely on go.mod and the module graph, since there is no lock file.
  4. For Gradle, decide whether to enable dependency locking or to scan the resolved graph from a build.
  5. Make sure CI fails if the lock file would change.
  6. Scan on every pull request and on a schedule.

Quick check

Do I need go.sum for scanning?

Scanners read go.mod and the module graph for versions. Keep go.sum committed for integrity checks.

My Swift project is a library. Should I still commit Package.resolved?

It is optional. It will not pin versions for your users, but it can keep your own CI consistent.

Safeguard's SBOM and dependency scanning builds an inventory from project files like these. Check a repository with the free scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.