Skip to content

Commit 483af90

Browse files
committed
Exception handling in Jarm processing module
1 parent 37a5011 commit 483af90

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

crawler/processing/jarm_processing.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# © Copyright 2021 HP Development Company, L.P.
22
from urllib.parse import urlparse
3-
43
from jarm.scanner.scanner import Scanner
5-
64
from .default_processing import DefaultProcessing
5+
import requests
76

87

98
class JARMProcessing(DefaultProcessing):
@@ -17,9 +16,13 @@ def __init__(self, config, logger):
1716

1817
def process(self, url, resp):
1918
jarm_scan = {}
20-
domain = urlparse(url).netloc
21-
result = Scanner.scan(domain, 443)
22-
jarm_scan["fingerprint"] = result[0]
23-
jarm_scan["domain"] = result[1]
24-
jarm_scan["port"] = result[2]
19+
try:
20+
domain = urlparse(url).netloc
21+
res = requests.get("https://" + domain) # Leads on purpose to an exception if connection is refused
22+
result = Scanner.scan(domain, 443)
23+
jarm_scan["fingerprint"] = result[0]
24+
jarm_scan["domain"] = result[1]
25+
jarm_scan["port"] = result[2]
26+
except Exception:
27+
pass
2528
return jarm_scan

0 commit comments

Comments
 (0)