-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig.py
52 lines (40 loc) · 1.25 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import configparser
import pathlib
# Definizione del path del file
path = pathlib.Path(__file__).parent.resolve()
# Creazione del file di configurazione
config_file = configparser.ConfigParser()
# DEFAULT (compile)
config_file["DEFAULT"] = {
"geoip_db": str(path / "GeoLite2-Country.mmdb"),
"log_file": str(path / "./logs/access.log"),
"max_requests_per_minute": int(changeme),
"risky_country": str("changeme"),
"unusual_status_codes": str("changeme")
}
# API (compile)
config_file["API"] = {
"abuseipdb_api_key": "changeme"
}
# WHITELIST (compile)
config_file["WHITELIST"] = {
"ips": "changeme"
}
# RISK SCORING (compile)
config_file["SCORING"] = {
"path_risk_weight": "1.0",
"geo_risk_weight": "0.5",
"abuse_ip_weight": "0.9",
"request_volume_weight": "0.6"
}
# Scrittura del file di configurazione
config_filename = "config.ini"
with open(config_filename, "w") as configfileObj:
config_file.write(configfileObj)
print(f"Config file '{config_filename}' created successfully.")
# Lettura e stampa del contenuto del file di configurazione
with open(config_filename, "r") as read_file:
content = read_file.read()
print(f"\nContent of the config file '{config_filename}':\n")
print(content)