Skip to content

Commit

Permalink
master: Fix mark_popular_plugins crashing when Wordpres API returned …
Browse files Browse the repository at this point in the history
…plugins in a dict instead of a list
  • Loading branch information
NicolasAubry committed Apr 4, 2018
1 parent 8aba13c commit 8b3d9e3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion openwebvulndb/wordpress/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ async def _mark_popular_from_api(self, group, count):
'?action=query_{group}&request[browse]=popular&request[per_page]={count}'.
format(group=group, count=count)) as response:
data = await response.json()
for entry in data[group]:
entries = data[group].values() if type(data[group]) == dict else data[group]
for entry in entries:
slug = "{group}/{partial}".format(group=group, partial=entry["slug"])
try:
meta = self.storage.read_meta(slug)
Expand Down
2 changes: 1 addition & 1 deletion tests/wordpress_test/enumerate_plugins_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async def test_flag_as_popular_from_api(self, loop):
handler.storage.read_meta.assert_has_calls([
call("plugins/woocommerce"),
call("plugins/google-sitemap-generator"),
])
], any_order=True)
self.assertTrue(meta_1.is_popular)
self.assertTrue(meta_2.is_popular)
self.assertIsNone(meta_3.is_popular)
Loading

0 comments on commit 8b3d9e3

Please sign in to comment.