From 0760a0b3fb2be31baac4a1ab1f0086ad2df00843 Mon Sep 17 00:00:00 2001 From: Martin Hutchinson Date: Thu, 9 Apr 2026 10:50:27 +0000 Subject: [PATCH] [GCP Docs] Document how to add new logs to a witness This wasn't covered explicitly and required knowledge of generating the correct log ID. In the interests of this being easier for the next person, here's the script I used to generate the inserts. --- cmd/omniwitness_gcp/README.md | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/cmd/omniwitness_gcp/README.md b/cmd/omniwitness_gcp/README.md index f3b35123..ddb81767 100644 --- a/cmd/omniwitness_gcp/README.md +++ b/cmd/omniwitness_gcp/README.md @@ -69,3 +69,56 @@ export SECRET="projects/..." # This is the secret manager secret name. go run ./cmd/omniwitness_gcp/ --signer_private_key_secret_name=${SECRET} --spanner=${SPANNER} ``` +## Operations + +### Adding a new log + +To add a new log configuration to a running witness, you can insert a row directly into the Spanner `logs` table. Since the persistence layer requires a deterministic `logID` derived from the log's origin, you can use the following standalone Go program to generate the exact `INSERT` statement to execute in Spanner Studio. + +Either save and run this snippet locally, or use https://go.dev/play/ to generate the SQL. + +```go +package main + +import ( + "fmt" + + "github.com/transparency-dev/formats/log" +) + +func main() { + // Edit these parameters for the log you wish to add: + origin := "vindex.gopherwatch.org" + vkey := "vindex.gopherwatch.org+af4f4f3a+AYlEp21ErzmKZa+aqhjC8BQteyEtsVwmLzblkzHxn8et" + contact := "admin@gopherwatch.org" + qpd := 86400.0 + disabled := false + + fmt.Println(generateInsert(origin, vkey, contact, qpd, disabled)) +} + +func generateInsert(origin, vkey, contact string, qpd float64, disabled bool) string { + id := log.ID(origin) + + contactVal := "NULL" + if contact != "" { + contactVal = fmt.Sprintf("'%s'", contact) + } + + qpdVal := "NULL" + if qpd > 0 { + qpdVal = fmt.Sprintf("%f", qpd) + } + + return fmt.Sprintf(`INSERT INTO logs (logID, origin, vkey, contact, qpd, disabled) +VALUES ( + '%s', + '%s', + '%s', + %s, + %s, + %t +);`, id, origin, vkey, contactVal, qpdVal, disabled) +} +``` +