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)
Mon, Nov 11, 7:20 AM
Unknown Object (File)
Sat, Nov 2, 6:20 PM
Unknown Object (File)
Wed, Oct 23, 10:57 AM
Unknown Object (File)
Oct 15 2024, 3:31 AM
Unknown Object (File)
Oct 14 2024, 5:10 AM
Unknown Object (File)
Oct 7 2024, 10:34 AM
Unknown Object (File)
Oct 7 2024, 10:34 AM
Unknown Object (File)
Oct 7 2024, 10:34 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
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.