Skip to content

Apply insecure HTTP source checks to audit sources during restore - #7514

Merged
zivkan merged 9 commits into
devfrom
zivkan-dev-zivkan-audit-sources-http
Jul 3, 2026
Merged

zivkan merged 9 commits into
devfrom
zivkan-dev-zivkan-audit-sources-http

Conversation

@zivkan

@zivkan zivkan commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#14962

Description

Restore only validated regular package sources for insecure HTTP usage, so an HTTP audit source configured without allowInsecureConnections was contacted silently, unlike package sources which produce NU1302/NU1803. This makes audit sources respect allowInsecureConnections too, matching what dotnet list package --vulnerable already does.

Key behavior, with two intentional differences from package sources:

  • Only when auditing is enabled. Audit sources are only contacted while auditing, so the insecure-HTTP check is skipped entirely when NuGetAudit is disabled.
  • Error-or-silent gating, not warn-then-error. Package sources warn (NU1803) below their SdkAnalysisLevel gate and error (NU1302) at/above it. Audit sources instead error at SdkAnalysisLevel 10.0.400 or higher and emit no diagnostic below that. The package-source gate stays at 9.0.100.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc. N/A

zivkan and others added 5 commits June 26, 2026 13:54
Restore only validated regular package sources for insecure HTTP usage, so an HTTP audit source configured without allowInsecureConnections was used silently. This makes audit sources follow the same NU1302/NU1803 behavior as package sources, respecting allowInsecureConnections, matching what 'dotnet list package' already does.

Co-authored-by: Copilot <[email protected]>
… 10.0.400

Skip the insecure HTTP check for audit sources when NuGetAudit is disabled,
since audit sources are only contacted while auditing. Package sources continue
to use the 9.0.100 SdkAnalysisLevel gate while audit sources use 10.0.400.

Co-authored-by: Copilot <[email protected]>
…rwise

Unlike package sources (which warn below the gate and error at/above it), audit
sources only error when the SDK analysis level is 10.0.400 or higher, and emit
no diagnostic otherwise.

Co-authored-by: Copilot <[email protected]>
All call sites use the existing overload that takes allowInsecureConnections.

Co-authored-by: Copilot <[email protected]>
Restore_WithHttpAuditSourceAndAllowInsecureConnectionsFalse_ThrowsError asserted
the same NU1302 outcome as Restore_WithHttpAuditSourceSdkAnalysisLevel100400_ThrowsError,
which more precisely covers the 10.0.400 gate boundary.

Co-authored-by: Copilot <[email protected]>
@zivkan
zivkan marked this pull request as ready for review June 26, 2026 06:24
@zivkan
zivkan requested a review from a team as a code owner June 26, 2026 06:24
@zivkan
zivkan requested review from kartheekp-ms and martinrrm June 26, 2026 06:24

@donnie-msft donnie-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see this change!

This means that the VS Settings should now have "Allow Insecure Connections" and require that to be checked for HTTP audit sources. Do you agree and if so, plan on filing an issue for that?

kartheekp-ms
kartheekp-ms previously approved these changes Jun 26, 2026
nkolev92
nkolev92 previously approved these changes Jun 26, 2026
@zivkan
zivkan dismissed stale reviews from nkolev92 and kartheekp-ms via 4481e0b June 27, 2026 04:28
nkolev92
nkolev92 previously approved these changes Jun 29, 2026
kartheekp-ms
kartheekp-ms previously approved these changes Jun 29, 2026
jebriede
jebriede previously approved these changes Jun 29, 2026

@jebriede jebriede left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with suggestions

When the same source URL is configured multiple times (for example as both a package source and an audit source), the insecure HTTP check now reports it only once. Deduplication happens at the point of emission, after the insecure-source guard, so a secure entry with the same URL never suppresses an insecure one.

Co-authored-by: Copilot <[email protected]>
@zivkan
zivkan dismissed stale reviews from jebriede, kartheekp-ms, and nkolev92 via 65c7afe June 30, 2026 06:47
nkolev92
nkolev92 previously approved these changes Jun 30, 2026
jebriede
jebriede previously approved these changes Jun 30, 2026
@zivkan
zivkan dismissed stale reviews from jebriede and nkolev92 via d7dafa3 July 2, 2026 01:35
@zivkan
zivkan requested review from jebriede and nkolev92 July 2, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore will start checking audit sources are secure HTTPS

5 participants