Skip to content

Enable NuGet lock files (RestorePackagesWithLockFile) in the .NET overlay #45

Closed

Description

@kyle-sexton

Problem

OSV-Scanner gives zero transitive NuGet coverage for SDK-style projects that use only <PackageReference> with no committed lock file. OSV-Scanner parses only packages.lock.json, *.deps.json, and packages.config — it never reads .csproj <PackageReference> and has no restore/resolution engine. So a PackageReference-only repo scans nothing for the NuGet ecosystem, and --allow-no-lockfiles (used by consumers, e.g. github-iac) just turns the erroring scan into a green-but-empty one — strictly worse, because it hides the gap.

Surfaced by a code review of github-iac (the one known transitive vuln there, OpenTelemetry 1.9.0, is only caught because it's manually pinned — OSV-Scanner itself sees nothing).

Proposal (build posture → belongs in the standards .NET overlay)

Add to the .NET overlay (the modules/dotnet Directory.Build.props that consumers import):

<PropertyGroup>
  <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Consumers then commit the generated packages.lock.json (the only OSV-supported .NET input that is committable and carries the full transitive closure). This also makes restore reproducible.

Caveats to design for

  • CI locked-mode (RestoreLockedMode=true / dotnet restore --locked-mode) for repeatable builds — fails (NU1004) if the resolved graph drifts from the lock file. Belongs in the ci-workflows restore step (see linked issue).
  • SDK sensitivity — implicit framework deps vary across SDK versions; pin via global.json + rollForward: disable to avoid locked-restore breakage.
  • Dependabot — supports updating packages.lock.json for direct PackageReference bumps but has open gaps (CPM / transitive-via-ProjectReference); consumers may need a dotnet restore --force-evaluate step on Dependabot PRs. Coordinated in the linked ci-workflows issue.

Sources

Companion: ci-workflows issue (locked-mode restore + OSV coverage + Dependabot lock regen).

Activity

  1. added 2 commits that reference this issue on Jul 4, 2026
    800d3b1
    804b74f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions