Skip to content

Commit

Permalink
changed xpath, fixed the context paths, added test to playbook (#6658)
Browse files Browse the repository at this point in the history
* changed xpath, fixed the context paths, added test to playbook

* updated pack-metadata

* Update CHANGELOG.md

Co-authored-by: roysagi <[email protected]>
  • Loading branch information
teizenman and roysagi authored Apr 30, 2020
1 parent cbf93e3 commit f1d3965
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 354 deletions.
7 changes: 3 additions & 4 deletions Packs/Alexa/Integrations/Alexa/Alexa.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def alexa_fallback_command(domain):
resp = requests.request('GET', 'https://www.alexa.com/minisiteinfo/{}'.format(domain),
headers=headers, verify=USE_SSL, proxies=PROXIES)
try:
x = re.search(r"style=\"margin-bottom:-2px;\"\/>\s(\d{0,3},)?(\d{3},)?\d{0,3}<\/a>",
resp.content)
x = re.search(r"style=\"margin-bottom:-2px;\"\/>\s(\d{0,3},)?(\d{3},)?\d{0,3}<\/a>", resp.content)
raw_result = x.group() # type:ignore
strip_beginning = raw_result.replace('style="margin-bottom:-2px;"/> ', '')
strip_commas = strip_beginning.replace(',', '')
Expand All @@ -43,7 +42,7 @@ def alexa_domain_command():
'https://data.alexa.com/data?cli=10&dat=s&url={}'.format(domain),
verify=USE_SSL, proxies=PROXIES)
root = ET.fromstring(str(resp.content))
rank = root.find("SD[0]/POPULARITY").attrib['TEXT'] # type: ignore
rank = root.find(".//POPULARITY").attrib['TEXT'] # type: ignore
except: # noqa
rank = alexa_fallback_command(domain)
if int(rank) > THRESHOLD:
Expand Down Expand Up @@ -90,7 +89,7 @@ def test_module_command():
'https://data.alexa.com/data?cli=10&dat=s&url={}'.format(domain),
verify=USE_SSL, proxies=PROXIES)
root = ET.fromstring(str(resp.content))
rank = root.find("SD[0]/POPULARITY").attrib['TEXT'] # type: ignore
rank = root.find(".//POPULARITY").attrib['TEXT'] # type: ignore
except: # noqa
rank = alexa_fallback_command(domain)
if rank == '1':
Expand Down
5 changes: 4 additions & 1 deletion Packs/Alexa/Integrations/Alexa/Alexa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ script:
- contextPath: DBotScore.Indicator
description: The indicator that was tested.
type: string
- contextPath: Alexa.Domain.Data
- contextPath: Alexa.Domain.Indicator
description: The Domain being checked
type: string
- contextPath: Alexa.Domain.Name
description: The Domain being checked
type: string
- contextPath: Alexa.Domain.Rank
Expand Down
12 changes: 1 addition & 11 deletions Packs/Alexa/Integrations/Alexa/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
## [Unreleased]
Fixed an issue where the integration failed to retrieve the correct rank.


## [20.4.1] - 2020-04-29
-


## [20.4.0] - 2020-04-14
-


## [20.3.3] - 2020-03-18
-

## [19.12.0] - 2019-12-10
- Added fallback for when default endpoint is inaccessible.
- Now supports connection from proxy.
Expand Down
Loading

0 comments on commit f1d3965

Please sign in to comment.