Skip to content

Commit 46b809a

Browse files
fix(security): remove insecure SSL verification bypass in dataset downloaders (#1108)
## Summary - Remove `ssl.CERT_NONE` and `check_hostname = False` bypass for `plato.asu.edu` URLs in dataset download scripts - The site has a valid SSL certificate — the bypass was unnecessary and flagged by SonarQube as 2 Medium-severity vulnerabilities - Clean up unused `import ssl` Fixes SonarQube rules `python:S4830` and `python:S5527` (the only 2 open security vulnerabilities in the report). ## Test plan - [ ] Run `regression/get_datasets.py` and verify plato.asu.edu downloads succeed without SSL bypass - [ ] Run `benchmarks/linear_programming/utils/get_datasets.py` and verify same
1 parent cfa7ce4 commit 46b809a

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

benchmarks/linear_programming/utils/get_datasets.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import argparse
66
import urllib.request
77
import urllib.parse
8-
import ssl
98
import subprocess
109

1110

@@ -632,14 +631,7 @@ def download(url, dst):
632631
if os.path.exists(dst):
633632
return
634633
print(f"Downloading {url} into {dst}...")
635-
# Bypass SSL verification for plato.asu.edu URLs
636-
if "plato.asu.edu" in url:
637-
context = ssl.create_default_context()
638-
context.check_hostname = False
639-
context.verify_mode = ssl.CERT_NONE
640-
response = urllib.request.urlopen(url, context=context)
641-
else:
642-
response = urllib.request.urlopen(url)
634+
response = urllib.request.urlopen(url)
643635
data = response.read()
644636
with open(dst, "wb") as fp:
645637
fp.write(data)

regression/get_datasets.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import sys
66
import urllib.request
77
import urllib.parse
8-
import ssl
98
import subprocess
109

1110

@@ -824,14 +823,7 @@ def download(url, dst):
824823
if os.path.exists(dst):
825824
return
826825
print(f"Downloading {url} into {dst}...")
827-
# Bypass SSL verification for plato.asu.edu URLs
828-
if "plato.asu.edu" in url:
829-
context = ssl.create_default_context()
830-
context.check_hostname = False
831-
context.verify_mode = ssl.CERT_NONE
832-
response = urllib.request.urlopen(url, context=context)
833-
else:
834-
response = urllib.request.urlopen(url)
826+
response = urllib.request.urlopen(url)
835827
data = response.read()
836828
with open(dst, "wb") as fp:
837829
fp.write(data)

0 commit comments

Comments
 (0)