forked from coracle/zooid
Be more strict with schema validation
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
@@ -285,6 +286,9 @@ func (api *APIHandler) validatePatchedConfig(config *Config) error {
|
|||||||
if config.Schema == "" {
|
if config.Schema == "" {
|
||||||
return fmt.Errorf("schema is required")
|
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 == "" {
|
if config.Secret == "" {
|
||||||
return fmt.Errorf("secret is required")
|
return fmt.Errorf("secret is required")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -122,7 +122,7 @@ func MakeInstance(filename string) (*Instance, error) {
|
|||||||
// Initialize the database
|
// Initialize the database
|
||||||
|
|
||||||
if err := instance.Events.Init(); err != nil {
|
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
|
// Enable extra functionality
|
||||||
|
|||||||
Reference in New Issue
Block a user