From c299f5de6de4cbefc0df7389a5ba4adb7486e845 Mon Sep 17 00:00:00 2001 From: "casey.largent" Date: Thu, 4 Apr 2024 16:08:08 -0500 Subject: [PATCH] Check netloc in urlparse result if path is empty --- detect_secrets/core/usage/filters.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/detect_secrets/core/usage/filters.py b/detect_secrets/core/usage/filters.py index c27ce0843..90e68af63 100644 --- a/detect_secrets/core/usage/filters.py +++ b/detect_secrets/core/usage/filters.py @@ -98,7 +98,15 @@ def valid_looking_paths(path: str) -> str: # May be local file. # We do some initial pre-processing, but perform the file validation during the # post-processing step. - components = parts.path.split('::') + + # urllib can put results of urlparse into either path or netloc + # depending on the version, so check both + if parts.path: + components = parts.path.split('::') + + elif parts.netloc: + components = parts.netloc.split('::') + if len(components) != 2: raise argparse.ArgumentTypeError( 'Did not specify function name for imported file.',