|
5 | 5 | import datetime |
6 | 6 | import traceback |
7 | 7 | from arango import ArangoClient |
8 | | -from uuid import uuid4 as unique_id |
9 | 8 |
|
10 | 9 | logging.basicConfig(stream=sys.stdout, level=logging.INFO) |
11 | 10 |
|
|
14 | 13 | DB_PORT = os.getenv("DB_PORT") |
15 | 14 | DB_NAME = os.getenv("DB_NAME") |
16 | 15 | DB_HOST = os.getenv("DB_HOST") |
17 | | - |
18 | | -QUEUE_URL = "http://scan-queue.scanners.svc.cluster.local" |
| 16 | +QUEUE_URL = os.getenv("SCAN_QUEUE_URL", "http://scan-queue.scanners.svc.cluster.local") |
19 | 17 |
|
20 | 18 |
|
21 | 19 | def dispatch_https(domain, client): |
@@ -46,11 +44,12 @@ def dispatch_dns(domain, client): |
46 | 44 | client.post(QUEUE_URL + "/dns", json=payload) |
47 | 45 |
|
48 | 46 |
|
49 | | -def scan(db_host, db_name, user_name, password, http_client=requests): |
| 47 | +def scan(db_host, db_port, db_name, user_name, password, http_client=requests): |
50 | 48 | logging.info("Retrieving domains for scheduled scan...") |
51 | 49 | try: |
52 | 50 | # Establish DB connection |
53 | | - arango_client = ArangoClient(hosts=db_host) |
| 51 | + connection_string = f"http://{db_host}:{db_port}" |
| 52 | + arango_client = ArangoClient(hosts=connection_string) |
54 | 53 | db = arango_client.db(db_name, username=user_name, password=password) |
55 | 54 |
|
56 | 55 | logging.info("Querying domains...") |
@@ -80,5 +79,5 @@ def scan(db_host, db_name, user_name, password, http_client=requests): |
80 | 79 | return count |
81 | 80 |
|
82 | 81 | if __name__ == "__main__": |
83 | | - dispatched_count = scan(DB_HOST, DB_NAME, DB_USER, DB_PASS) |
| 82 | + dispatched_count = scan(DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASS) |
84 | 83 | logging.info(f"Dispatched scans for {dispatched_count} domains.") |
0 commit comments