-
Notifications
You must be signed in to change notification settings - Fork 647
ghidra: initial capa explorer extension MVP #2839
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the master (unreleased) section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: [x] No CHANGELOG update needed
Summary of ChangesHello @vaishakh787, 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 lays the foundational architecture for integrating the capa analysis tool directly into Ghidra as a native extension. It transitions the existing script-based workflow into a more robust, installable plugin, providing a dedicated UI component and a menu action to initiate capa analysis. This MVP focuses on establishing the core framework and communication between Ghidra's Java environment and capa's Python logic, setting the stage for comprehensive feature development. 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. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a solid MVP for a capa explorer Ghidra extension. The architecture with a Java Swing UI and a Python backend for analysis is a good approach. My review includes suggestions to clean up some boilerplate code, improve error handling and configuration, and some minor code style points. Specifically, I've pointed out unused template files in the capaexplorer package that should be removed, and suggested improvements for handling Python executable paths and exception logging.
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaProvider.java
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPythonBridge.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPlugin.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPlugin.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaProvider.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPythonBridge.java
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPythonBridge.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capaexplorer/CapaExplorerPlugin.java
Outdated
Show resolved
Hide resolved
mike-hunhoff
left a comment
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 seems reasonable so far, but we want to utilize PyGhidra to bridge Java and Python. This implementation creates a separate process to run Python. Additionally, the already analyzed Ghidra database (program object) should be passed to capa for analysis, so the initial binary analysis does not need to be completed twice.
| Process process = | ||
| new ProcessBuilder( | ||
| python, | ||
| scriptFile.getAbsolutePath() | ||
| ) | ||
| .redirectErrorStream(true) | ||
| .start(); |
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.
PyGhidra should serve as the Python <-> Java bridge. Running Python in a separate process doesn't count 🙂
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.
Thanks for the clarification @mike-hunhoff that makes sense.
You're right: launching Python as a separate process is not the intended model here.
I’ll rework the bridge to use PyGhidra directly for in-process Java ↔ Python execution.
The updated approach will be:
- Use PyGhidra as the execution bridge
- Pass the already-loaded
Programobject into Python - Avoid reloading or reanalyzing the binary
- Reuse the existing Ghidra analysis database for capa
For this draft PR, my goal was to validate extension packaging and UI wiring.
I’ll update the implementation to follow the PyGhidra-based design next.
Thanks for pointing this out — I’ll push an update shortly.
ghidra: Implement a capa explorer plugin as a Ghidra extension #1980
Summary
Hey @mike-hunhoff , This PR introduces an initial MVP implementation of a capa explorer Ghidra extension.
The purpose of this draft PR is to validate the overall architecture and
integration approach before implementing full capa analysis functionality.
This work aims to replace the current script-based Ghidra workflow with a
proper, installable Ghidra extension that mirrors the IDA Pro capa explorer
plugin experience.
Current functionality
This MVP confirms that the extension:
Non-goals for this PR
This PR intentionally does not implement:
These will be implemented incrementally after architectural review.
Design notes
without breaking backward compatibility
Repository layout
capa/ghidra/
├── helpers.py
├── plugin/
│ ├── capa_explorer.py # existing script integration
│ └── extension/ # new Ghidra extension (this PR)
│ ├── Module.manifest
│ ├── extension.properties
│ ├── build.gradle
│ ├── data/
│ │ └── python/
│ └── src/
│ └── main/java/capa/ghidra/
Related to #1980
