diff --git a/cmd/rekor-server/app/root.go b/cmd/rekor-server/app/root.go index 579bd2544..4d60922e9 100644 --- a/cmd/rekor-server/app/root.go +++ b/cmd/rekor-server/app/root.go @@ -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]") diff --git a/tests/e2e_test.go b/tests/e2e_test.go index 7e67d9272..eab4e85a7 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -32,6 +32,7 @@ import ( "fmt" "golang.org/x/sync/errgroup" "io/ioutil" + "net/http" "os" "os/exec" "path/filepath" @@ -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") + } +}