Skip to content

Commit

Permalink
migrating to in-toto/go-witness
Browse files Browse the repository at this point in the history
Signed-off-by: chaosinthecrd <[email protected]>
  • Loading branch information
ChaosInTheCRD committed Dec 15, 2023
1 parent c7e725e commit b5d9aed
Show file tree
Hide file tree
Showing 15 changed files with 366 additions and 121 deletions.
6 changes: 3 additions & 3 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"os"
"strings"

"github.com/in-toto/go-witness/log"
"github.com/in-toto/witness/options"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"github.com/testifysec/go-witness/log"
)

func initConfig(rootCmd *cobra.Command, rootOptions *options.RootOptions) error {
Expand All @@ -47,10 +47,10 @@ func initConfig(rootCmd *cobra.Command, rootOptions *options.RootOptions) error
return fmt.Errorf("failed to read config file: %w", err)
}

//Currently we do not accept configuration for root commands
// Currently we do not accept configuration for root commands
commands := rootCmd.Commands()
for _, cm := range commands {
//Check which command we are running
// Check which command we are running
if !contains(os.Args, cm.Name()) {
continue
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/keyloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"fmt"
"strings"

"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/log"
"github.com/in-toto/go-witness/signer"
"github.com/in-toto/witness/options"
"github.com/spf13/pflag"
"github.com/testifysec/go-witness/cryptoutil"
"github.com/testifysec/go-witness/log"
"github.com/testifysec/go-witness/signer"
)

// signerProvidersFromFlags looks at all flags that were set by the user to determine which signer providers we should use
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"fmt"
"os"

"github.com/in-toto/go-witness/log"
"github.com/in-toto/witness/options"
"github.com/spf13/cobra"
"github.com/testifysec/go-witness/log"
)

var ro = &options.RootOptions{}
Expand Down
10 changes: 4 additions & 6 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"testing"
"time"

"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/signer"
"github.com/in-toto/go-witness/signer/file"
"github.com/in-toto/witness/options"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/testifysec/go-witness/cryptoutil"
"github.com/testifysec/go-witness/signer"
"github.com/testifysec/go-witness/signer/file"
)

const (
Expand Down Expand Up @@ -148,7 +148,6 @@ func rsakeypair(t *testing.T) (privatePem *os.File, publicPem *os.File) {
}

return privatePem, publicPem

}

// ref: https://jamielinux.com/docs/openssl-certificate-authority/appendix/intermediate-configuration-file.html
Expand Down Expand Up @@ -189,7 +188,7 @@ func fullChain(t *testing.T) (caPem *os.File, intermediatePems []*os.File, leafP
t.Fatal(err)
}

