One way to read any codebase: C, C++, PHP, Perl, Java and binaries in the same shape
Eptalights Researchcode-analysisEptaKode Analysis5 min
Most code investigations don’t start with a clever idea. They start with a folder of someone else’s code and a deadline.
The folder might be a C or C++ service nobody has touched in six years, a PHP storefront with a decade of plugins, a pile of Perl scripts that quietly run payroll, a Java app that only exists as a jar, or a closed-source binary with no source at all. The first few days go to the same boring question: how do I even get this into a form I can reason about?
That is the part we keep building tools for.
Read the compiler’s version, not ours
A regex can tell you a function is called. It can’t tell you where a variable came from, which branch skips the check, or what the value looks like by the time it reaches the database. For that you need what the compiler or interpreter sees: instructions, control flow, data flow.
So our extractors don’t parse code the way a text tool does. They borrow the real front end for each language, or a disassembler’s own view of a binary.
- C and C++ run through a GCC plugin. We take GIMPLE, the compiler’s own intermediate form, straight out of the build.
- PHP is read by an extractor that embeds the actual PHP engine. You get the Zend opcodes for every function, plus the control flow graph, data flow and SSA for each one.
- Perl goes through PPI. Every token and structure in the file ends up in the output, and we check that the tree can be turned back into the exact source.
- Java and other JVM languages are read from compiled bytecode through SootUp, which gives us Jimple, so Kotlin, Scala and Groovy come along for free.
- Compiled binaries come from a Binary Ninja plugin. It exports the high-level IL (HLIL) for each function, and optionally the strings and data variables, so code you only have as an executable can be analyzed like the rest.
Five extractors, five different tricks. The result on disk looks the same to the next stage: one JSON file per function (or per class, or per file for Perl) that our engine can lift into Sophia-IR.
The part nobody wants to do by hand
Getting the compiler to cooperate with a project you didn’t write is where the time goes. Missing headers. A Perl module that isn’t installed. A top-level PHP script with a single function so large that the engine’s own analysis gives up on it (we had to fix that one in PHP itself).
We decided that shouldn’t be your problem. The source-code extractors now share one workflow, and the only thing you install is Docker:
make extract-image
make extract-init PROJECT=~/code/their-app PACK=~/packs/their-app
make extract-run PROJECT=~/code/their-app PACK=~/packs/their-app
Your project is mounted read-only and never touched. The container carries the toolchain: GCC and CMake for C and C++, the PHP engine, Perl with PPI, and the bytecode reader for Java. Java is read from classes and jars you have already built; we don’t compile it for you.
Binaries are the exception. Binary Ninja is a desktop tool, so that extractor runs as a plugin inside it: open the binary, choose the Eptakode extractor from the plugin menu, tick HLIL (and strings and data if you want them), and pick an output folder. The output goes to the same next stage.
“It finished” is not the same as “it worked”
This is the thing we care about most, and the thing most extraction scripts skip. A run that exits cleanly can still have produced half a pack: files that failed to compile, functions with no body, an output folder that doesn’t match what the tool claims it wrote.
So every run ends by checking its own work and printing a short verdict as the last line:
{"status": "needs_attention", "exit_code": 2,
"files": {"total": 6970, "ok": 6944, "syntax_error": 8, "crashed_or_timeout": 18},
"problems": ["18 file(s) crashed or timed out ..."],
"next": ["exclude the crashing files via extract.exclude, or raise extract.timeout_per_file"]}
Pass, needs attention or failed, with a plain reason and the next thing to try. A person can read it. A script, or a coding agent, can act on it. We built it so that you can hand a new codebase to either one and get back something you can trust, or a clear list of what’s wrong.
It’s been run against real projects, not just toy examples. One of the PHP test runs covered a commercial application of nearly seven thousand files and well over seventy thousand functions, and the same checks that caught a crash on a handful of enormous functions are the reason that bug got fixed instead of buried.
Why this matters
When every language comes out in the same shape, the analysis stops being language-specific. The same questions work everywhere: what reaches this call, where is this value defined, which paths skip this check. Variant analysis stops being “find this bug in this repo” and becomes “find this bug anywhere we can read”.
If your team inherits code, buys a company, or just needs to know what a dependency really does, that’s the difference between a week of setup and an afternoon.
Try it on your code
We’re working with engineering and security teams on code review, due diligence and variant analysis across C/C++, PHP, Java, Perl and compiled binaries. If you’ve got a codebase you need to understand, book a demo and bring the ugliest one you have.
Filed under code-analysis