Skip to content

Commit

Permalink
fix: leading character exploit (#332)
Browse files Browse the repository at this point in the history
* fix: leading ೦

* fix: any leading zeros

* fix: makefile

* fix: additional characters
  • Loading branch information
grantdfoster authored Dec 23, 2024
1 parent 71965be commit 0f56ac6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions masa/validator/forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

from masa_ai.tools.validator import TrendingQueries, TweetValidator

import re


class Forwarder:
def __init__(self, validator):
Expand Down Expand Up @@ -213,14 +215,14 @@ async def get_miners_volumes(self):
if not all_responses:
continue

# also remove all padded 0's from the response IDs
# Use regex to remove all leading zeros or similar characters
unique_tweets_response = list(
{
resp["Tweet"]["ID"].lstrip("0"): {
re.sub(r"^[0೦०]+", "", resp["Tweet"]["ID"]): {
**resp,
"Tweet": {
**resp["Tweet"],
"ID": resp["Tweet"]["ID"].lstrip("0"),
"ID": re.sub(r"^[0೦०]+", "", resp["Tweet"]["ID"]),
},
}
for resp in all_responses
Expand Down
2 changes: 1 addition & 1 deletion notebooks/mainnet/axons.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions notebooks/mainnet/volumes.ipynb

Large diffs are not rendered by default.

0 comments on commit 0f56ac6

Please sign in to comment.