Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flags_id nullable field to new Flake model #484

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joseph-sentry
Copy link
Contributor

No description provided.

@joseph-sentry joseph-sentry requested a review from a team January 20, 2025 17:43
@@ -10,6 +10,7 @@ class Flake(models.Model):

repoid = models.IntegerField()
test_id = models.BinaryField()
flags_id = models.BinaryField(null=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

BinaryField. What kind of data do you plan to put there? Also noticing now that test_id is also a BinaryField. Will these hold (non-base16-encoded) hash values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, they're both has values. I think i can probably indicate it somehow with some sort of max length in the binary field but the test_id is meant to be 16 bytes and the flags_id is meant to be 8 bytes. they're both generated using mmh3 and they don't have any particular encoding hence: BinaryField. In BQ they're defined as BYTES fields

Copy link
Contributor

Choose a reason for hiding this comment

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

we have a normal index on repo_id and test_id, but are you planning on having any kind of uniqueness constraint based on the test_id or the flags_id?

it should be fine if both are still also dependent on the repo_id.

just thinking of that as I recently read https://orlp.net/blog/breaking-hash-functions/ which is a very well written post about how to trivially cause collisions of mmh3 and similar non cryptographic hash functions.
it would be really bad if one customer could mess with another customers data based on such trivially breakable hash values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think the uniqueness constraint should be on (repoid, test_id, flags_id) so that will isolate test_id collisions to a single customer. The mistake I made with the Test model previously is that the primary key was the test_id, which was all around a bad idea.

At least this strategy of isolating unique (test_id, flags_id) combinations to the repo means that one customer can't mess with another, however this still leaves an opening for open source repos (or any repo that doesn't protect its uploads) to be polluted. I'm not sure how to fix that problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants