Code Monkey home page Code Monkey logo

covenant's Introduction

Covenant

A tool to generate SBOM (Software Bill of Material) from source code artifacts.

NOTE: Covenant requires all projects to have been built, and all dependencies to have been restored to make an as accurate analysis as possible.

Supported SBOM formats

Supported sources

  • .NET 5 to .NET 8
  • .NET Core
  • NPM
  • CycloneDX BOM
    • *.cdx.xml or bom.xml

Installation

Install by running the following command in your repository:

$ dotnet tool install covenant

You can also install Covenant globally on your machine:

$ dotnet tool install -g covenant

Configuration file

The configuration file is used to configure different aspects of Covenant.

{
    "$schema": "https://raw.githubusercontent.com/patriksvensson/covenant/main/schema/0.14.json"
    
    // Used for arbitrary files to be included in the SBOM (optional)
    "files": [
        {
            "path": "./files/lol.txt",
            "license": "MIT"
        },
        {
            "path": "./**/foo.c"
        }
    ],
    
    // Used for compliance checks (optional)
    "licenses": { 
        "banned": [
            "MIT"
        ]
    }
}

Generate Covenant SBOM

Usage:
  covenant generate [<PATH>] [options]

Arguments:
  <PATH>  A file or directory to use as input

Options:
  -o, --output <FILE>         The output path of the SBOM file
  -n, --name <NAME>           The SBOM name
  -v, --version <VERSION>     The SBOM version [default: 0.0.0]
  -m, --metadata <metadata>   Arbitrary metadata in the form 'key=value'
  -c, --configuration <FILE>  The Covenant configuration file to use
  --design-time-build         Performs a design time build for .NET projects [default: False]
  --no-dev-dependencies       Excludes dev dependencies for NPM projects [default: False]
  -?, -h, --help              Show help and usage information

To generate an Covenant SBOM from the current directory:

dotnet covenant generate 

To generate an Covenant SBOM from a specific directory:

dotnet covenant generate "C:\Source\Foo"

To generate an Covenant SBOM from a specific file:

dotnet covenant generate "C:\Source\Foo\Foo.sln"

Convert Covenant SBOM to third party SBOM formats

Usage:
  covenant convert [command] [options]

Options:
  -?, -h, --help  Show help and usage information

Commands:
  cyclonedx <PATH>
  spdx <PATH>

SPDX

Usage:
  covenant convert spdx <PATH> [options]

Arguments:
  <PATH>  The Covenant SBOM file to convert

Options:
  -o, --output <FILE>      The output path
  --namespace <namespace>  The SPDX namespace
  -?, -h, --help           Show help and usage information
dotnet covenant convert spdx "C:\Source\Foo\Foo.covenant.json"

CycloneDX

Usage:
  covenant convert cyclonedx <PATH> [options]

Arguments:
  <PATH>  The Covenant SBOM file to convert

Options:
  -o, --output <FILE>  The output path
  -?, -h, --help       Show help and usage information
dotnet covenant convert cyclonedx "C:\Source\Foo\Foo.covenant.json"

Creating reports

Usage:
  covenant report <PATH> [options]

Arguments:
  <PATH>  The Covenant SBOM file to create a HTML report for

Options:
  -o, --output <FILE>  The output path of the HTML report
  -?, -h, --help       Show help and usage information
dotnet covenant report "C:\Source\Foo\Foo.covenant.json"

Checking compliance

Usage:
  covenant check <PATH> [options]

Arguments:
  <PATH>  The Covenant SBOM file to run compliance checks for

Options:
  -c, --configuration <FILE>  The Covenant configuration file to use
  -?, -h, --help              Show help and usage information
dotnet covenant check "C:\Source\Foo\Foo.covenant.json"

You can put a file called covenant.config next to the SPDX report, or providing one via the --config parameter, to configure the compliance rules.

{
    "licenses": {
        "banned": [
            "MIT"
        ]
    }
}

Building

We're using Cake as a dotnet tool for building. So make sure that you've restored Cake by running the following in the repository root:

> dotnet tool restore

After that, running the build is as easy as writing:

> dotnet cake

covenant's People

Contributors

devlead avatar johanlindfors-ts avatar numpsy avatar patriksvensson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

covenant's Issues

Compliance: Explicitly allowed components

It should be possible to explicitly allow a component, regardless if it's not part of an "allow" SPDX license expression or if the component license has explicitly been banned.

Suggestion: Missing `project.assets.json` as warning instead of an error

I was looking for an alternative to https://github.com/microsoft/sbom-tool with CycloneDX support and came across this repo. Thanks for the tool! :-)

One suggestion though: The SBOM generation failed for me because I had no project.assets.json in one of my subprojects. As a result no SBOM was generated at all. My preference would be to see missing project.assets.json as an warning that does not prevent the generation of the SBOM.

and

context.AddError($"Could not find [yellow]project.assets.json[/] at [yellow]{path}[/]");

What do you think?

Usage with .NET 8 projects using the 'UseArtifactsOutput' build option

Hi,

I had a go at running Covenant on a project that uses the 'UseArtifactsOutput' build option that was added in .NET 8 (which causes all the 'obj' directories to get put under a single 'artifacts' directory under the build root), and that failed as it couldn't find the project.assets.json file.

I haven't had much of a look at the issue, but I guess it might be down to
https://github.com/patriksvensson/covenant/blob/afaa6d6b83d00f9cbe8005f2091f521cb4a4dbfd/src/Covenant/Analysis/Dotnet/DotnetAnalyzer.cs#L223C38-L223C38
which looks for the assets file in a fixed location under the directory containing the project file.

Suggestion: Add support for tracking licensed components smaller than a library

A component may consume 3rd party licensed elements at a more granular level than a package or library, it would be useful to be able to represent these smaller-scale dependencies in the generated SBOM.

For example, a given code file may re-use or derive its own implementation from another source. Whilst this use can be acknowledged via a comment in the affected code file and other higher level documentation, this doesn't offer a structured way to record the dependency and any licensing requirements attached to its use.

Approaches like the debian/copyright file provide a means of recording licensing requirements on a per-file basis.

Adding support to Covenant so it can understand such conventions would enable it to include the license details of these 'sub-library' dependencies.

The SPDX specification includes support for recording information at the file level which seems like it would cater for this type of scenario.

Custom SPDX License Id

Problem

I have a dependency on a component that does not have a SPDX License Id. For example the System.IO 4.3 package only have a license URL to the Microsoft .NET Library license, which does not fulfill the requirements to be included in the official SPDX License ID list.

Converting the SBOM to CycloneDX will only include the license URL which can not be used to identify the license in Dependency Track. Dependency Track relies on SPDX license ID for identification.

Current Behavior

  • Converting to SPDX will generate a custom license ID that is unique only the SBOM file (and possibly undeterministic?)
  • Converting to CycloneDX will generate only a license URL

Proposed Behavior

  • Make it possible to map license url:s to custom license Id:s
  • Make mapped license id:s part of CycloneDX conversion

This would solve the problem of identification in Dependency Track.

Stretch

  • Add default mappings that can be enabled/disabled and overriden (this can be nice for common packages from Microsoft)
  • Add support for the ScanCode License Database

Support for F# project files?

Hi,

I tried running Covenant on a solution that contains F# projects and it successfully generated a report, but when I tried running it directly against an fsproj file I got

SBOM was not created since no components could be found

I had a go at making it recognize .fsproj project files in main...Numpsy:covenant:fsproj and it appeared to work, so - is that something you'd be interested in supporting?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.