Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2025 Carabiner Systems, Inc
# SPDX-FileCopyrightText: Copyright 2025 The SLSA Authors
# SPDX-License-Identifier: Apache-2.0
---
version: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
# SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
# SPDX-License-Identifier: Apache-2.0

name: go-tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
# SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
# SPDX-License-Identifier: Apache-2.0

name: golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
# SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
# SPDX-License-Identifier: Apache-2.0

name: release
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2025 Carabiner Systems, Inc
# SPDX-FileCopyrightText: Copyright 2025 The SLSA Authors
# SPDX-License-Identifier: Apache-2.0
---
version: "2"
Expand Down
4 changes: 3 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
# SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
# SPDX-License-Identifier: Apache-2.0

project_name: slsa-verifier
Expand Down Expand Up @@ -35,6 +35,8 @@ builds:
goarch: amd64
flags:
- -trimpath
ldflags:
- -X github.com/slsa-framework/verifier/internal/cmd.version={{ .Tag }}

archives:
- formats: binary
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/build.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/build_builders_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/build_keyless_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/build_level_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/build_subjects_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/emitvsa.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/emitvsa_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/load.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_builders.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_builders_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_controls.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_param.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_param_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_shared.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_signing.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_signing_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_subject.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_subject_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/options_vsaoutput.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/printer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/printer_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
21 changes: 20 additions & 1 deletion internal/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand All @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"os"
"runtime/debug"

"github.com/spf13/cobra"
)
Expand All @@ -25,6 +26,23 @@ var ErrVerifyFailed = errors.New("attestation verification failed")

const appname = "slsa-verifier"

// version is the release this binary was built from. Releases set it at
// build time (-ldflags, see .goreleaser.yaml); a binary built with
// `go install module@version` reads it from the module information instead,
// and anything else reports "devel".
var version = "devel"

// resolvedVersion is what --version prints.
func resolvedVersion() string {
if version != "devel" {
return version
}
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" && info.Main.Version != "(devel)" {
return info.Main.Version
}
return version
}

var rootCmd = &cobra.Command{
Short: fmt.Sprintf("%s: verify SLSA build and source attestations", appname),
Long: fmt.Sprintf(`
Expand All @@ -33,6 +51,7 @@ attestations against the SLSA spec-defined controls and any user-supplied
controls.
`, appname),
Use: appname,
Version: resolvedVersion(),
SilenceUsage: false,
SilenceErrors: true,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/select_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/source.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/source_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
45 changes: 45 additions & 0 deletions internal/cmd/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
"strings"
"testing"
)

func TestResolvedVersion(t *testing.T) {
t.Cleanup(func() { version = "devel" })

// A release build stamps the version, which wins over anything else.
version = "v1.2.3"
if got := resolvedVersion(); got != "v1.2.3" {
t.Errorf("stamped: resolvedVersion() = %q", got)
}

// Without a stamp the module information decides; in a test binary it
// carries no release, so the result is "devel" or whatever the module
// reports, never empty or the placeholder "(devel)".
version = "devel"
got := resolvedVersion()
if got == "" || got == "(devel)" {
t.Errorf("unstamped: resolvedVersion() = %q", got)
}
}

func TestVersionFlag(t *testing.T) {
t.Cleanup(func() { version = "devel" })
version = "v1.2.3"
rootCmd.Version = resolvedVersion()

var out strings.Builder
rootCmd.SetOut(&out)
rootCmd.SetArgs([]string{"--version"})
t.Cleanup(func() { rootCmd.SetArgs(nil) })
if err := rootCmd.Execute(); err != nil {
t.Fatal(err)
}
if !strings.Contains(out.String(), "slsa-verifier version v1.2.3") {
t.Errorf("--version printed %q", out.String())
}
}
2 changes: 1 addition & 1 deletion internal/cmd/vsa.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/vsa_registry_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/vsa_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package main
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/identity.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/identity_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/levels.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/levels_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/load_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/select.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/select_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/signatures.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/signatures_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/source.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/source_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

// Package attestation provides a Verifier object that orchestrates
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/verifier.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/vsa.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
2 changes: 1 addition & 1 deletion pkg/attestation/vsa_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
// SPDX-FileCopyrightText: Copyright 2026 The SLSA Authors
// SPDX-License-Identifier: Apache-2.0

package attestation
Expand Down
Loading
Loading