Skip to content

Conversation

@vaishakh787
Copy link

@vaishakh787 vaishakh787 commented Jan 26, 2026

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

  • Ghidra extension packaged using the standard Ghidra extension mechanism
  • Java Swing–based UI integration (no PyQt)
  • Menu action: Tools ->Run capa analysis
  • Plugin lifecycle and registration validated
  • Java -> Python execution bridge implemented
  • Extension data directory handling verified
  • Minimal Python entry point for execution testing

This MVP confirms that the extension:

  • installs cleanly
  • enables correctly via Ghidra’s plugin manager
  • executes code from the UI
  • provides a stable foundation for further development

Non-goals for this PR

This PR intentionally does not implement:

  • Full capa rule execution
  • Feature extractor integration
  • Rule management or selection UI
  • Result tree view
  • Program navigation, bookmarks, or highlighting
  • Full parity with the IDA capa explorer plugin

These will be implemented incrementally after architectural review.


Design notes

  • UI is implemented entirely in Java Swing, consistent with Ghidra plugin requirements
  • Python is used only for capa execution logic
  • No PyQt usage (Ghidra main-thread constraint)
  • Architecture mirrors the IDA explorer separation of concerns:
    • Java: UI and Ghidra integration
    • Python: capa execution and result processing
  • Extension is implemented alongside the existing script-based integration
    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
image

image

@google-cla
Copy link

google-cla bot commented Jan 26, 2026

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.

Copy link

@github-actions github-actions bot left a 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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Initial MVP for Capa Explorer Extension: This pull request introduces the Minimum Viable Product (MVP) for a capa explorer Ghidra extension, establishing the foundational architecture for integrating capa analysis directly into Ghidra.
  • Transition from Script-based to Extension-based Workflow: The new implementation moves away from the existing script-based Ghidra workflow, providing a proper, installable Ghidra extension that mirrors the IDA Pro capa explorer plugin experience.
  • Hybrid Architecture (Java UI, Python Logic): The extension utilizes Java Swing for its user interface and Ghidra integration, while employing a Python execution bridge to handle the core capa analysis logic, ensuring compatibility with Ghidra's main-thread constraints.
  • New 'Run capa analysis' Menu Action: A new menu action, 'Tools → Run capa analysis', has been added, allowing users to trigger capa analysis directly from the Ghidra UI.
  • Core Functionality Validation: The MVP successfully validates key functionalities, including clean installation, correct enablement via Ghidra’s plugin manager, and the ability to execute code from the UI, providing a stable base for future development.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@vaishakh787 vaishakh787 marked this pull request as ready for review January 26, 2026 13:16
@vaishakh787 vaishakh787 marked this pull request as draft January 26, 2026 13:22
@vaishakh787 vaishakh787 changed the title ghidra: initial capa explorer extension MVP ghidra: initial capa explorer extension MVP Jan 26, 2026
Copy link
Collaborator

@mike-hunhoff mike-hunhoff left a 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.

Comment on lines +42 to +48
Process process =
new ProcessBuilder(
python,
scriptFile.getAbsolutePath()
)
.redirectErrorStream(true)
.start();
Copy link
Collaborator

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 🙂

Copy link
Author

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 Program object 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants