mandiant / Ghidrathon

The FLARE team's open-source extension to add Python 3 scripting to Ghidra.
Apache License 2.0
696 stars 54 forks source link

Build failure: "error: cannot find symbol import db.Transaction;" in GhidrathonConsoleInputThread #80

Closed binaryninja closed 1 year ago

binaryninja commented 1 year ago

I was able to pip install jeb after installing vs/c++ build tools

I am attempting to build Ghidrathon 3.x on windows and failing 3.0 and 3.0.1

I am using gradle 8.2, Ghidrathon-3.0.1, jdk-17

Problem: The build fails. with the following error:

C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\src\main\java\ghidrathon\GhidrathonConsoleInputThread.java:13: error: cannot find symbol
import db.Transaction;
         ^
  symbol:   class Transaction
  location: package db
C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\src\main\java\ghidrathon\GhidrathonConsoleInputThread.java:143: error: cannot find symbol
    try (Transaction tx = program != null ? program.openTransaction("Ghidrathon console command") : null) {
         ^
  symbol:   class Transaction
  location: class GhidrathonConsoleInputThread
C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\src\main\java\ghidrathon\GhidrathonConsoleInputThread.java:143: error: cannot find symbol
    try (Transaction tx = program != null ? program.openTransaction("Ghidrathon console command") : null) {
                                                   ^
  symbol:   method openTransaction(String)
  location: variable program of type Program
3 errors

Full Error/Log output follows:

Starting 8th build in daemon [uptime: 24 mins 52.588 secs, performance: 100%, GC rate: 0.00/s, heap usage: 0% of 512 MiB, non-heap usage: 21% of 384 MiB]
Using 32 worker leases.
Now considering [C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main, C:\Users\UserName\Downloads\Ghidrathon-3.0.1\Ghidrathon-3.0.1] as hierarchies to watch
Watching the file system is configured to be enabled if available
File system watching is active
Starting Build
Settings evaluated using settings file 'C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\settings.gradle'.
Projects loaded. Root project using build file 'C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\build.gradle'.
Included projects: [root project 'Ghidrathon-main']

> Configure project :
Evaluating root project 'Ghidrathon-main' using build file 'C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\build.gradle'.
Using Ghidra install directory C:\Users\UserName\Downloads\ghidra_10.2.3_PUBLIC_20230208\ghidra_10.2.3_PUBLIC
file or directory 'C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\src\global', not found
All projects evaluated.
No tasks specified. Using project default tasks 'buildExtension'
Task name matched 'buildExtension'
Selected primary task 'buildExtension' from project :
The configuration :mainSourceElements is both consumable and declarable. This combination is incorrect, only one of these flags should be set.
Tasks to be executed: [task ':installJep', task ':copyJepNativeBinaries', task ':copyDependencies', task ':compileJava', task ':processResources', task ':classes', task ':indexHelp', task ':buildHelp', task ':jar', task ':zipSource', task ':buildExtension']
Tasks that were excluded: []
Resolve mutations for :installJep (Thread[Execution worker,5,main]) started.
:installJep (Thread[Execution worker Thread 5,5,main]) started.

> Task :installJep
Caching disabled for task ':installJep' because:
  Build cache is disabled
Task ':installJep' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command 'python''. Working directory: C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main Command: python -m pip install jep
Successfully started process 'command 'python''
Requirement already satisfied: jep in c:\users\UserName\appdata\local\programs\python\python311\lib\site-packages (4.1.1)
Resolve mutations for :copyJepNativeBinaries (Thread[Execution worker Thread 5,5,main]) started.
:copyJepNativeBinaries (Thread[Execution worker Thread 21,5,main]) started.

> Task :copyJepNativeBinaries
Caching disabled for task ':copyJepNativeBinaries' because:
  Build cache is disabled
Task ':copyJepNativeBinaries' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command 'python''. Working directory: C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main Command: python util\configure_jep_native_binaries.py
Successfully started process 'command 'python''
2023-09-25 13:49:19,229 INFO     Searching for Jep Python module directory
2023-09-25 13:49:19,229 INFO     Found Jep Python module directory at C:\Users\UserName\AppData\Local\Programs\Python\Python311\Lib\site-packages\jep
2023-09-25 13:49:19,229 INFO     Copying jep.dll and C:\Users\UserName\AppData\Local\Programs\Python\Python311\Lib\site-packages\jep\jep-4.1.1.jar to extension folders
2023-09-25 13:49:19,230 INFO     Done
Resolve mutations for :copyDependencies (Thread[Execution worker Thread 21,5,main]) started.
:copyDependencies (Thread[Execution worker Thread 21,5,main]) started.

> Task :copyDependencies NO-SOURCE
Watching 2 directory hierarchies to track changes
Skipping task ':copyDependencies' as it has no source files and no previous output files.
Resolve mutations for :compileJava (Thread[Execution worker Thread 21,5,main]) started.
:compileJava (Thread[Execution worker Thread 21,5,main]) started.

> Task :compileJava
Caching disabled for task ':compileJava' because:
  Build cache is disabled
Task ':compileJava' is not up-to-date because:
  No history is available.
The input changes require a full rebuild for incremental task ':compileJava'.
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
Compiling with toolchain 'C:\Program Files\Java\jdk-17'.
Compiling with JDK Java compiler API.
C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\src\main\java\ghidrathon\GhidrathonConsoleInputThread.java:13: error: cannot find symbol
import db.Transaction;
         ^
  symbol:   class Transaction
  location: package db
C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\src\main\java\ghidrathon\GhidrathonConsoleInputThread.java:143: error: cannot find symbol
    try (Transaction tx = program != null ? program.openTransaction("Ghidrathon console command") : null) {
         ^
  symbol:   class Transaction
  location: class GhidrathonConsoleInputThread
C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main\src\main\java\ghidrathon\GhidrathonConsoleInputThread.java:143: error: cannot find symbol
    try (Transaction tx = program != null ? program.openTransaction("Ghidrathon console command") : null) {
                                                   ^
  symbol:   method openTransaction(String)
  location: variable program of type Program
3 errors

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --scan to get full insights.

BUILD FAILED in 4s
3 actionable tasks: 3 executed
Watched directory hierarchies: [C:\Users\UserName\Downloads\Ghidrathon-main\Ghidrathon-main, C:\Users\UserName\Downloads\Ghidrathon-3.0.1\Ghidrathon-3.0.1]
mike-hunhoff commented 1 year ago

Thank you for reporting @binaryninja. It appears that the AutoCloseable Transaction API was added in Ghidra 10.3 (see https://github.com/NationalSecurityAgency/ghidra/commit/1795c35dfc13866e4234d89f7833e836989ede3b). Therefore, the latest version of Ghidrathon must be used with Ghidra >= 10.3 (I see that you're using Ghidra 10.2.3). I'll update Ghidrathon's README to reflect this.

Please reopen this issue if you continue to experience build issues with Ghidra >= 10.3.