Be more strict with schema validation

This commit is contained in:
Jon Staab
2026-04-02 13:40:38 -07:00
parent cc6a7667cc
commit 35fa254d1b
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
"path/filepath"
"regexp"
"strings"
"fiatjaf.com/nostr"
@@ -285,6 +286,9 @@ func (api *APIHandler) validatePatchedConfig(config *Config) error {
if config.Schema == "" {
return fmt.Errorf("schema is required")
}
if !regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*$`).MatchString(config.Schema) {
return fmt.Errorf("schema must contain only letters, numbers, and underscores")
}
if config.Secret == "" {
return fmt.Errorf("secret is required")
}
+1 -1
View File
@@ -122,7 +122,7 @@ func MakeInstance(filename string) (*Instance, error) {
// Initialize the database
if err := instance.Events.Init(); err != nil {
log.Fatal("Failed to initialize event store: ", err)
log.Fatal("Failed to initialize event store for ", filename, ": ", err)
}
// Enable extra functionality