Page MenuHomePhabricator

[services] Tunnelbroker - Introduce `validateUUIDv4` function
ClosedPublic

Authored by max on Jul 7 2022, 4:33 AM.
Tags
None
Referenced Files
F2205676: D4467.id14525.diff
Sat, Jul 6, 11:14 PM
F2205675: D4467.id14249.diff
Sat, Jul 6, 11:14 PM
F2204546: D4467.id14417.diff
Sat, Jul 6, 4:53 PM
F2204332: D4467.id14525.diff
Sat, Jul 6, 3:56 PM
F2204200: D4467.diff
Sat, Jul 6, 3:33 PM
Unknown Object (File)
Sat, Jul 6, 11:06 AM
Unknown Object (File)
Sat, Jul 6, 12:17 AM
Unknown Object (File)
Fri, Jul 5, 8:56 PM

Details

Summary

This diff introduces validateUUIDv4 function that checks the validity of the generated UUIDs based on the regular expression.

Related linear task: ENG-1360

Test Plan

Tests from D4468

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

max held this revision as a draft.
max published this revision for review.Jul 7 2022, 4:57 AM
max edited the summary of this revision. (Show Details)
max edited the test plan for this revision. (Show Details)
max added reviewers: karol, tomek.
services/lib/src/GlobalTools.cpp
50 ↗(On Diff #14249)

can you provide a source of this regex?

max added inline comments.
services/lib/src/GlobalTools.cpp
50 ↗(On Diff #14249)

can you provide a source of this regex?

This expression is based on the UUID v4 format.

Why do we need to validate if it is formatted correctly? What could happen if we don't do that?

services/lib/src/GlobalTools.cpp
48 ↗(On Diff #14249)

We need to state that we validate only v4

50 ↗(On Diff #14249)
This revision is now accepted and ready to land.Jul 8 2022, 2:18 AM
max marked 2 inline comments as done.

The function name was changed to validateUUIDv4, small regexp simplify.

max retitled this revision from [services] Tunnelbroker - Introduce `validateUUID` function to [services] Tunnelbroker - Introduce `validateUUIDv4` function.Jul 12 2022, 4:11 PM
max edited the summary of this revision. (Show Details)
In D4467#127455, @palys-swm wrote:

Why do we need to validate if it is formatted correctly?

In a recent message checkpointing architecture update, the messageID (UUID) is generated on the client-side. That's why we should check the messageID format validity received from the client.

What could happen if we don't do that?

Message IDs format would go wrong in the database and can cause a possible message collision in the deviceID messages batch.
At the moment we are checking the messageID for not being empty only. This function would be used instead of this simple check.

services/lib/src/GlobalTools.cpp
48 ↗(On Diff #14249)

We need to state that we validate only v4

That makes sense, I've changed the function name.

max marked an inline comment as done.

Regular expression was changed to match lowercase only and case insensitive was removed from regex. The function now returns true
only for UUIDs in a lower case.