A Go implementation of in-toto. in-toto is a framework to protect software supply chain integrity.

In-toto Go implementation

build Coverage Status PkgGoDev Go Report Card

Go implementation of the in-toto Python reference implementation.

Docs

To read the documentation along with some examples, run:

godoc -http :8080

and navigate to localhost:8080/pkg/github.com/in-toto/in-toto-golang/in_toto/

Example

A very simple example, just to help you starting:

package main

import (
	"time"
	toto "github.com/in-toto/in-toto-golang/in_toto"
)

func main() {
	t := time.Now()
	t = t.Add(30 * 24 * time.Hour)

	var keys = make(map[string]toto.Key)

	var metablock = toto.Metablock{
		Signed: toto.Layout{
			Type: "layout",
			Expires:  t.Format("2006-01-02T15:04:05Z"),
			Steps: []toto.Step{},
			Inspect: []toto.Inspection{},
			Keys:  keys,
		},
	}

	var key toto.Key

	key.LoadKey("keys/alice", "rsassa-pss-sha256", []string{"sha256", "sha512"})

	metablock.Sign(key)

	metablock.Dump("root.layout")
}

Running the Demo

To run the demo, pull down the source code, install Go, and run make test-verify. This will use openssl to generate a certificate chain.

During the in-toto verification process, certificate constraints are checked to ensure the build step link meta-data was signed with the correct SVID.

Building

Download the source, run make build.

CLI

Usage:
  in-toto [command]

Available Commands:
  help        Help about any command
  key         Key management commands
  record      Creates a signed link metadata file in two steps, in order to provide evidence for supply chain steps that cannot be carried out by a single command
  run         Executes the passed command and records paths and hashes of 'materials'
  sign        Provides command line interface to sign in-toto link or layout metadata
  verify      Verify that the software supply chain of the delivered product

Flags:
  -h, --help                              help for in-toto

Use "in-toto [command] --help" for more information about a command.

key

Key management commands

Usage:
  in-toto key [command]

Available Commands:
  id          Output the key id for a given key
  layout      Output the key layout for a given key in <KEYID>: <KEYOBJ> format

Flags:
  -h, --help   help for key

Use "in-toto key [command] --help" for more information about a command.

run

Executes the passed command and records paths and hashes of 'materials' (i.e.
files before command execution) and 'products' (i.e. files after command
execution) and stores them together with other information (executed command,
return value, stdout, stderr, ...) to a link metadata file, which is signed
with the passed key.  Returns nonzero value on failure and zero otherwise.

Usage:
  in-toto run [flags]

Flags:
  -c, --cert string                 Path to a PEM formatted certificate that corresponds with
                                    the provided key.
  -e, --exclude stringArray         Path patterns to match paths that should not be recorded as 0
                                    ‘materials’ or ‘products’. Passed patterns override patterns defined
                                    in environment variables or config files. See Config docs for details.
  -h, --help                        help for run
  -k, --key string                  Path to a PEM formatted private key file used to sign
                                    the resulting link metadata.
  -l, --lstrip-paths stringArray    Path prefixes used to left-strip artifact paths before storing
                                    them to the resulting link metadata. If multiple prefixes
                                    are specified, only a single prefix can match the path of
                                    any artifact and that is then left-stripped. All prefixes
                                    are checked to ensure none of them are a left substring
                                    of another.
  -m, --materials stringArray       Paths to files or directories, whose paths and hashes
                                    are stored in the resulting link metadata before the
                                    command is executed. Symlinks are followed.
  -d, --metadata-directory string   Directory to store link metadata (default "./")
  -n, --name string                 Name used to associate the resulting link metadata
                                    with the corresponding step defined in an in-toto layout.
      --normalize-line-endings      Enable line normalization in order to support different
                                    operating systems. It is done by replacing all line separators
                                    with a new line character.
  -p, --products stringArray        Paths to files or directories, whose paths and hashes
                                    are stored in the resulting link metadata after the
                                    command is executed. Symlinks are followed.
  -r, --run-dir string              runDir specifies the working directory of the command.
                                    If runDir is the empty string, the command will run in the
                                    calling process's current directory. The runDir directory must
                                    exist, be writable, and not be a symlink.

