-
-
Notifications
You must be signed in to change notification settings - Fork 121
mimas: block alibaba and tencent from scraping hydra #811
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: main
Are you sure you want to change the base?
Conversation
ee196d0
to
f8c0912
Compare
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.
Took a look through this and your new Python repo. Overall LGTM.
Some comments:
- I don't understand how old stuff get cleaned up when it should no longer exist. I see
nft add element
being called here. I honestly don't know exactly what it does, but it sounds additive. - Sure would appreciate a comment here: https://github.com/mweinelt/nft-prefix-import/blob/6ef9ed3cc2bfd0d2498c03907b0ad87a8366d793/src/nft_prefix_import/__init__.py#L79.
- This looks kind of silly with the
check=True
right above it: https://github.com/mweinelt/nft-prefix-import/blob/6ef9ed3cc2bfd0d2498c03907b0ad87a8366d793/src/nft_prefix_import/__init__.py#L62. If the intent is to be explicit, I think acheck=False
would do that. Either way, could use a comment explaining why we're ok with failures. Is our intent to just accomplish as much as we can? If so, should we be tracking that a failure occurred and then go on to crash the process at the end, so our systemd unit alerting can tell us to take a look?
|
I dropped the timeout completely, since adding the same item again does not seem to reset the timeout. The list now resets at boot and will only be appended to for the uptime of the box.
It prints the error to stdout/stderr and moves on. Not silly at all. This is the effect we see in 90 minutes:
|
That's not because you're setting demo.py#!/usr/bin/env python
import subprocess
noisy_error = (
"echo 'some info' >/dev/stdout && echo 'this is an error' >/dev/stderr && exit 42"
)
print("=== Experiment 1: Running `noisy_error` with `check=False`")
subprocess.run(noisy_error, shell=True, check=False)
print("=" * 30)
print(
"=== Experiment 2: Running `noisy_error` with `check=True`, and catching and tossing the Python exception"
)
try:
subprocess.run(noisy_error, shell=True, check=True)
except subprocess.SubprocessError:
pass
print("=" * 30) Note how both Experiment 1 and 2 output the exact same thing: $ python demo.py
=== Experiment 1: Running `noisy_error` with `check=False`
some info
this is an error
==============================
=== Experiment 2: Running `noisy_error` with `check=True`, and catching and tossing the Python exception
some info
this is an error
============================== Not that there's anything wrong with the code you've written, it just looks odd to me. My other questions are more important. |
These networks keep scraping hydra.nixos.org with a high request rate across a wide range of IP addresses with bogus user-agents. They did it, they made me develop a tool to lookup prefixes for an AS and block them from accessing tcp/443 using an nftable set match.
Testing right now on mimas. Will probably pull the python package out into a dedicated repo.