Skip to content

Commit

Permalink
Add a timeout to the GET for the GitHub CSV URL
Browse files Browse the repository at this point in the history
Bandit now complains about requests calls that do not have a timeout.
  • Loading branch information
jsf9k committed Jul 31, 2023
1 parent 00edd95 commit 3d69847
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/vdp_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
GITHUB_CSV_URL = (
"https://raw.githubusercontent.com/cisagov/dotgov-data/main/current-federal.csv"
)
# The time in seconds to wait for a response from github.com before
# giving up. Thirty seconds seems like more than enough time.
GITHUB_CSV_URL_TIMEOUT = 30


class DomainResult(NamedTuple):
Expand Down Expand Up @@ -252,7 +255,7 @@ def get_local_csv(file: str) -> List[Dict[str, str]]:

def get_remote_csv() -> List[Dict[str, str]]:
"""Load domains from the CSV at the given URL."""
resp = requests.get(GITHUB_CSV_URL)
resp = requests.get(GITHUB_CSV_URL, timeout=GITHUB_CSV_URL_TIMEOUT)
# Default to utf-8 encoding if there is no encoding in the response
encoding = resp.encoding if resp.encoding else "utf-8"
if resp.status_code != 200:
Expand Down

0 comments on commit 3d69847

Please sign in to comment.