sign

Provides command line interface to sign in-toto link or layout metadata

Usage:
  in-toto sign [flags]

Flags:
  -f, --file string     Path to link or layout file to be signed or verified.
  -h, --help            help for sign
  -k, --key string      Path to PEM formatted private key used to sign the passed 
                        root layout's signature(s). Passing exactly one key using
                        '--layout-key' is required.
  -o, --output string   Path to store metadata file to be signed

verify

in-toto-verify is the main verification tool of the suite, and 
it is used to verify that the software supply chain of the delivered 
product was carried out as defined in the passed in-toto supply chain 
layout. Evidence for supply chain steps must be available in the form 
of link metadata files named ‘<step name>.<functionary keyid prefix>.link’.

Usage:
  in-toto verify [flags]

Flags:
  -h, --help                         help for verify
  -i, --intermediate-certs strings   Path(s) to PEM formatted certificates, used as intermediaries to verify
                                     the chain of trust to the layout's trusted root. These will be used in
                                     addition to any intermediates in the layout.
  -l, --layout string                Path to root layout specifying the software supply chain to be verified
  -k, --layout-keys strings          Path(s) to PEM formatted public key(s), used to verify the passed 
                                     root layout's signature(s). Passing at least one key using
                                     '--layout-keys' is required. For each passed key the layout
                                     must carry a valid signature.
  -d, --link-dir string              Path to directory where link metadata files for steps defined in 
                                     the root layout should be loaded from. If not passed links are 
                                     loaded from the current working directory.
      --normalize-line-endings       Enable line normalization in order to support different
                                     operating systems. It is done by replacing all line separators
                                     with a new line character.

record

Creates a signed link metadata file in two steps, in order to provide
evidence for supply chain steps that cannot be carried out by a single command
(for which ‘in-toto-run’ should be used). It returns a non-zero value on
failure and zero otherwise.

Usage:
  in-toto record [command]

Available Commands:
  start       Creates a preliminary link file recording the paths and hashes of the
passed materials and signs it with the passed functionary’s key.
  stop        Records and adds the paths and hashes of the passed products to the link metadata file and updates the signature.

Flags:
  -c, --cert string                 Path to a PEM formatted certificate that corresponds
                                    with the provided key.
  -e, --exclude stringArray         Path patterns to match paths that should not be recorded as 
                                    ‘materials’ or ‘products’. Passed patterns override patterns defined
                                    in environment variables or config files. See Config docs for details.
  -h, --help                        help for record
  -k, --key string                  Path to a private key file to sign the resulting link metadata.
                                    The keyid prefix is used as an infix for the link metadata filename,
                                    i.e. ‘<name>.<keyid prefix>.link’. See ‘–key-type’ for available
                                    formats. Passing one of ‘–key’ or ‘–gpg’ is required.
  -l, --lstrip-paths stringArray    Path prefixes used to left-strip artifact paths before storing
                                    them to the resulting link metadata. If multiple prefixes
                                    are specified, only a single prefix can match the path of
                                    any artifact and that is then left-stripped. All prefixes
                                    are checked to ensure none of them are a left substring
                                    of another.
  -d, --metadata-directory string   Directory to store link metadata (default "./")
  -n, --name string                 Name for the resulting link metadata file.
                                    It is also used to associate the link with a step defined
                                    in an in-toto layout.
      --normalize-line-endings      Enable line normalization in order to support different
                                    operating systems. It is done by replacing all line separators
                                    with a new line character.

Use "in-toto record [command] --help" for more information about a command.

Completion

Generate completion script
Usage:
  in-toto completion [bash|zsh|fish|powershell]

Flags:
  -h, --help   help for completion

Bash

$ source <(in-toto completion bash)
# To load completions for each session, execute once:
# Linux (the target location may differ depending on your distro):
$ in-toto completion bash > /etc/bash_completion.d/in-toto
# macOS:
$ in-toto completion bash > /usr/local/etc/bash_completion.d/in-toto

