Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to use in-toto/go-witness module #330

Closed
Closed
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
8 changes: 4 additions & 4 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"
"github.com/testifysec/witness/options"
)

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
8 changes: 4 additions & 4 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"
"github.com/testifysec/witness/options"
)

// signerProvidersFromFlags looks at all flags that were set by the user to determine which signer providers we should use
Expand Down
8 changes: 3 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ 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"
"github.com/testifysec/witness/options"
)

var (
ro = &options.RootOptions{}
)
var ro = &options.RootOptions{}

func New() *cobra.Command {
cmd := &cobra.Command{
Expand Down
12 changes: 5 additions & 7 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"
"github.com/testifysec/witness/options"
)

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

}
25 changes: 12 additions & 13 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"
"github.com/testifysec/witness/options"
)

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
10 changes: 5 additions & 5 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"
"github.com/testifysec/witness/options"
)

func TestRunRSAKeyPair(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 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"
"github.com/testifysec/witness/options"
)

func SignCmd() *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions 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"
"github.com/testifysec/witness/options"
)

func Test_runSignPolicyRSA(t *testing.T) {
Expand Down
17 changes: 7 additions & 10 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"
"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"
"github.com/testifysec/witness/options"
)

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

}
18 changes: 8 additions & 10 deletions cmd/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"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"
"github.com/testifysec/witness/options"
)

func TestRunVerifyCA(t *testing.T) {
Expand Down Expand Up @@ -313,7 +313,7 @@
}

p := policy.Policy{
Expires: time.Now().Add(1 * time.Hour),

Check failure on line 316 in cmd/verify_test.go

View workflow job for this annotation

GitHub Actions / unit-test / witness

cannot use time.Now().Add(1 * time.Hour) (value of type time.Time) as v1.Time value in struct literal
PublicKeys: map[string]policy.PublicKey{},
Steps: map[string]policy.Step{},
}
Expand All @@ -327,9 +327,7 @@
p.Steps[step02.Name] = step02

if publicKey.KeyID != "" {

p.PublicKeys[publicKey.KeyID] = publicKey

}

pb, err := json.MarshalIndent(p, "", " ")
Expand Down
2 changes: 1 addition & 1 deletion docgen/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"flag"
"log"

"github.com/in-toto/witness/cmd"
"github.com/spf13/cobra/doc"
"github.com/testifysec/witness/cmd"
)

var directory string
Expand Down
Loading
Loading