Diego Carpintero commited on
Commit
7210215
1 Parent(s): 254da27

return flag after URL check

Browse files
Files changed (1) hide show
  1. tools.py +3 -3
tools.py CHANGED
@@ -41,7 +41,7 @@ class Tools:
41
  except requests.exceptions.RequestException as e:
42
  return url # Return original URL if expansion fails
43
 
44
- def is_url_safe(self, target_url: str) -> Tuple[bool, List[Dict[str, str]]]:
45
  """Check if URL is safe using Google Safe Browsing API
46
  """
47
  if not self.safebrowsing_key:
@@ -75,7 +75,7 @@ class Tools:
75
  result = response.json()
76
 
77
  if not result:
78
- return True, []
79
 
80
  threats = []
81
  if "matches" in result:
@@ -85,7 +85,7 @@ class Tools:
85
  "threat_url": match.get("threat", {}).get("url"),
86
  })
87
 
88
- return False, threats
89
 
90
  except requests.exceptions.RequestException as e:
91
  raise Exception(f"Error checking URL safety: {str(e)}")
 
41
  except requests.exceptions.RequestException as e:
42
  return url # Return original URL if expansion fails
43
 
44
+ def is_url_safe(self, target_url: str) -> Tuple[str, List[Dict[str, str]]]:
45
  """Check if URL is safe using Google Safe Browsing API
46
  """
47
  if not self.safebrowsing_key:
 
75
  result = response.json()
76
 
77
  if not result:
78
+ return "Not Flagged", []
79
 
80
  threats = []
81
  if "matches" in result:
 
85
  "threat_url": match.get("threat", {}).get("url"),
86
  })
87
 
88
+ return "Flagged", threats
89
 
90
  except requests.exceptions.RequestException as e:
91
  raise Exception(f"Error checking URL safety: {str(e)}")