mirror of https://github.com/waku-org/nwaku.git
fix(archive): dburl check (#2071)
* dburl.nim: simpler regex that can support db_urls with . and - in hostname * dbrul.nim: accepting any non-empty sequence for user and password * dburl.nim: skipping validation for 'sqlite' db paths
This commit is contained in:
parent
1763b1efa1
commit
a27d005ffc
|
@ -509,18 +509,6 @@ proc parseCmdArg*(T: type Option[uint], p: string): T =
|
|||
except CatchableError:
|
||||
raise newException(ValueError, "Invalid unsigned integer")
|
||||
|
||||
## Configuration validation
|
||||
|
||||
let DbUrlRegex = re"^[\w\+]+:\/\/[\w\/\\\.\:\@]+$"
|
||||
|
||||
proc validateDbUrl*(val: string): ConfResult[string] =
|
||||
let val = val.strip()
|
||||
|
||||
if val == "" or val == "none" or val.match(DbUrlRegex):
|
||||
ok(val)
|
||||
else:
|
||||
err("invalid 'db url' option format: " & val)
|
||||
|
||||
## Load
|
||||
|
||||
proc readValue*(r: var TomlReader, value: var crypto.PrivateKey) {.raises: [SerializationError].} =
|
||||
|
|
|
@ -7,9 +7,9 @@ import
|
|||
proc validateDbUrl*(dbUrl: string): Result[string, string] =
|
||||
## dbUrl mimics SQLAlchemy Database URL schema
|
||||
## See: https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls
|
||||
let regex = re"^[\w\+]+:\/\/[\w\/\\\.\:\@]+$"
|
||||
let regex = re"^\w+:\/\/.+:.+@[\w*-.]+:[0-9]+\/[\w*-.]+$"
|
||||
let dbUrl = dbUrl.strip()
|
||||
if dbUrl == "" or dbUrl == "none" or dbUrl.match(regex):
|
||||
if "sqlite" in dbUrl or dbUrl == "" or dbUrl == "none" or dbUrl.match(regex):
|
||||
return ok(dbUrl)
|
||||
else:
|
||||
return err("invalid 'db url' option format: " & dbUrl)
|
||||
|
|
Loading…
Reference in New Issue