-
Notifications
You must be signed in to change notification settings - Fork 285
Fix call() API crash when used without run_module() #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
williballenthin
wants to merge
5
commits into
master
Choose a base branch
from
worktree-fix-issue-21
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
44e0ef1
ci: add permissions
williballenthin 1d7d0c3
v2.0.0b1
williballenthin dedc300
Merge pull request #263 from mandiant/wb-unicorn2
mr-tz 1a2f336
Fix call() API crash when used without run_module()
williballenthin 9b238d5
Consolidate call/run context initialization into _prepare_run_context
williballenthin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ on: | |
| pull_request: | ||
| branches: [master] | ||
|
|
||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "2.0.0a1" | ||
| __version__ = "2.0.0b1" |
This file contains hidden or 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 hidden or 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,40 @@ | ||
| import pytest | ||
|
|
||
| from speakeasy import Speakeasy | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "bin_file", | ||
| [ | ||
| "dll_test_x86.dll.xz", | ||
| "dll_test_x64.dll.xz", | ||
| ], | ||
| ) | ||
| def test_call_without_run_module(config, load_test_bin, bin_file): | ||
| """call() should work without run_module() being called first (GH-21).""" | ||
| data = load_test_bin(bin_file) | ||
| se = Speakeasy(config=config) | ||
| try: | ||
| mod = se.load_module(data=data) | ||
| se.call(mod.base + mod.ep, [mod.base, 1, 0]) | ||
| finally: | ||
| se.shutdown() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "bin_file", | ||
| [ | ||
| "dll_test_x86.dll.xz", | ||
| "dll_test_x64.dll.xz", | ||
| ], | ||
| ) | ||
| def test_call_after_run_module(config, load_test_bin, bin_file): | ||
| """call() should still work after run_module() has set up context.""" | ||
| data = load_test_bin(bin_file) | ||
| se = Speakeasy(config=config) | ||
| try: | ||
| mod = se.load_module(data=data) | ||
| se.run_module(mod) | ||
| se.call(mod.base + mod.ep, [mod.base, 1, 0]) | ||
| finally: | ||
| se.shutdown() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't like having this second copy of the initialization. we should study this further and see if we can refactor/consolidate all the logic together. i'm not convinced the call to
_ensure_process_contextis the right way.