Skip to content
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

Ghidra 11.2 issues #30

Merged
merged 13 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Publish Tagged Commit to PyPI
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"
workflow_dispatch:
inputs:
workflow-ghidra-ver:
description: 'Specify Ghidra Version to Build'
description: "Specify Ghidra Version to Build"
required: true
type: string
default: 'latest'
default: "latest"
schedule:
- cron: "0 13 * * 3"

Expand All @@ -36,7 +36,7 @@ jobs:
echo "GHIDRA_VER=$(echo ${{steps.get_latest_ghidra_ver.outputs.release}} | cut -d_ -f2)" >> $GITHUB_ENV
- name: Set Ghidra Version from Input
if: github.event_name == 'workflow_dispatch' && github.event.inputs.workflow-ghidra-ver != 'latest'
run: |
run: |
echo "GHIDRA_VER=$(echo ${{github.event.inputs.workflow-ghidra-ver}})" >> $GITHUB_ENV
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -52,7 +52,7 @@ jobs:
needs:
- set-versions
runs-on: ubuntu-20.04
outputs:
outputs:
already-exists: ${{ contains( steps.self.outputs.release, needs.set-versions.outputs.pyi-rel-ver ) }}
steps:
- id: self
Expand All @@ -64,7 +64,7 @@ jobs:
echo "Ghidra ver: ${{ needs.set-versions.outputs.ghidra-ver }} PYI ver: ${{ needs.set-versions.outputs.pyi-ver }} PYI Release: ${{needs.set-versions.outputs.pyi-rel-ver}} Current Release: ${{steps.self.outputs.release }}"
echo "already exists ${{ contains( steps.self.outputs.release, needs.set-versions.outputs.pyi-rel-ver ) }}"
build-n-publish:
needs:
needs:
- set-versions
- check-release
if: needs.check-release.outputs.already-exists == 'false' || (github.event_name == 'workflow_dispatch' && github.event.inputs.workflow-ghidra-ver != 'latest')
Expand All @@ -80,21 +80,16 @@ jobs:
- name: Set up JDK 1.11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

distribution: "temurin"
java-version: "21"

- uses: er28-0652/setup-ghidra@master
with:
version: "${{ needs.set-versions.outputs.ghidra-ver }}"

- name: Prepare Jython Environment
run: |
mkdir -p "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.2/Lib/site-packages"
cp -r vendor/* "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.2/Lib/site-packages/"

mkdir -p "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.3/Lib/site-packages"
cp -r vendor/* "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.3/Lib/site-packages/"
run: |
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /tmp tmp -scriptPath $(pwd) -preScript vendor_packages.py

- name: Build Package
run: |
Expand Down Expand Up @@ -128,13 +123,10 @@ jobs:
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


- name: Release on GitHub
uses: softprops/action-gh-release@v1
with:
files: ./dist/*
tag_name: "v${{ needs.set-versions.outputs.pyi-rel-ver }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


21 changes: 8 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
workflow_dispatch:
inputs:
workflow-ghidra-ver:
description: 'Specify Ghidra Version to Build'
description: "Specify Ghidra Version to Build"
required: true
type: string
default: 'latest'
default: "latest"

jobs:
set-versions:
Expand All @@ -33,7 +33,7 @@ jobs:
echo "GHIDRA_VER=$(echo ${{steps.get_latest_ghidra_ver.outputs.release}} | cut -d_ -f2)" >> $GITHUB_ENV
- name: Set Ghidra Version from Input
if: github.event_name == 'workflow_dispatch' && github.event.inputs.workflow-ghidra-ver != 'latest'
run: |
run: |
echo "GHIDRA_VER=$(echo ${{github.event.inputs.workflow-ghidra-ver}})" >> $GITHUB_ENV
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -56,21 +56,16 @@ jobs:
- name: Set up JDK 1.11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

distribution: "temurin"
java-version: "21"

- uses: er28-0652/setup-ghidra@master
with:
version: "${{ needs.set-versions.outputs.ghidra-ver }}"

- name: Prepare Jython Environment
run: |
mkdir -p "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.2/Lib/site-packages"
cp -r vendor/* "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.2/Lib/site-packages/"

mkdir -p "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.3/Lib/site-packages"
cp -r vendor/* "$GHIDRA_INSTALL_DIR/Ghidra/Features/Python/data/jython-2.7.3/Lib/site-packages/"
run: |
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /tmp tmp -scriptPath $(pwd) -preScript vendor_packages.py

- name: Build Package
run: |
Expand Down Expand Up @@ -99,4 +94,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
path: dist
12 changes: 9 additions & 3 deletions pythonscript_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import os

import ghidra.python.PythonScript
import ghidra

try:
import ghidra.python.PythonScript as PythonScript
except ImportError:
# 11.2 renamed everything to Jython
import ghidra.jython.JythonScript as PythonScript

import helper
import type_extractor
Expand Down Expand Up @@ -49,13 +55,13 @@ def is_ghidra_value(value):
def is_ghidra_method(value):
return (
type(value).__name__ == 'instancemethod'
and getattr(value, 'im_class', None) == ghidra.python.PythonScript
and getattr(value, 'im_class', None) == PythonScript
)


def is_instance_property(name):
try:
getattr(ghidra.python.PythonScript, name)
getattr(PythonScript, name)
except AttributeError as e:
if e.args[0].startswith('instance attr:'):
return True
Expand Down
6 changes: 6 additions & 0 deletions vendor_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import site
import shutil
import os.path

os.system("mkdir -p %s" % (os.path.dirname(site.getsitepackages()[0]), ))
shutil.copytree(os.path.join(os.path.dirname(__file__), "vendor"), site.getsitepackages()[0])
Loading