NuGet Application Analysis

NuGet Application Analysis

Evaluation: Advanced Binary Fingerprinting (ABF)

The primary open-source repository for .NET components is NuGet. A NuGet package is an archive file with the .nupkg extension. These packages contain compiled code in the form of Pecoff (PE = Portable Executable, COFF = Common Object File Format) files, related files, and a descriptive manifest. Developers may add complete packages to their applications or directly utilize the Pecoff files from the package. The .NET build process will remove non-essential files connecting individual Pecoff files back to their parent components.

Scanning MSI Packages

An MSI (Microsoft Software Installer) file is a package file that contains instructions for installing, updating, configuring, and removing software on Windows. The contents that go into an MSI are compressed and modified so may not be scanned effectively. Analyzing .msi files is not currently supported.

Scan the contents of your application before packaging your application into the .msi format.

Evaluation: Project files

A Lifecycle analysis can be run from source control by directly scanning the project (.csproj) and packages.config files. Both are package file options used in NuGet projects.

For example, a declaration such as Version="3.6.*" or Version="[3.6,4.0)" will not be analyzed.

.csproj

The include and version fields will be evaluated.

.csproj

<Project Sdk="Microsoft.NET.Sdk">
        <ItemGroup Condition = "'$(TargetFramework)' == 'net452'">
                <PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0" />
        </ItemGroup>
</Project>

packages.config

The id and version fields will be evaluated.

packages.config

 <?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="7zip" version="4.23.0" targetFramework="net46" developmentDependency="true" />
  <package id="bootstrap" version="4.0.0-beta" targetFramework="net46" developmentDependency="true" />
</packages>

Steps to analyze using the Sonatype IQ CLI

Invoke a Sonatype IQ CLI analysis of a directory or subdirectories containing .csproj files. When binaries are included in the scan path the analysis will default to an ABF scan from above.

.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
  </ItemGroup>
</Project>

Steps to analyze using the Jenkins plugin

The Sonatype Platform Plugin for Jenkins will not evaluate the packages.config or .csproj files by default. Custom Scan Targets are needed to target these files.

Example Pipeline Script with Scan Patterns

nexusPolicyEvaluation iqApplication: 'SampApp', iqScanPatterns: [[scanPattern: '**/*.csproj'], [scanPattern: '**/packages.config']], iqStage:  'build'

Search results

No results found