Skip to content

Commit a27d005

Browse files
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
1 parent 1763b1e commit a27d005

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

apps/wakunode2/external_config.nim

-12
Original file line numberDiff line numberDiff line change
@@ -509,18 +509,6 @@ proc parseCmdArg*(T: type Option[uint], p: string): T =
509509
except CatchableError:
510510
raise newException(ValueError, "Invalid unsigned integer")
511511

512-
## Configuration validation
513-
514-
let DbUrlRegex = re"^[\w\+]+:\/\/[\w\/\\\.\:\@]+$"
515-
516-
proc validateDbUrl*(val: string): ConfResult[string] =
517-
let val = val.strip()
518-
519-
if val == "" or val == "none" or val.match(DbUrlRegex):
520-
ok(val)
521-
else:
522-
err("invalid 'db url' option format: " & val)
523-
524512
## Load
525513

526514
proc readValue*(r: var TomlReader, value: var crypto.PrivateKey) {.raises: [SerializationError].} =

waku/common/databases/dburl.nim

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import
77
proc validateDbUrl*(dbUrl: string): Result[string, string] =
88
## dbUrl mimics SQLAlchemy Database URL schema
99
## See: https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls
10-
let regex = re"^[\w\+]+:\/\/[\w\/\\\.\:\@]+$"
10+
let regex = re"^\w+:\/\/.+:.+@[\w*-.]+:[0-9]+\/[\w*-.]+$"
1111
let dbUrl = dbUrl.strip()
12-
if dbUrl == "" or dbUrl == "none" or dbUrl.match(regex):
12+
if "sqlite" in dbUrl or dbUrl == "" or dbUrl == "none" or dbUrl.match(regex):
1313
return ok(dbUrl)
1414
else:
1515
return err("invalid 'db url' option format: " & dbUrl)

0 commit comments

Comments
 (0)