Skip to content

Commit bfbc40a

Browse files
committed
mission fixes
1 parent 7bbd2d5 commit bfbc40a

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

docs/src/usage/plugins/targets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
>> [{"credentials": [{...},...],...}]
211211
>> ```
212212
213-
## targets.get_query(status='registered', query_changes={})
213+
## targets.get(status='registered', query_changes={})
214214
215215
> Pulls back a list of targets matching the specified query
216216
>
@@ -221,7 +221,7 @@
221221
>
222222
>> Examples
223223
>> ```python3
224-
>> >>> h.targets.get_query(status='unregistered')
224+
>> >>> h.targets.get(status='unregistered')
225225
>> [{"codename": "SLEEPYSLUG", ...}, ...]
226226
>> ```
227227

src/synack/plugins/duo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_grant_token(self, auth_url):
6363
def _get_mfa_details(self):
6464
if self._state.otp_secret:
6565
self._device = 'null'
66-
self._hotp = pyotp.HOTP(s=self._state.otp_secret).generate_otp(self._state.otp_count)
66+
self._hotp = pyotp.HOTP(s=self._state.otp_secret).generate_otp(int(self._state.otp_count))
6767
self._factor = 'Passcode'
6868
return
6969

src/synack/plugins/missions.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def build_summary(self, missions):
5454
for mission in missions:
5555
codename = mission.get('listingCodename', 'UNKNOWN')
5656
ret[codename] = ret.get(codename, {'count': 0, 'value': 0, 'time': 0})
57-
ret[codename][count] += 1
57+
ret[codename]['count'] += 1
5858
ret[codename]['value'] += mission['payout']['amount']
5959
ret['total']['count'] += 1
6060
ret['total']['value'] += mission['payout']['amount']
@@ -83,7 +83,7 @@ def build_summary(self, missions):
8383

8484
return ret
8585

86-
def get(self, **kwargs):
86+
def get(self, status='PUBLISHED', max_pages=1, page=1, per_page=20, listing_uids=None, **kwargs):
8787
"""Get a list of missions given a status
8888
8989
Arguments:
@@ -96,12 +96,6 @@ def get(self, **kwargs):
9696
(Bad: per_page=5000, per_page=1&max_pages=10)
9797
listing_uids -- A specific listing ID to check for missions
9898
"""
99-
status = kwargs.get('status', 'PUBLISHED')
100-
max_pages = kwargs.get('max_pages', 1)
101-
page = kwargs.get('page', 1)
102-
per_page = kwargs.get('per_page', 20)
103-
listing_uids = kwargs.get('listing_uids', None)
104-
10599
query = {
106100
'status': status,
107101
'perPage': per_page,

src/synack/plugins/targets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def get_credentials(self, **kwargs):
206206
if res.status_code == 200:
207207
return res.json()
208208

209-
def get_query(self, status='registered', query_changes={}):
209+
def get(self, status='registered', query_changes={}):
210210
"""Get information about targets returned from a query"""
211211
if not self._db.categories:
212212
self.get_assessments()
@@ -356,15 +356,15 @@ def get_submissions_summary(self, target=None, hours_ago=None, **kwargs):
356356

357357
def get_unregistered(self):
358358
"""Get slugs of all unregistered targets"""
359-
return self.get_query(status='unregistered')
359+
return self.get(status='unregistered')
360360

361361
def get_upcoming(self):
362362
"""Get slugs and upcoming start dates of all upcoming targets"""
363363
query_changes = {
364364
'sorting[field]': 'upcomingStartDate',
365365
'sorting[direction]': 'asc'
366366
}
367-
return self.get_query(status='upcoming', query_changes=query_changes)
367+
return self.get(status='upcoming', query_changes=query_changes)
368368

369369
def set_connected(self, target=None, **kwargs):
370370
"""Connect to a target"""

test/test_targets.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def test_get_credentials(self):
403403
self.targets.get_credentials(codename='SLEEPYSLUG'))
404404
self.targets._api.request.assert_called_with('POST', url)
405405

406-
def test_get_query(self):
406+
def test_get(self):
407407
"""Should get a list of targets"""
408408
self.targets._db.categories = [
409409
Category(id=1, passed_practical=True, passed_written=True),
@@ -429,7 +429,7 @@ def test_get_query(self):
429429
"targets",
430430
query=query)
431431

432-
def test_get_query_assessments_empty(self):
432+
def test_get_assessments_empty(self):
433433
"""Should get a list of unregistered targets"""
434434
self.targets.get_assessments = MagicMock()
435435
self.targets._db.categories = []
@@ -776,10 +776,10 @@ def test_get_unregistered(self):
776776
results = [
777777
{'codename': 'SLEEPYSLUG', 'slug': '1283hi'}
778778
]
779-
self.targets.get_query = MagicMock()
780-
self.targets.get_query.return_value = results
779+
self.targets.get = MagicMock()
780+
self.targets.get.return_value = results
781781
self.assertEqual(results, self.targets.get_unregistered())
782-
self.targets.get_query.assert_called_with(status='unregistered')
782+
self.targets.get.assert_called_with(status='unregistered')
783783

784784
def test_get_upcoming(self):
785785
"""Should query for upcoming targets"""
@@ -790,10 +790,10 @@ def test_get_upcoming(self):
790790
'sorting[field]': 'upcomingStartDate',
791791
'sorting[direction]': 'asc'
792792
}
793-
self.targets.get_query = MagicMock()
794-
self.targets.get_query.return_value = results
793+
self.targets.get = MagicMock()
794+
self.targets.get.return_value = results
795795
self.assertEqual(results, self.targets.get_upcoming())
796-
self.targets.get_query.assert_called_with(status='upcoming', query_changes=query_changes)
796+
self.targets.get.assert_called_with(status='upcoming', query_changes=query_changes)
797797

798798
def test_set_connected(self):
799799
"""Should connect to a given target provided kwargs"""

0 commit comments

Comments
 (0)