-
Notifications
You must be signed in to change notification settings - Fork 694
fix(idalib): only pass -R when creating new database #2952
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
Open
Young-Lord
wants to merge
1
commit into
mandiant:master
Choose a base branch
from
Young-Lord:fix-r-flag
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.
Open
Changes from all commits
Commits
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
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 |
|---|---|---|
|
|
@@ -221,6 +221,17 @@ def get_idalib_extractor(path: Path): | |
|
|
||
| idapro.enable_console_messages(False) | ||
|
|
||
| # `-R` (load resources) is only valid when loading a new input file. | ||
| # if an IDA database already exists, open it without `-R`. | ||
| # ref: https://github.com/mandiant/capa/issues/2950 | ||
| has_existing_database = any( | ||
| path.with_name(path.name + ext).exists() | ||
| for ext in (".ida", ".i64", ".id0") | ||
| ) | ||
| open_database_args = "-Olumina:host=0.0.0.0 -Osecondary_lumina:host=0.0.0.0" | ||
| if not has_existing_database: | ||
| open_database_args += " -R" | ||
|
Comment on lines
+224
to
+233
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test code seems to be duplicated from the source, so I followed the same approach. |
||
|
|
||
| # we set the primary and secondary Lumina servers to 0.0.0.0 to disable Lumina, | ||
| # which sometimes provides bad names, including overwriting names from debug info. | ||
| # | ||
|
|
@@ -233,7 +244,7 @@ def get_idalib_extractor(path: Path): | |
| # -1 - Generic errors (database already open, auto-analysis failed, etc.) | ||
| # -2 - User cancelled operation | ||
| ret = idapro.open_database( | ||
| str(path), run_auto_analysis=True, args="-Olumina:host=0.0.0.0 -Osecondary_lumina:host=0.0.0.0 -R" | ||
| str(path), run_auto_analysis=True, args=open_database_args | ||
| ) | ||
| if ret != 0: | ||
| raise RuntimeError("failed to analyze input file") | ||
|
|
||
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.
This logic for determining the IDA database arguments is duplicated in
tests/fixtures.py. To improve maintainability and avoid future inconsistencies, consider extracting this logic into a shared helper function.For example, you could create a function in this module or a more specific IDA helper module:
You could then call this function here and in
tests/fixtures.pyto avoid the code duplication. Using constants for the extensions and arguments would also improve readability.