Zsh

# If shell completion is not already enabled in your environment,
# you will need to enable it.  You can execute the following once:
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
# To load completions for each session, execute once:
$ in-toto completion zsh > "${fpath[1]}/_in-toto"
# You will need to start a new shell for this setup to take effect.

Fish

fish:
$ in-toto completion fish | source
# To load completions for each session, execute once:
$ in-toto completion fish > ~/.config/fish/completions/in-toto.fish

PowerShell

PS> in-toto completion powershell | Out-String | Invoke-Expression
# To load completions for every new session, run:
PS> in-toto completion powershell > in-toto.ps1
# and source this file from your PowerShell profile.

Layout Certificate Constraints

Currently the following constraints supported:

{
  "cert_constraints": [{
    "common_name": "write-code.example.com",
      "dns_names": [
        ""
      ],
      "emails": [
        ""
      ],
      "organizations": [
        "*"
      ],
      "roots": [
        "*"
      ],
      "uris": [
        "spiffe://example.com/write-code"
      ]
  }, {
    "uris": [],
    "common_names": ["Some User"]
  }]
}

Not (yet) supported

This golang implementation was focused on verification on admission controllers and kubectl plugins. As such, it focused on providing a strong, auditable set of core functions rather than a broad and (possibly) unstable feature set. In other words, we believe that the current feature set is stable enough for production use.

If any of these features are necessary for your use case please let us know and we will try to provide them as soon as possible!