//common name must be different than the CA name
// common name must be different than the CA name
intermediate := &x509.Certificate{
SerialNumber: big.NewInt(43),
Subject: pkix.Name{
Expand Down Expand Up @@ -272,5 +271,4 @@ func fullChain(t *testing.T) (caPem *os.File, intermediatePems []*os.File, leafP
}

return caPem, intermediatePems, leafPem, leafkeyPem

}
23 changes: 11 additions & 12 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ import (
"encoding/json"
"fmt"

witness "github.com/in-toto/go-witness"
"github.com/in-toto/go-witness/archivista"
"github.com/in-toto/go-witness/attestation"
"github.com/in-toto/go-witness/attestation/commandrun"
"github.com/in-toto/go-witness/attestation/material"
"github.com/in-toto/go-witness/attestation/product"
"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/dsse"
"github.com/in-toto/go-witness/log"
"github.com/in-toto/go-witness/registry"
"github.com/in-toto/go-witness/timestamp"
"github.com/in-toto/witness/options"
"github.com/spf13/cobra"
witness "github.com/testifysec/go-witness"
"github.com/testifysec/go-witness/archivista"
"github.com/testifysec/go-witness/attestation"
"github.com/testifysec/go-witness/attestation/commandrun"
"github.com/testifysec/go-witness/attestation/material"
"github.com/testifysec/go-witness/attestation/product"
"github.com/testifysec/go-witness/cryptoutil"
"github.com/testifysec/go-witness/dsse"
"github.com/testifysec/go-witness/log"
"github.com/testifysec/go-witness/registry"
"github.com/testifysec/go-witness/timestamp"
)

func RunCmd() *cobra.Command {
Expand Down Expand Up @@ -120,7 +120,6 @@ func runRun(ctx context.Context, ro options.RunOptions, args []string, signers .
witness.RunWithAttestationOpts(attestation.WithWorkingDir(ro.WorkingDir), attestation.WithHashes(roHashes)),
witness.RunWithTimestampers(timestampers...),
)

if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import (
"path/filepath"
"testing"

"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/dsse"
"github.com/in-toto/go-witness/signer"
"github.com/in-toto/go-witness/signer/file"
"github.com/in-toto/witness/options"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/testifysec/go-witness/cryptoutil"
"github.com/testifysec/go-witness/dsse"
"github.com/testifysec/go-witness/signer"
"github.com/testifysec/go-witness/signer/file"
)

func TestRunRSAKeyPair(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions cmd/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
"fmt"
"os"

witness "github.com/in-toto/go-witness"
"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/dsse"
"github.com/in-toto/go-witness/timestamp"
"github.com/in-toto/witness/options"
"github.com/spf13/cobra"
witness "github.com/testifysec/go-witness"
"github.com/testifysec/go-witness/cryptoutil"
"github.com/testifysec/go-witness/dsse"
"github.com/testifysec/go-witness/timestamp"
)

func SignCmd() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cmd/sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"os"
"testing"

"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/witness/options"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/testifysec/go-witness/cryptoutil"
)

func Test_runSignPolicyRSA(t *testing.T) {
Expand Down
15 changes: 6 additions & 9 deletions cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (
"fmt"
"os"

witness "github.com/in-toto/go-witness"
"github.com/in-toto/go-witness/archivista"
"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/dsse"
"github.com/in-toto/go-witness/log"
"github.com/in-toto/go-witness/source"
"github.com/in-toto/witness/options"
"github.com/spf13/cobra"
witness "github.com/testifysec/go-witness"
"github.com/testifysec/go-witness/archivista"
"github.com/testifysec/go-witness/cryptoutil"
"github.com/testifysec/go-witness/dsse"
"github.com/testifysec/go-witness/log"
"github.com/testifysec/go-witness/source"
)

func VerifyCmd() *cobra.Command {
Expand Down Expand Up @@ -125,10 +125,8 @@ func runVerify(ctx context.Context, vo options.VerifyOptions) error {
witness.VerifyWithSubjectDigests(subjects),
witness.VerifyWithCollectionSource(collectionSource),
)

if err != nil {
return fmt.Errorf("failed to verify policy: %w", err)

}

log.Info("Verification succeeded")
Expand All @@ -142,5 +140,4 @@ func runVerify(ctx context.Context, vo options.VerifyOptions) error {
}

return nil

}
16 changes: 7 additions & 9 deletions cmd/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import (
"testing"
"time"

witness "github.com/in-toto/go-witness"
"github.com/in-toto/go-witness/attestation/commandrun"
"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/dsse"
"github.com/in-toto/go-witness/policy"
"github.com/in-toto/go-witness/signer"
"github.com/in-toto/go-witness/signer/file"
"github.com/in-toto/witness/options"
"github.com/stretchr/testify/require"
witness "github.com/testifysec/go-witness"
"github.com/testifysec/go-witness/attestation/commandrun"
"github.com/testifysec/go-witness/cryptoutil"
"github.com/testifysec/go-witness/dsse"
"github.com/testifysec/go-witness/policy"
"github.com/testifysec/go-witness/signer"
"github.com/testifysec/go-witness/signer/file"
)

func TestRunVerifyCA(t *testing.T) {
Expand Down Expand Up @@ -327,9 +327,7 @@ func makepolicy(t *testing.T, functionary policy.Functionary, publicKey policy.P
p.Steps[step02.Name] = step02

if publicKey.KeyID != "" {

p.PublicKeys[publicKey.KeyID] = publicKey

}

pb, err := json.MarshalIndent(p, "", " ")
Expand Down
Loading

0 comments on commit b5d9aed

Please sign in to comment.