Skip to main content
caution

This documentation is a WIP and gives only a brief explanation of what each field in the NuGetDefense.json configuration file does and what values they accept.

Configuring NuGetDefense

NuGetDefense can run without any prior configuration. On the first run, it will generate a config file in the AppData Special Folder with the defaults used when no configuration is found. For more control over specific projects and solutions, you can add a NuGetDefense.json config file to the directory with your project or solution file and it will be used instead.

NuGetDefense.json
{
"WarnOnly": false,
"VulnerabilityReports": {
"OutputTextReport": true
},
"CheckTransitiveDependencies": true,
"CheckReferencedProjects": false,
"ErrorSettings": {
"ErrorSeverityThreshold": "any",
"Cvss3Threshold": -1,
"IgnoredPackages": [
{
"Id": "NugetDefense"
}
],
"IgnoredCvEs": [],
"AllowedPackages": [],
"WhiteListedPackages": [],
"BlockedPackages": [],
"BlacklistedPackages": []
},
"OssIndex": {
"ApiToken": "",
"Username": "",
"Enabled": true,
"BreakIfCannotRun": true
},
"GitHubAdvisoryDatabase": {
"ApiToken": "",
"Username": "",
"Enabled": true,
"BreakIfCannotRun": false
},
"NVD": {
"SelfUpdate": false,
"TimeoutInSeconds": 15,
"Enabled": true,
"BreakIfCannotRun": true
},
"SensitivePackages": []
}

WarnOnly

When enabled, NuGetDefense will always return an exit code of 0, and will output msbuild warning messages instead of msBuild Error Messages

Accepted Values

ValueDescription
trueEnables WarnOnly mode preventing errors wehn vulnerabilities are reporting from the msBuild
falseReturns errors and a non-zero exit code when vulnerabilities are reported. This will break the build.msBuild

VulnerabilityReports

VulnerabilityReports allows exporting reports generated by nugetdefense with details from the scan. There are a few report types available. Any reports omitted from these settings is disabled.

Report OptionValues AcceptedDescription
JsonReportPathAny Valid File PathExports the VulnerabilityReport in JSON format to the provided path.
OutputTextReporttrue or falseOutputs the a human readable VulnerabilityReport to the console.
XmlReportPathAny Valid File PathOutputs the VulnerabilityReport in XML format to the provided path.

CheckTransitiveDependencies

Transitive dependency checking relies on dotnet list --transitive and adds any versions found in that list to the packages to be scanned.

ValueDescription
trueEnables scanning transitive dependencies (dependencies of the packages you have referenced that are automatically referenced in your project).
falseDisabled transitive dependency scanning.

CheckReferencedProjects

Referenced project scanning works when the project file is scanned. Any packages referenced in those projects are scanned as well.

ValueDescription
trueEnables scanning project references.
falseDisabled scanning project references.

ErrorSettings

Error settings generally handle how errors for vulnerabilities are handled.packages

ErrorSeverityThreshold

Human readable levels for vulnerability severities. Each level corresponds to a CVSS score range. Scores below that range are ignored.

::: caution This setting is not compatible with Cvss3Threshold :::

SeverityyCVSS Score
anyN/A - any disables severity thresholds
NoneCVSS3 score 0 - Only vulnerabilities without a CVSS score are ignored
LowCVSS3 score 0.1 - 3.9
MediumCVSS3 score 4.0 - 6.9
HighCVSS3 score 7.0 - 8.9
CriticalCVSS3 score 9.0 - 10.0

Cvss3Threshold

CSSV3 Score threshold for ignoring vulnerabilities.

::: caution This setting is not compatible with ErrorSeverityThreshold :::

ValueDescription
0 to 10.0Ignores all vulnerabilities with a CVSS3 score lower than the threshold. Also Ignores All Vulnerabilities without a CVSS3 score.
-1Disables the threshold.

IgnoredPackages

An array of packages to be ignored.

ValueDescription
IdRequired Id of the package to ignore
VersionOptional Version of the package to ignore. If no version is set, all versions of the package are ignored.

