What the agent does
The agent clones the solution into its own cloud sandbox and reads the build configuration before any tooling. In a solution like jasontaylordev/CleanArchitecture, global.json pins SDK 10.0.403 with rollForward: latestFeature, Directory.Build.props targets net10.0 with TreatWarningsAsErrors on and NU1608 carved out through WarningsNotAsErrors, and Directory.Packages.props turns on central package management with CentralPackageTransitivePinningEnabled. One line there tells the story the job is about: System.Security.Cryptography.Pkcs is pinned to 10.0.14 with a comment saying 10.0.12 was pulled in transitively and carried two GitHub advisories. Somebody found that by hand. There is no nuget.config, so restore talks to nuget.org with the SDK's defaults, and .github/workflows/build.yml runs dotnet restore, dotnet build --no-restore --configuration Release and dotnet test --no-build on pull requests to main, with codeql.yml, release.yml and test-templates.yml beside it.
It then works out what the SDK already does and what is implicit. Since the .NET 8 SDK, dotnet restore audits packages against the vulnerability data nuget.org publishes and raises NU1901 to NU1904 for low through critical advisories, and with TreatWarningsAsErrors set in this repository those warnings already fail a restore. What is missing is the policy stated in a file: the audit level, whether transitive packages are included, and where the data comes from. The agent adds NuGetAudit, NuGetAuditMode set to all and NuGetAuditLevel set to low to Directory.Build.props with a comment on each, so the behaviour no longer depends on which SDK's default a contributor happens to have, and adds a nuget.config with an auditSources entry naming nuget.org's vulnerability feed, which is what keeps the audit working the day someone adds a private feed that has no advisory data and would otherwise produce NU1905.
A failing restore says that something is vulnerable, not what or why, so the agent adds a report. In build.yml a step after restore runs dotnet list package --vulnerable --include-transitive for the solution and writes the output to the job summary, and on a finding it runs dotnet nuget why for each flagged package so the summary shows the dependency path that pulled it in, which is exactly the question the Pkcs comment answers by hand today. It also adds .github/workflows/audit.yml on a weekly schedule and workflow_dispatch, running restore and the same report against main, because an advisory published after a pull request merges only surfaces when something restores again, and a quiet repository may not restore for weeks.
Because this repository is also a dotnet new template, with <!--#if (UsePostgreSQL)--> conditionals in the props files and a test-templates.yml workflow that instantiates it, the agent keeps the new properties outside any conditional block and in Directory.Build.props, which every generated solution carries. In the sandbox it installs the SDK global.json names, runs dotnet restore to show the audit passes with the current pins, runs the vulnerable-package report to show it empty, and runs dotnet build --configuration Release once to confirm that adding properties to the props file changed nothing else. The output goes into the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add NuGet vulnerability auditing to this .NET solution's CI. Read global.json, Directory.Build.props, Directory.Packages.props, any nuget.config, every workflow under .github/workflows and the solution layout first, and note any package already pinned because of an advisory. In Directory.Build.props set NuGetAudit, NuGetAuditMode all and NuGetAuditLevel low explicitly with a comment each, outside any template conditional. Add a nuget.config with nuget.org as a package source and as an audit source. In the build workflow add a step after restore that runs dotnet list package --vulnerable --include-transitive into the job summary and, on any finding, dotnet nuget why for each flagged package. Add a weekly scheduled workflow that runs restore and the same report on the default branch. Do not change package versions. In your sandbox install the pinned SDK, run dotnet restore, the vulnerable-package report and a Release build, and open a pull request whose description explains what the SDK audited before this change, what is now explicit, and the command output.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request with three properties and comments added to Directory.Build.props, a new nuget.config, one new step in .github/workflows/build.yml and a new .github/workflows/audit.yml. No package version changes. The description explains what the SDK was already doing at restore time, what is now written down, and why the report step exists alongside the failing restore: one blocks, the other tells a reviewer which package and which path.
The run's record keeps the dotnet restore, dotnet list package --vulnerable --include-transitive and dotnet build --configuration Release output from the sandbox, so a reviewer sees the audit pass with the current pins, the report come back empty, and the build unchanged, and can check that the Pkcs pin that prompted the comment is no longer the only line of defence.
Before merging, a reviewer decides whether low is the right floor or whether moderate suits a template many teams generate from, confirms the organisation allows scheduled workflows on the repository, and checks the summary step renders in a pull request before relying on it during an incident.
Run it on every Monday morning
The weekly audit.yml the pull request adds is the recurring half of this job. The other half is reading what it finds. A team starts one run every Monday from an automation with a schedule trigger in the Project that holds the solution, with a prompt that asks the agent to run the vulnerable-package report, and for each finding to read the advisory, run dotnet nuget why for the path, bump or pin the package in Directory.Packages.props at the patched version, and open a pull request with the restore passing.
Each run works in its own sandbox against the current main, so a quiet week opens nothing and a week with an advisory opens one pull request with the package, the path and the advisory ids in its description, which is the comment on the Pkcs line written by a process instead of a person.
The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.
Why run it on Rush?
The audit is already in the SDK; the value is in making the policy visible and the output readable. A pull request that turns three defaults into three commented lines, adds a report that names the package and its path, and schedules the check so it runs when nobody is pushing, is an afternoon of reading NuGet documentation that the agent does in its sandbox with the commands run and kept. Nothing in the pull request is a claim about how auditing works; each claim has a command next to it.
An organisation with a dozen .NET solutions sends the same body a dozen times, and each run reads that solution's props, finds its own hand-made pins and comments, and opens a pull request a reviewer can compare against the others. The weekly automation then keeps every one of them honest without a person remembering to restore.
Frequently asked questions
Does this change any package versions?
No. The pull request adds properties, a nuget.config and workflow steps. If the report in the sandbox had found a vulnerable package, the agent would say so in the description and leave the version change to a separate pull request, because an upgrade needs its own test run and review.
Why add properties if the SDK already audits?
Because the defaults for audit level and transitive coverage have changed between SDK versions, and rollForward: latestFeature means contributors do not all run the same one. Three lines in Directory.Build.props make every restore, local or in CI, apply the same policy.
Will a new advisory break the build for everyone?
With TreatWarningsAsErrors already on, a restore that hits an advisory fails today; the pull request does not change that. What it adds is the report that says which package and which path, and a weekly run that finds the advisory on a schedule instead of in the middle of someone's unrelated pull request.
Does it work with central package management?
Yes. The audit runs on the resolved graph, and CentralPackageTransitivePinningEnabled in Directory.Packages.props is how this solution already fixes a transitive version. A finding is resolved by adding or raising a PackageVersion line there, which dotnet nuget why points at.
What if we add a private feed later?
That is what the auditSources entry in nuget.config is for. A private feed usually has no vulnerability data, and without an audit source NuGet reports NU1905 and audits nothing. Naming nuget.org as the audit source keeps the check working whatever the package sources become.
More .NET jobs
More jobs like this: Upgrade dependencies weekly
- Add pip-audit to a Python Project's CI (Python)
- Set Up Renovate for an Ansible Role (Ansible)
- Add Renovate to Keep Docker Compose Image Tags Current (Docker Compose)