Skip to content

Commit

Permalink
change default value for rekor_server.hostname to server's hostname (#…
Browse files Browse the repository at this point in the history
…963)

* change default server hostname away from rekor.sigstore.dev
* add e2e test

Signed-off-by: Bob Callaway <bcallaway@google.com>
  • Loading branch information
bobcallaway committed Aug 10, 2022
1 parent 0140a44 commit 921c478
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/rekor-server/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ func init() {
rootCmd.PersistentFlags().Uint("trillian_log_server.tlog_id", 0, "Trillian tree id")
rootCmd.PersistentFlags().String("trillian_log_server.sharding_config", "", "path to config file for inactive shards")

rootCmd.PersistentFlags().String("rekor_server.hostname", "rekor.sigstore.dev", "public hostname of instance")
hostname, err := os.Hostname()
if err != nil {
hostname = "localhost"
}
rootCmd.PersistentFlags().String("rekor_server.hostname", hostname, "public hostname of instance")
rootCmd.PersistentFlags().String("rekor_server.address", "127.0.0.1", "Address to bind to")
rootCmd.PersistentFlags().String("rekor_server.signer", "memory", "Rekor signer to use. Current valid options include: [gcpkms, memory]")

Expand Down
23 changes: 23 additions & 0 deletions tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"fmt"
"golang.org/x/sync/errgroup"
"io/ioutil"
"net/http"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -835,3 +836,25 @@ func TestInclusionProofRace(t *testing.T) {
t.Fatal(err)
}
}

func TestHostnameInSTH(t *testing.T) {
// get ID of container
rekorContainerID := strings.Trim(run(t, "", "docker", "ps", "-q", "-f", "name=rekor-server"), "\n")
resp, err := http.Get("http://localhost:3000/api/v1/log")
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}

if !strings.Contains(string(body), fmt.Sprintf(" %s ", rekorContainerID)) {
t.Errorf("logInfo does not contain the hostname (%v) of the rekor-server container: %v", rekorContainerID, string(body))
}
if strings.Contains(string(body), "rekor.sigstore.dev") {
t.Errorf("logInfo contains rekor.sigstore.dev which should not be set by default")
}
}

0 comments on commit 921c478

Please sign in to comment.