Owner
in-toto
A framework to protect software supply chain integrity
in-toto
Comments
  • in-toto-run implementation

    in-toto-run implementation

    The following PR is part of the Google Summer of Code 2020 program

    Fixes issue #54: This PR intents to fix Issue #54

    Description of pull request: The goal of this PR is the in-toto-run implementation similar to our reference implementation in python.

    Please verify and check that the pull request fulfills the following requirements:

    • [X] Tests have been added for the bug fix or new feature
    • [X] Docs have been added for the bug fix or new feature
  • shibumi/exclude pattern fix 41

    shibumi/exclude pattern fix 41

    Note: This PR is based on PR #41, I couldn't work on the branch directly, because I am not a project maintainer, so I checkout out PR #41 and opened a new PR instead. With this approach we can still list @ayush159 as author for the code he wrote.

    EDIT: I rewrote everything from scratch

    I am right now working on:

    • adding documentation (The Apply... func is missing documentation. The func is being exported, so we should definitely add some docs for it)
    • Removing unnecessary things or improving error messages. For example:

    https://github.com/in-toto/in-toto-golang/pull/41/files#diff-73e399e3c84826b077d43cc4cbc98e7eR103

    Original PR description is below:

    Fixes issue #33:

    Description of pull request: Used go-git to implement gitignore style pattern parsing. Changed the signature of RecordArtifacts function in runlib.go . Added exclude pattern in method signature. If exclude patterns not available, pass nil.

    Please verify and check that the pull request fulfills the following requirements:

    • [x] Tests have been added for the bug fix or new feature
    • [x] Docs have been added for the bug fix or new feature
  • handle unhandled errors

    handle unhandled errors

    Please fill in the fields below to submit a pull request. The more information that is provided, the better.

    Fixes issue #:

    This is not yet related to an issue. Shall I open an issue for it?

    Description of pull request:

    This PR fixes a few golang linter warnings like unhandled errors. It's work in progress.

    Please verify and check that the pull request fulfills the following requirements:

    • [ ] Tests have been added for the bug fix or new feature
    • [ ] Docs have been added for the bug fix or new feature

    New tests shouldn't be necessary.

  • implement multi hash support

    implement multi hash support

    Fixes issue #:

    This PR is intended to fix: https://github.com/in-toto/in-toto-golang/issues/31 and https://github.com/in-toto/in-toto-golang/issues/67 and https://github.com/in-toto/in-toto-golang/issues/65

    It will maybe also provide different rsassa-pss schemes like: rsassa-pss-sha512

    Description of pull request: In this PR we remove our old hash implementation and use Go's hash.Hash interface instead. The goal is to use the new hashlib for all hash related tasks. We should be able to use this in RecordArtifact and in the keylib for generating hashes for example for rsassa-pss-sha256 or ecdsa-sha2-nistp384.

    Please verify and check that the pull request fulfills the following requirements:

    • [X] Tests have been added for the bug fix or new feature
    • [X] Docs have been added for the bug fix or new feature
  • implement symlink functionality with filepath.EvalSymlinks()

    implement symlink functionality with filepath.EvalSymlinks()

    Please fill in the fields below to submit a pull request. The more information that is provided, the better.

    Fixes issue #: https://github.com/in-toto/in-toto-golang/issues/32 as well as PR https://github.com/in-toto/in-toto-golang/pull/37

    Description of pull request: We are using filepath.EvalSymlinks() here, because it will give us the last element in a symlink chain. Therefore we don't need to worry about stack size or recursion cycles.

    Please verify and check that the pull request fulfills the following requirements:

    • [x] Tests have been added for the bug fix or new feature
    • [x] Docs have been added for the bug fix or new feature
  • Data structures for generalized link formats/ITE-6

    Data structures for generalized link formats/ITE-6

    Please fill in the fields below to submit a pull request. The more information that is provided, the better.

    Fixes issue #: Adds the data types for the generalized link format as described in this PR https://github.com/in-toto/ITE/pull/15 (ITE-6).

    Description of pull request: Only the data types are added in this PR. This includes the "Envelope", but not implementation for the serialization. I will work on the implementation for the SSL signing spec/ITE-5 in the coming weeks.

    Please verify and check that the pull request fulfills the following requirements:

    • [*] Tests have been added for the bug fix or new feature
    • [*] Docs have been added for the bug fix or new feature
  • ITE7 Prototype Implementation

    ITE7 Prototype Implementation

    This is a prototype implementation of ITE7 as drafted and proposed at: https://github.com/in-toto/ITE/pull/21

    • Adds the concept of certificate constraints. This allows layout creators to define the shape of a X509 certificate that is allowed to act as a functionary for each step of a layout.
    • Adds roots and intermediate CAs to the layout. This allows layout creators to define the chain of trust that a X509 certificate must fall within to act as a functionary.
    • Adds the leaf certificate to signatures. This will need to be updated to be compatible with DSSE if ITE5 is accepted into the specficiation.

    Please fill in the fields below to submit a pull request. The more information that is provided, the better.

    Fixes issue #:

    Description of pull request:

    Please verify and check that the pull request fulfills the following requirements:

    • [ ] Tests have been added for the bug fix or new feature
    • [ ] Docs have been added for the bug fix or new feature
  • Configure cobra using standard layout

    Configure cobra using standard layout

    This sets cobra up using the standard approach (the default when running cobra init)

    It's then easier to run the app with commands such as:

    go run main.go run

    Not hugely adamant this gets merged, but figured its worth putting up as quicker than an issue.

    Signed-off-by: Luke Hinds [email protected]

  • Add Github Actions Support

    Add Github Actions Support

    Fixes issue #: https://github.com/in-toto/in-toto-golang/issues/62

    Description of pull request: This PR intents to remove travis and appveyor as CI and use Github Actions for everything, what we need.

    Please verify and check that the pull request fulfills the following requirements:

    • [ ] Tests have been added for the bug fix or new feature
    • [ ] Docs have been added for the bug fix or new feature
  • feat: generate markdown documents for in-toto-golang

    feat: generate markdown documents for in-toto-golang

    Signed-off-by: Batuhan Apaydın [email protected]

    Fixes issue:

    Description:

    This is just a proof-of-concept PR.

    Thanks to @imjasonh amazing work he did on cosign project, and I thought I might be helpful for in-toto-golang CLI too, so I created this PR

    👉 https://github.com/sigstore/cosign/pull/839

    Please verify and check that the pull request fulfills the following requirements:

    • [ ] Tests have been added for the bug fix or new feature
    • [ ] Docs have been added for the bug fix or new feature

    cc: @shibumi @colek42

  • Exclude_pattern fix (Issue #33)

    Exclude_pattern fix (Issue #33)

    Please fill in the fields below to submit a pull request. The more information that is provided, the better.

    **Fixes issue #33 **:

    Description of pull request: Used go-git to implement gitignore style pattern parsing. Changed the signature of RecordArtifacts function in runlib.go . Added exclude pattern in method signature. If exclude patterns not available, pass nil.

    Please verify and check that the pull request fulfills the following requirements:

    • [ ] Tests have been added for the bug fix or new feature
    • [ ] Docs have been added for the bug fix or new feature
  • Fix handling of symlinks in artifact recording

    Fix handling of symlinks in artifact recording

    Signed-off-by: Aditya Sirish [email protected]

    Fixes issue:

    Related to #57, partially #191

    Description:

    • Records source path instead of destination path for symlinks
    • Adds explicit parameter to decide if symlinks to directories must be followed

    Please verify and check that the pull request fulfills the following requirements:

    • [ ] Tests have been added for the bug fix or new feature
    • [ ] Docs have been added for the bug fix or new feature
  • non unique dictionary key error

    non unique dictionary key error

    General information:

    main linux 1.19.1

    failed to create link metadata: left stripping has resulted in non unique dictionary key: /node_modules/@actions/tool-cache/node_modules/uuid/bin/uuid

    When testing the in-toto run action we run into the above error when calculating the materials for thejob.

  • Add version/SHA to provevanceBuilder

    Add version/SHA to provevanceBuilder

    The provenance builder contains only an ID field, see https://github.com/in-toto/in-toto-golang/blob/master/in_toto/slsa_provenance/v0.2/provenance.go#L22)](https://github.com/in-toto/in-toto-golang/blob/master/in_toto/slsa_provenance/v0.2/provenance.go#L22

    It would be beneficial to add a Version and a Digest field, because the builder itself needs to be identified uniquely.

    An alternative would be to use ID=theID:version@hash. I don't think this is a good approach because it treats the builder differently from the rest of he provenance information (ConfigSource contains a digest, for example)

    One may ask why we need a version if we have a hash. Versions are useful during verification of the provenance: based on a the version, the verifier can adjust its logic/verification. Hashes don't allow to do this easily.

    Maybe I'm misunderstanding the purpose of provenanceBuilder, and the intention may be to put the data I'm after inside ConfigSource? (which does not contain a version field either).

    Note: my use case is a build using a GitHub action on GitHub. The builder is the action (which has a version and a hash).

    cc @asraa

  • Provide examples to each major in-toto cli subcommand

    Provide examples to each major in-toto cli subcommand

    According to the Cobra documentation, Cobra supports examples. I think we should use these example strings for making in-toto easier to use. This might be something for @alanssitis. Do you want to have a look? :)

  • feat: use-dsse flag add to run command

    feat: use-dsse flag add to run command

    Signed-off-by: Batuhan Apaydın [email protected]

    Fixes issue:

    Fixes #148

    Description:

    If I did something wrong, I want to apologize in advance, but I wanted to do something, at least I wanted to start somewhere 🧑🏻‍💻🔮

    Please verify and check that the pull request fulfills the following requirements:

    • [ ] Tests have been added for the bug fix or new feature
    • [ ] Docs have been added for the bug fix or new feature
  • Allow generating in-toto links using DSSE

    Allow generating in-toto links using DSSE

    Description of the feature request:

    in-toto-golang should include a user-specified option that controls if the link metadata generated uses the current legacy signature wrapper or DSSE. The library should also be able to load these links and verify them. in-toto can use https://github.com/secure-systems-lab/go-securesystemslib for the DSSE provider.

XT Smart Chain, a chain based on the go-ethereum fork

XT Smart Chain XT Smart Chain (XSC) is a decentralized, high-efficiency and ener

Dec 28, 2022
Berylbit PoW chain using Ethash, EPI-Burn and geth. The chain will be using bot congestion flashbot bundles through nodes

Berylbit PoW chain using Ethash, EPI-Burn and geth. The chain will be using bot congestion flashbot bundles through nodes. Soon, We will work towards

Jun 30, 2022
Go-chain - EVM-compatible chain secured by the Lachesis consensus algorithm

ICICB galaxy EVM-compatible chain secured by the Lachesis consensus algorithm. B

Jun 8, 2022
Koisan-chain - Official Golang implementation of the Koisan protocol

Go Ethereum Official Golang implementation of the Koisan protocol. Building the

Feb 6, 2022
Kava - Reference implementation of Kava, a blockchain for cross-chain DeFi. Built using the cosmos-sdk

DeFi for Crypto. Telegram | Medium | Discord Reference implementation of Kava, a

Apr 4, 2022
Go language implementation of a blockchain based on the BDLS BFT protocol. The implementation was adapted from Ethereum and Sperax implementation

BDLS protocol based PoS Blockchain Most functionalities of this client is similar to the Ethereum golang implementation. If you do not find your quest

Oct 14, 2022
Huobi Eco Chain client based on the go-ethereum fork

The Huobi Open Platform is a unified infrastructure platform based on the technical, traffic and ecological resources of the Huobi Group, and will be gradually open to the blockchain industry.

Dec 31, 2022
Moeing chain is an EVM&Web3 compatible sidechain for Bitcoin Cash

Full node client of smartBCH This repository contains the code of the full node client of smartBCH, an EVM&Web3 compatible sidechain for Bitcoin Cash.

Nov 29, 2022
Cryptographic Addition Chain Generation in Go

Cryptographic Addition Chain Generation in Go addchain generates short addition chains for exponents of cryptographic interest with results rivaling t

Dec 5, 2022
Yet another Binance Smart Chain client based on TrustFi Network

TrustFi Smart Chain The goal of TrustFi Smart Chain is to bring programmability and interoperability to Binance Chain. In order to embrace the existin

Mar 27, 2021
A Binance Chain vanity address generator written in golang.
A Binance Chain vanity address generator written in golang.

VaniBNB A Binance Chain vanity address generator written in golang. For example address ending with 0xkat Raw https://github.com/makevoid/vanieth http

Sep 9, 2022
Frontier Chain is a blockchain application built using Cosmos SDK and Tendermint.

Frontier Chain Frontier Chain is a blockchain application built using Cosmos SDK and Tendermint. Setup Initialize the blockchain with one validator no

Jul 12, 2022
Dump BitClout chain data into MongoDB

mongodb-dumper mongodb-dumper runs a full BitClout node and dumps the chain data into a MongoDB database Build Running the following commands will cre

Nov 30, 2022
A phoenix Chain client based on the go-ethereum fork,the new PoA consensus engine is based on the VRF algorithm.

Phoenix Official Golang implementation of the Phoenix protocol. !!!The current version is for testing and developing purposes only!!! Building the sou

Apr 28, 2022
Rei chain fork from quorum using raft consensus
Rei chain fork from quorum using raft consensus

GoQuorum is an Ethereum-based distributed ledger protocol with transaction/contract privacy and new consensus mechanisms. GoQuorum is a fork of go-eth

Aug 8, 2022
A markov chain for Discord message dumps using https://github.com/fr3fou/polo

discord-markov-chain A markov chain for Discord message dumps using https://github.com/fr3fou/polo Download If you have a go installed, just clone the

Oct 28, 2022
A Binance Smart Chain client based on the go-ethereum fork

A Binance Smart Chain client based on the go-ethereum fork

Dec 31, 2022
Create chain for application built using starport.

test test is a blockchain built using Cosmos SDK and Tendermint and created with Starport. Get started starport chain serve serve command installs de

Dec 8, 2021
A Binance Smart Chain client based on the erigon fork

Erigon Erigon is an implementation of Ethereum (aka "Ethereum client"), on the efficiency frontier, written in Go. System Requirements Usage Getting S

Sep 17, 2022