Use random job and snapshot IDs

Timestamp-derived IDs were guessable, and the ID is what grants access
to indexed source. crypto/rand.Text gives 26 base32 characters.
This commit is contained in:
Andy Dixon
2026-02-07 12:18:26 +00:00
parent 981ec88f43
commit d8d4a77ba7
+3 -4
View File
@@ -3,6 +3,7 @@ package main
import (
"bufio"
"bytes"
"crypto/rand"
"embed"
"encoding/json"
"errors"
@@ -19,7 +20,6 @@ import (
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
"unicode/utf8"
)
@@ -620,10 +620,9 @@ func safeRelativePath(value string) (string, bool) {
return filepath.Join(clean...), true
}
var idCounter atomic.Uint64
// uniqueID is unguessable: IDs are the capability that grants access to a job or snapshot.
func uniqueID(prefix string) string {
return fmt.Sprintf("%s-%x%x", prefix, time.Now().UnixNano(), idCounter.Add(1))
return prefix + "-" + rand.Text()
}
func writeError(w http.ResponseWriter, status int, message string) {