Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3509217
D4467.id14416.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4467.id14416.diff
View Options
diff --git a/services/lib/src/GlobalTools.h b/services/lib/src/GlobalTools.h
--- a/services/lib/src/GlobalTools.h
+++ b/services/lib/src/GlobalTools.h
@@ -19,6 +19,8 @@
std::string generateUUID();
+bool validateUUIDv4(const std::string &uuid);
+
} // namespace tools
} // namespace network
} // namespace comm
diff --git a/services/lib/src/GlobalTools.cpp b/services/lib/src/GlobalTools.cpp
--- a/services/lib/src/GlobalTools.cpp
+++ b/services/lib/src/GlobalTools.cpp
@@ -1,5 +1,6 @@
#include "GlobalTools.h"
+#include <glog/logging.h>
#include <openssl/sha.h>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
@@ -7,6 +8,7 @@
#include <chrono>
#include <iomanip>
+#include <regex>
#include <string>
namespace comm {
@@ -43,6 +45,19 @@
return boost::uuids::to_string(random_generator());
}
+bool validateUUIDv4(const std::string &uuid) {
+ const std::regex uuidV4RegexFormat(
+ "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$",
+ std::regex_constants::icase);
+ try {
+ return std::regex_match(uuid, uuidV4RegexFormat);
+ } catch (const std::exception &e) {
+ LOG(ERROR) << "Tools: "
+ << "Got an exception at `validateUUID`: " << e.what();
+ return false;
+ }
+}
+
} // namespace tools
} // namespace network
} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 2:35 AM (19 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690221
Default Alt Text
D4467.id14416.diff (1 KB)
Attached To
Mode
D4467: [services] Tunnelbroker - Introduce `validateUUIDv4` function
Attached
Detach File
Event Timeline
Log In to Comment