-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable NuGet Audit in .NET repositories #15019
Comments
NuGet.Client added (I also added the 4 NU codes to |
Contributes to dotnet/arcade#15019 Fixes dotnet/source-build#4577
Contributes to dotnet/arcade#15019 Also remove the unnecessary `SystemFormatsAsn1Version` property.
Contributes to dotnet/arcade#15019 - Remove unnecessary package source feeds - Move version properties into D.Packages.props as those aren't auto-updated. - Enable NuGetAudit and make vulnerabilities to only fail the official build.
Contributes to dotnet/arcade#15019 - Remove unnecessary package source feeds - Move version properties into D.Packages.props as those aren't auto-updated. - Enable NuGetAudit and make vulnerabilities to only fail the official build.
* Enable NuGetAudit Contributes to dotnet/arcade#15019 Also remove the unnecessary `SystemFormatsAsn1Version` property. * Update NuGet.config
* Enable Central Package Management and NuGetAudit Contributes to dotnet/arcade#15019 * Delete eng/SourceBuildPrebuiltBaseline.xml * Don't hardcode package relative path
@mmitche @jaredpar @aortiz-msft - how do you think we should drive enforcement of this? @jaredpar suggested forcing folks to emit a binlog then presumably adding some validation somewhere in the common templates or scripts to ensure they ran the build with audit enabled. Seems possible but feels like a lot of things to line up just to enforce this in the timeline we're trying to drive it. I was thinking we could add a check in arcade for this. @aortiz-msft @zivkan suppose we wanted Arcade to enforce this, could we set a property that would make NuGet enforce that, or could we observe if NuGet ran with an audit source? If we did so, then we could make arcade check for that and emit an error if it's absent. |
Binlog checking seems rather fragile and I don't love the idea of adding additional steps to builds just to do this checking. Is it possible to detect whether NuGet Audit is enabled via msbuild targets? We have plenty of injection points in arcade. What properties can we check? |
I checked some binlogs from before and after Viktor's change to arcade to enable auditing. There's not much to go on. No real indication that actual auditing happened. The thing is that auditing is enabled in both, just only functional in the one with nuget.org as part of the audit sources. The only binlog entry differentiating the two is that searching for "nuget.org" shows a CACHE entry for nuget.org's vulnerability endpoint if auditing is working. But I wouldn't base detection on that. Instead, it's probably better for arcade to include a target that reads the nuget.config file and verifies the audit sources are available. @zivkan @aortiz-msft Are the audit sources controllable with an itemgroup, or only through nuget.config? |
I think that if pipelines / actions published binlogs to a well known location there is a lot of standard analysis that we could do. I understand it's a bit of cost initially but need to pay that at some point.
That approach though limits our ability to say look at what warnings are suppressed, how globally are they suppressed, etc ... |
When
Only through nuget.config. We have a request to make it available via msbuild, but it has zero upvotes so far. |
Arcade can check whether NuGetAudit = false (it isn't). We would need to implement the additional check on the nuget.config. I don't think the binlog is the way to go here as there was no obvious way to say auditing happened. For instance, the list of audit sources is not even outputted into the binlog. We could go in the direction of the binlog being more checkable, but IMO:
|
You can argue "they can turn it off" for any option here. The question is whether you can detect the situation or not. The abscence of a published file is pretty easy to detect 😄 |
This enables NuGet audit using the audit sources from nuget.org. This is the standard that is being pushed into all of our repositories. The end result is that we will get early warning on CVE and won't need to wait until CG scans on our scheduled builds reveal them. I've set this up so that it warns not errors. That is deliberate because the audit warnings are asynchronous. Setting them up as errors would mean that builds, which were passing one minute, could start failing the next t. A warning here feels like the right balance but we can experiment and see how it goes. Related dotnet/arcade#15019
Could we force a layered NuGet.config with the audit source in official builds? NuGet.config's are all about layering. |
I don't think layering would work (not sure where we would put the layer, but we could modify Maestro to augment the nuget.config. It already can do so for other things. Not sure whether all repos would love that approach, though. |
There should also be an option for arcade to set |
What is the guidance here? If I turn it on and leave them as warnings (as errors), my builds will get broken the moment there is a release. We've already seen that break VMR builds because of older arcade dependencies and the warnings were downgraded back to warnings. However, if they are left as warnings, will anyone ever see them? We already have CG running so what additional value does this provide over that? |
We recommend and implemented the following in most repos: Line 18 in ad64a76
This means that we block official builds but not dev and CI builds. We must not release new bits without NuGet Audit enabled but we don't want to nuke all builds on a Patch Tuesday. |
I think the best approach is:
The rationale for not wanting error on official builds is that it will lead to us failing official builds for NuGet audit warnings that aren't actually blocking us shipping. NuGet audit is always going to have a degree of false positive or real positive but test assets only. Having us fail official builds for that feels wrong. Instead I think it's better to warn on official builds and then before shipping audit the warnings and decide if they are critical enough to block shipping. I also think we need to think about the policy for meta repos like source build or VMR. That is taking all of the friction with NuGet audit and multiplying it by the number of repositories there are. Further in the case of VMR we're getting the warning in a place (asynchronously) but we will be fixing the warning in another place (the original repo). Having NuGet audit run in PR / local dev seems like it will lead to an incredible amount of noise. For that rolling / official seems a better course with checks to ensure the teams are tracking the issues in the originating repository. |
NuGet Audit docs: https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/ & https://learn.microsoft.com/en-us/nuget/concepts/auditing-packages
NuGet Audit flags vulnerable dependencies at restore and build time so that we don’t have to exclusively rely on post-build scanners like Component Governance. NuGet Audit is part of the .NET 8 and .NET 9 SDKs and now enabled by default.
Our .NET repositories need to opt into that security feature as we don’t use nuget.org as our package repository. Aside from resolving potential vulnerable packages in the build, all that's needed to turn it on is: #15018
Requirement
This depends on a NuGet feature that got added with the .NET 9 Preview 7 SDK. If your repository doesn't yet use that, that's fine and enabling NuGetAudit can be revisited at a later point.
Status
List below are repositories that are part of the VMR. The list can be extended.
cc @zivkan @ericstj @JonDouglas
The text was updated successfully, but these errors were encountered: