Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Fix UUID equality check bug #45

Merged

Conversation

jooskim
Copy link
Collaborator

@jooskim jooskim commented Dec 4, 2021

UUID is used throughout the entire codebase of Transport and is
especially important in filtering messages based on their destination.
While implementing basic WASM bridge for the bus I realized that UUID
comparison was failing, i.e. returning true for the equality check
between two dififerent UUID instances. Turns out the use of .ID()
method on the UUID object only returns the first 4 bytes of the
underlying 16-byte slice. This means as long as the first 8
hexadecimal characters matched between two UUID instances, they would
come out as equal, and it would therefore mean a significantly higher
chance of UUID collision.. The fix introduced in this PR is to use
the string comparison of the full UUID in places where .ID() was used.

Also performs gofmt across all source files, which is done in a separate commit
to make reviewing the PR easier.

Signed-off-by: Josh Kim kjosh@vmware.com

Signed-off-by: Josh Kim <kjosh@vmware.com>
UUID is used throughout the entire codebase of Transport and is
especially important in filtering messages based on their destination.
While implementing basic WASM bridge for the bus I realized that UUID
comparison was failing, i.e. returning true for the equality check
between two dififerent UUID instances. Turns out the use of .ID()
method on the UUID object only returns the first 4 bytes of the
underlying 16-byte slice. This means as long as the first 8
hexadecimal characters matched between two UUID instances, they would
come out as equal, and it would therefore mean a significantly higher
chance of UUID collision.. The fix introduced in this PR is to use
the string comparison of the full UUID in places where .ID() was used.

Signed-off-by: Josh Kim <kjosh@vmware.com>
@codecov-commenter
Copy link

Codecov Report

Merging #45 (e47c0c5) into main (3c1a8f0) will increase coverage by 0.03%.
The diff coverage is 95.40%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
+ Coverage   87.56%   87.60%   +0.03%     
==========================================
  Files          52       52              
  Lines        2695     2695              
==========================================
+ Hits         2360     2361       +1     
+ Misses        335      334       -1     
Flag Coverage Δ
unittests 87.60% <95.40%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bridge/broker_connector_config.go 100.00% <ø> (ø)
bus/eventbus.go 98.41% <ø> (ø)
model/store_responses.go 0.00% <0.00%> (ø)
model/util.go 0.00% <0.00%> (ø)
plank/pkg/server/prometheus.go 0.00% <ø> (ø)
plank/pkg/server/spa_config.go 46.66% <ø> (ø)
service/service_lifecycle_manager.go 94.11% <ø> (ø)
service/service_registry.go 94.59% <ø> (ø)
bus/transaction.go 92.39% <92.39%> (+1.08%) ⬆️
bus/channel.go 97.22% <97.22%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c1a8f0...e47c0c5. Read the comment docs.

config := &bridge.BrokerConnectorConfig{
Username: "guest",
Password: "guest",
ServerAddr: "appfabric.vmware.com",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen a couple of these old references in here still. can we get rid of them?

Copy link
Collaborator

@daveshanley daveshanley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, it's a little hard to see what has changed because of legacy gofmt issues overloading the review with formatting.

@jooskim
Copy link
Collaborator Author

jooskim commented Dec 8, 2021

@daveshanley For that purpose I explicitly split this work into two commits. By choosing the latest commit you'll be able to see the changes only pertaining to this PR.

@jooskim jooskim merged commit 6d9ecb6 into vmware-archive:main Dec 8, 2021
@jooskim jooskim deleted the topic/kjosh/fix-uuid-comparison-bug branch December 8, 2021 03:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants