aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/storage/buildstore
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-02-04 13:20:20 +0100
committerGitHub Enterprise <[email protected]>2026-02-04 13:20:20 +0100
commit05108dad394952733838daf442ffdd553a62b727 (patch)
tree8fd64eb6ba26e93da5b1a165750a9f7ad2fc67de /src/zenserver/storage/buildstore
parentimplemented chunking for TransmitFile path (#736) (diff)
downloadzen-05108dad394952733838daf442ffdd553a62b727.tar.xz
zen-05108dad394952733838daf442ffdd553a62b727.zip
use matcher over regex (#744)
* replace http router AddPattern with AddMatcher * fix scrub logging
Diffstat (limited to 'src/zenserver/storage/buildstore')
-rw-r--r--src/zenserver/storage/buildstore/httpbuildstore.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/zenserver/storage/buildstore/httpbuildstore.cpp b/src/zenserver/storage/buildstore/httpbuildstore.cpp
index 18fae7027..f5ba30616 100644
--- a/src/zenserver/storage/buildstore/httpbuildstore.cpp
+++ b/src/zenserver/storage/buildstore/httpbuildstore.cpp
@@ -48,10 +48,20 @@ HttpBuildStoreService::Initialize()
{
ZEN_LOG_INFO(LogBuilds, "Initializing Builds Service");
- m_Router.AddPattern("namespace", "([[:alnum:]\\-_.]+)");
- m_Router.AddPattern("bucket", "([[:alnum:]\\-_.]+)");
- m_Router.AddPattern("buildid", "([[:xdigit:]]{24})");
- m_Router.AddPattern("hash", "([[:xdigit:]]{40})");
+ static constexpr AsciiSet ValidNamespaceCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789-_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
+ static constexpr AsciiSet ValidBucketCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789-_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
+ static constexpr AsciiSet ValidHexCharactersSet{"0123456789abcdefABCDEF"};
+
+ m_Router.AddMatcher("namespace",
+ [](std::string_view Str) -> bool { return !Str.empty() && AsciiSet::HasOnly(Str, ValidNamespaceCharactersSet); });
+ m_Router.AddMatcher("bucket",
+ [](std::string_view Str) -> bool { return !Str.empty() && AsciiSet::HasOnly(Str, ValidBucketCharactersSet); });
+ m_Router.AddMatcher("buildid", [](std::string_view Str) -> bool {
+ return Str.length() == Oid::StringLength && AsciiSet::HasOnly(Str, ValidHexCharactersSet);
+ });
+ m_Router.AddMatcher("hash", [](std::string_view Str) -> bool {
+ return Str.length() == IoHash::StringLength && AsciiSet::HasOnly(Str, ValidHexCharactersSet);
+ });
m_Router.RegisterRoute(
"{namespace}/{bucket}/{buildid}/blobs/{hash}",