Page MenuHomePhabricator

[services] Tunnelbroker - Introduce `validateUUIDv4` function
ClosedPublic

Authored by max on Jul 7 2022, 4:33 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 25, 10:09 AM
Unknown Object (File)
Wed, Dec 25, 10:09 AM
Unknown Object (File)
Wed, Dec 25, 10:09 AM
Unknown Object (File)
Wed, Dec 25, 10:09 AM
Unknown Object (File)
Wed, Dec 25, 10:09 AM
Unknown Object (File)
Wed, Dec 25, 10:08 AM
Unknown Object (File)
Sat, Dec 21, 3:28 AM
Unknown Object (File)
Sat, Dec 21, 3:24 AM

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
Branch
add-validateuuid-function
Lint
No Lint Coverage
Unit
No Test Coverage

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.