mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 15:45:13 +08:00
fix: V-001 security vulnerability
Automated security fix generated by OrbisAI Security
This commit is contained in:
1 parent
ccaa53e2e9
commit
cbc4bfdd98
1 file changed
+4
-1
@@ -25,9 +25,12 @@ from __future__ import absolute_import, division, print_function, \
|
|||||||
with_statement
|
with_statement
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
_VALID_IP_RE = re.compile(r'^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description='See README')
|
parser = argparse.ArgumentParser(description='See README')
|
||||||
parser.add_argument('-c', '--count', default=3, type=int,
|
parser.add_argument('-c', '--count', default=3, type=int,
|
||||||
@@ -45,7 +48,7 @@ if __name__ == '__main__':
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
else:
|
else:
|
||||||
ips[ip] += 1
|
ips[ip] += 1
|
||||||
if ip not in banned and ips[ip] >= config.count:
|
if ip not in banned and ips[ip] >= config.count and _VALID_IP_RE.match(ip):
|
||||||
banned.add(ip)
|
banned.add(ip)
|
||||||
cmd = 'iptables -A INPUT -s %s -j DROP' % ip
|
cmd = 'iptables -A INPUT -s %s -j DROP' % ip
|
||||||
print(cmd, file=sys.stderr)
|
print(cmd, file=sys.stderr)
|
||||||
|
|||||||
Reference in new issue
Block a user