-
Notifications
You must be signed in to change notification settings - Fork 139
Censor ip addresses in failed_task messages. #2415
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"__version": 305, "updater.py": "eDDBPKA/vrTCadgtEJFdL06vSoiysF0JhiHKdEnjQv3zS4kfdOAqnco/DJpDWbvh", "worker.py": "Y0kkVAk+3q3+HuWmVqgcPx7/h+CoLyPihLUszUGrvphfzNn55qXwqC+xh0fPz/Zt", "games.py": "uUpIoWu/jB6IoWN4aqSmRvtb7chhVswcFqIiT+G/cKNUWTam8ARxMZARNmTqGQ9p"} | ||
| {"__version": 305, "updater.py": "eDDBPKA/vrTCadgtEJFdL06vSoiysF0JhiHKdEnjQv3zS4kfdOAqnco/DJpDWbvh", "worker.py": "t4tOovi0IPG0K/DFZ1/6wC7rOOTh7ZzKEkAJm8zUMvPoiPv52H3jnyXoefbfckjO", "games.py": "uUpIoWu/jB6IoWN4aqSmRvtb7chhVswcFqIiT+G/cKNUWTam8ARxMZARNmTqGQ9p"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1369,11 +1369,18 @@ def fetch_and_handle_task( | |
| current_state["task_id"] = None | ||
| current_state["run"] = None | ||
|
|
||
| def censor(s): | ||
| ipv4 = re.compile(r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}") | ||
| ipv6 = re.compile(r"(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}") | ||
|
||
| s = re.sub(ipv6, "?.?.?.?.?.?.?.?", s) | ||
| s = re.sub(ipv4, "?.?.?.?", s) | ||
| return s | ||
|
Comment on lines
+1372
to
+1377
|
||
|
|
||
| payload = { | ||
| "password": password, | ||
| "run_id": str(run["_id"]), | ||
| "task_id": task_id, | ||
| "message": server_message, | ||
| "message": censor(server_message), | ||
| "worker_info": worker_info, | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IPv4 regex pattern is too permissive and will match invalid IP addresses. The pattern allows each octet to be 0-999, which means it would match invalid addresses like "999.999.999.999". Each octet in an IPv4 address should be in the range 0-255. Consider using a more precise regex pattern that properly validates IPv4 addresses, or at minimum restricts octets to 0-255 range.