feat: add ARM disassembler operation#2156
Conversation
GCHQDeveloper581
left a comment
There was a problem hiding this comment.
At the moment this is pulling in capstone.min.js in two different ways (through the "@alexaltea/capstone-js" package, and through the vendor import) but only using the vendor import version.
I've checked and the package version can be used by changing the import in src/core/operations/DisassembleARM.mjs to
import cs from "@alexaltea/capstone-js/dist/capstone.min.js";
which still passes all your tests, and seems to work in browser.
This would be the slightly preferred method if there's not otherwise a problem with the npm package as it saves cluttering up the code base with additional vendor imports.
If the vendor import version is needed (and in which case there should be a test that distinguishes between the package and vendor import versions to avoid someone "cleaning up" at a later date) then the vendor import will need something at the top to establish provenance (where you've pulled it in from, and in particular what the "upstream bug fix" is), and to establish the MIT license that covers the code.
Either way the one you aren't using wants to be removed.
Otherwise looks pretty good (though I note there's currently a merge conflict).
Add new Disassemble ARM operation using Capstone.js disassembly framework. Features: - ARM32 (ARM mode, Thumb mode, Thumb + Cortex-M, ARMv8) - ARM64 (AArch64) - Little/Big Endian support - Configurable start address - Optional hex and position display Includes vendored capstone.min.js with fix for cs_disasm parameter bug.
Replace the vendored capstone.min.js with the import from the @alexaltea/capstone-js npm package, as suggested in code review. This avoids duplicating the library in the repository while the npm dependency was already declared in package.json.
0eff656 to
6b88ed4
Compare
|
Thanks for the review. I've switched to using the npm package import ( The upstream bug fix is a single line: the Also rebased onto current master so the merge conflict is resolved. |
GCHQDeveloper581
left a comment
There was a problem hiding this comment.
Looks good! Thanks for your contribution.
Summary
Details
Supported Architectures
Features
Why Capstone?
Capstone is the industry standard disassembly framework used by:
This ensures accurate disassembly for security research and binary analysis.
Test plan
11 automated tests covering ARM32, ARM64, and Thumb modes
Manual test vectors
ARM32:
Input: 0100a0e3 001081e0 001041e0
Output:
mov r0, #1
add r1, r1, r0
sub r1, r1, r0
ARM64:
Input: fd7bbfa9 fd030091 c0035fd6
Output:
stp x29, x30, [sp, #-0x10]!
mov x29, sp
ret
Thumb:
Input: 80b5 0844 80bd
Output:
push {r7, lr}
add r0, r1
pop {r7, pc}
Files changed
package.jsonsrc/core/operations/DisassembleARM.mjssrc/core/vendor/capstone.min.jssrc/core/config/Categories.jsontests/operations/tests/DisassembleARM.mjstests/operations/index.mjs