-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aaron Loo
committed
Oct 1, 2019
1 parent
e1b2ae2
commit 0a87809
Showing
6 changed files
with
166 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from ..core.database import Base | ||
|
||
|
||
class Widget(Base): | ||
""" | ||
We really don't need anything else in this, except an ID. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
|
||
import fuzz_lightyear | ||
|
||
|
||
@pytest.fixture | ||
def mock_api_client(mock_client): | ||
""" | ||
Override victim and attacker account, with proper API keys. | ||
""" | ||
victim_key = mock_client.user.post_create_user().result() | ||
attacker_key = mock_client.user.post_create_user().result() | ||
|
||
fuzz_lightyear.victim_account( | ||
lambda: { | ||
'_request_options': { | ||
'headers': { | ||
'X-API-KEY': victim_key, | ||
}, | ||
}, | ||
}, | ||
) | ||
fuzz_lightyear.attacker_account( | ||
lambda: { | ||
'_request_options': { | ||
'headers': { | ||
'X-API-KEY': attacker_key, | ||
}, | ||
}, | ||
}, | ||
) | ||
|
||
yield mock_client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import pytest | ||
|
||
from fuzz_lightyear.request import FuzzingRequest | ||
from fuzz_lightyear.response import ResponseSequence | ||
from fuzz_lightyear.runner import run_sequence | ||
|
||
|
||
def test_basic(mock_client): | ||
responses = run_sequence( | ||
[ | ||
FuzzingRequest( | ||
tag='basic', | ||
operation_id='get_private_listing', | ||
id=1, | ||
), | ||
], | ||
ResponseSequence(), | ||
) | ||
|
||
assert responses.data['session'] == 'victim_session' | ||
assert responses.test_results['IDORPlugin'] | ||
|
||
|
||
def test_skipped_due_to_no_inputs(mock_client): | ||
responses = run_sequence( | ||
[ | ||
FuzzingRequest( | ||
tag='basic', | ||
operation_id='get_no_inputs_required', | ||
), | ||
], | ||
ResponseSequence(), | ||
) | ||
|
||
assert responses.data['session'] == 'victim_session' | ||
assert responses.test_results == {} | ||
|
||
|
||
@pytest.mark.xfail( | ||
reason='https://github.com/Yelp/fuzz-lightyear/issues/11', | ||
) | ||
def test_side_effect(mock_api_client): | ||
responses = run_sequence( | ||
[ | ||
FuzzingRequest( | ||
tag='sequence', | ||
operation_id='post_create_with_side_effect', | ||
), | ||
FuzzingRequest( | ||
tag='user', | ||
operation_id='get_get_user', | ||
), | ||
|
||
# This goes last, to test for IDOR. | ||
FuzzingRequest( | ||
tag='sequence', | ||
operation_id='get_get_with_side_effect', | ||
), | ||
], | ||
ResponseSequence(), | ||
) | ||
|
||
assert responses.responses[1].has_created_resource | ||
assert responses.test_results['IDORPlugin'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters