Skip to content

Commit

Permalink
Merge pull request #1154 from lucamemini/patch-1
Browse files Browse the repository at this point in the history
Update urlcategory.py
  • Loading branch information
nusantara-self authored Oct 22, 2024
2 parents 37973d7 + e9db42a commit 05c453f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions analyzers/Fortiguard/urlcategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import requests
from cortexutils.analyzer import Analyzer
import urllib.parse


class URLCategoryAnalyzer(Analyzer):
Expand Down Expand Up @@ -37,12 +38,15 @@ def run(self):
try:
pattern = re.compile("(?:Category: )([-\w\s]+)")
baseurl = 'https://www.fortiguard.com/webfilter?q='
url = baseurl + self.get_data()
url = baseurl + urllib.parse.quote_plus(self.get_data())
req = requests.get(url)
category_match = re.search(pattern, req.text, flags=0)
self.report({
'category': category_match.group(1)
})
if not req.status_code == 200:
raise Exception(str(req.status_code)+': '+req.reason+' '+url)
else:
category_match = re.search(pattern, req.text, flags=0)
self.report({
'category': category_match.group(1)
})
except ValueError as e:
self.unexpectedError(e)
else:
Expand Down

0 comments on commit 05c453f

Please sign in to comment.