ex.

[
{
"Id": "NugetDefense",
"Version": "1.2.3"
},
{
"Id": "InternalPackage.Invulnerable"
}
]

IgnoredCvEs

Array of CVE's or Vulenrability ID's to ingore when scanning.

ex. ["CVE-1234-1234","sonatype-1234-01234","GHSA-1234-abc9-abcd"]

AllowedPackages / WhiteListedPackages

This is an AllowList/WhiteList of packages that are allowed to be installed in the project. This is generally intended for CI use to prevent the addition of unapproved packages to a project. AllowedPackages is the official name of this setting, but for backwards compatability and non-english speaking users, WhiteListedPackages is also usable.

ValueDescription
IdRequired Id of the package to ignore
VersionOptional Version of the package to ignore. If no version is set, all versions of the package are ignored.

ex.

[
{
"Id": "NugetDefense",
"Version": "1.2.3"
},
{
"Id": "InternalPackage.Invulnerable"
}
]

BlockedPackages / BlackListedPackages

This is an AllowList/WhiteList of packages that are allowed to be installed in the project. This is generally intended for CI use to prevent the addition of unapproved packages to a project. AllowedPackages is the official name of this setting, but for backwards compatability and non-english speaking users, WhiteListedPackages is also usable.

ValueDescription
IdRequired Id of the package to ignore
VersionOptional Version of the package to ignore. If no version is set, all versions of the package are ignored.

ex.

[
{
"Id": "NugetDefense",
"Version": "1.2.3"
},
{
"Id": "InternalPackage.Invulnerable"
}
]

OssIndex / GitHubAdvisoryDatabase

OSSIndex and GitHubAdvisoryDatabase are remote vulnerability sources and information about your packages must be sent up to their servers to gather information about the known vulnerabilities for them. They share teh same configuration settings. In general it's advisable to setup an account to access remote vulnerability services. GitHubAdvisoryDatabase does not work without one, but rewuires NO permissions. OSSindex provides more useful info with an account.

ValueDescription
APITokenRequired For GitHubAdvisoryDatabase Password/API Token/Secret for accessing the API using your account
UsernameOptional Username of the account used to access the remote vulnerability source
EnabledEnables using this vulnerability source. If not present or Disabled, this source will not be used to scan your packages.
BreakIfCannotRunIf enabled, throws an error if the source cannot be run. This could be caused by aPI limits or network errors.

NVD

NVD is an offline copy of the National Vulnerability Database that is optionally self-updating. This is the least reliable source for vulnerability scanning since it has an automated update/parsing process.

ValueDescription
SelfUpdateIf Enabled, attempts to update the offile source before scanning.
TimeoutInSecondsTimeout to use when retrieving the latest vulnerabilities.
EnabledEnables using this vulnerability source. If not present or Disabled, this source will not be used to scan your packages.
BreakIfCannotRunIf enabled, throws an error if the source cannot be run. This could be caused by aPI limits or network errors.

SensitivePackages

Packages in this array are not sent to any remote vulnerability source but will still be scanned against the embedded NVD source.

ValueDescription
IdRequired Id of the package to ignore
VersionOptional Version of the package to ignore. If no version is set, all versions of the package are ignored.

ex.

[
{
"Id": "NugetDefense",
"Version": "1.2.3"
},
{
"Id": "InternalPackage.Invulnerable"
}
]

Log / Logs

The Log configuration section provides options to log the output to a file.

Logs accepts an array of file locations instead of a single path.

FieldDescription
OutputRequired Path to the log file
LogLevelOptional Log Level to use when logging: Verbose, Debug, Information, Warning, Error, Fatal
RollingIntervalOptional Log rotation interval: Infinite, Year, Month,Day,Hour,Minute

CacheLocation

Path for the local cache for previously reported known vulnerabilities.

Defaults to: /path/to/SpecialFolder/ApplicationData/.nugetdefense/NugetDefense.sqlite