Conversation
Signed-off-by: kunalsz <kunalavengers@gmail.com>
Summary of ChangesHello @kunalsz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the FLOSS tool's capability to detect string decoding functions by incorporating a novel heuristic based on the number of external API calls made by a function. This addition aims to refine the scoring of functions, leveraging the observation that decoding routines typically perform low-level operations with minimal external API interaction, thereby improving the accuracy of identifying such functions. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new heuristic, num_api_calls, to help identify string decoding functions based on the number of API calls they make. The implementation is sound, but I've identified a high-severity bug that would limit its effectiveness on non-x86 architectures, and a medium-severity issue related to error handling that could make debugging difficult. I have provided specific suggestions to address these points.
| # only proceed on call mnemonics when available | ||
| mnem = insn.mnem.lower() | ||
| if mnem and mnem != "call": | ||
| continue | ||
|
|
There was a problem hiding this comment.
The check for mnem == "call" is specific to x86/x64 architectures and will not work for other architectures like ARM, where call instructions are BL. This makes the heuristic less portable. The _iter_call_targets function already correctly identifies call-like instructions using the architecture-agnostic envi.BR_PROC flag, so this check is both redundant and buggy.
| except Exception: | ||
| return |
There was a problem hiding this comment.
Swallowing exceptions with a broad except Exception: and a return or pass can hide bugs and makes debugging difficult. It is better to log the exception to provide visibility into potential issues during analysis. This pattern is also present in _is_external_api_target.
| except Exception: | |
| return | |
| except Exception as e: | |
| logger.warning("Failed to get branches for instruction at 0x%x: %s", insn.va, e) | |
| return |
|
Thanks for the proposal. On closer look, and seeing the already noticeable slowdown, let's hold off with additional heuristics unless these really provide a benefit in detection more detection functions. What do you think? |
|
Thanks for the feedback! I understand the concern and just wanted to highlight that the time difference added is quite small and more like applying a filter , it improves the confidence in detection without significantly altering existing logic. I still believe it adds value, but I'm happy to adapt based on your suggestions! |
In reference to the discussion here #1212
What it is?
extract_num_api_callsis a function-level heuristic that counts how many API calls a function makesLow API call count : more consistent with a decoding rpoutine
High API call count : less consistent with decoding
How is it implemented ?
Test results
With the heuristic in place the score has improved(same num of strings found)
Tests were executed on
tests/data/malware/stackstrings/a294620543334a721a2ae8eaaf9680a0786f4b9a216d75b55cfd28f39e9430ea.exe_With this heuristic :
@mr-tz Looking forward to your insights !