Commit e9fa9a3
authored
capstone, upx, fq: complete the reverse-engineering workbench (#549)
* capstone: package the disassembly framework 5.0.9
The disassembler engine underneath most open reverse-engineering tooling,
packaged as a shared library so consumers can link it rather than vendor it.
BUILD_SHARED_LIBS defaults to OFF upstream (and BUILD_STATIC_LIBS to ON), so a
stock build ships libcapstone.a only. Anything linking that absorbs capstone
statically, which puts a capstone CVE beyond pkgscan's reach entirely — nothing
in the consumer's tree would name capstone at all. Shared on, static off, and
the `ships_shared_lib` test pins it rather than trusting the flag.
Tests disassemble real bytes across five architectures, including two fringe
ones (riscv64, ppc64be), because CAPSTONE_ARCHITECTURE_DEFAULT gates every
per-arch support option at once: turning it off yields a cstool that builds,
runs, and reports the same version while silently having lost whole
architectures. A deliberate no-such-arch case is included as a control, so the
greps cannot pass on an error message.
5.0.9 rather than 6.0.0-Alpha10: the 6.0.0 alphas are tagged prerelease=false
on GitHub but are alphas by name. Note rizin does NOT consume this — it pins
capstone "next" (the unreleased v6) and vendors it, as recorded in that package.
* upx: package the executable packer 5.2.0
The standard tool for unpacking UPX-compressed binaries, which is most of what
an RE workbench wants it for.
Three things worth a reviewer's attention:
Vendored compressors are STRUCTURAL here, not a config choice. vendor/ carries
ucl, lzma-sdk, zlib, zstd and bzip2, and the CMake build offers no
find_package() or system-lib option at all — unlike rizin, where seventeen
use_sys_* flags existed and flipping them was the whole job. It is not an
oversight either: upx's output is read back by a decompression stub welded onto
the packed executable, so compressor and stub must agree bit-for-bit. The
consequence is stated rather than left to be discovered — those five libraries
are invisible to pkgscan on this package, permanently.
The source is not fetched with extract = true. Upstream compresses the -src
tarball with an xz SHA-256 integrity check (xz --list reports Check: SHA-256,
not the usual CRC64) and the fetcher's decoder rejects it:
compression error: Unsupported SHA-256 checksum (not yet implemented)
build.sh unpacks it with the system tar instead.
runtime_deps carries libstdc++/libgcc beyond glibc — found by the checker, not
guessed: with glibc alone even `upx --version-short` died with "error while
loading shared libraries: libstdc++.so.6".
The test packs a real binary, EXECUTES the packed copy and compares its output
to the original, then unpacks and cmp's byte-for-byte. Nothing cheaper works:
`upx --version` runs without touching a compressor, and `upx --best` will
happily produce a file that is smaller and completely unrunnable if the
per-architecture stub is wrong.
* fq: package the binary-format query tool 0.17.0
jq for binaries: ~120 format decoders behind a jq expression language, which
makes "what is in this file, structurally" scriptable across a corpus rather
than a thing you do one file at a time in a hex editor.
Built CGO_ENABLED=0 (upstream's own setting), so the result is a pure-Go static
binary with no DT_NEEDED — hence the empty runtime_deps, same shape as helm. If
CGO ever creeps back in, the missing-runtime_deps checker is what notices.
No -X version stamping: fq keeps its version as a plain const in fq.go, and the
Go linker only rewrites vars — a -ldflags -X aimed at a const is silently
ignored, which is the kind of thing that looks maintained and does nothing.
The test decodes rather than smoke-tests. `fq --version` and even `fq -n '1+1'`
pass on a build whose format decoders are all broken, since the jq engine and
the decoders are separate packages and only the decoders are the reason to ship
this. So it asserts on a gzip's INFLATED payload — proving the DEFLATE decoder
ran and returned the original bytes — not merely on the header field, and adds
a second decoder (ELF) over a real file. The expected ELF machine is derived
from uname rather than hardcoded, after an earlier package in this loadout
pinned an architecture literal and only failed once it reached amd64 CI.
* capstone, upx: record the aggregate licence, not the headline one
Both packages declared a single licence where the shipped artifact carries
more than one. The repo already models this — 54 packages use compound SPDX
expressions — so these were simply wrong, not stylistically different.
capstone: the tree ships LICENSE.TXT (BSD-3-Clause) AND LICENSE_LLVM.TXT for
the decoders generated from LLVM's tables. My comment claimed that second file
was "Apache-2.0 WITH LLVM-exception". It is not: capstone 5.x predates LLVM's
relicensing and the file is the old LLVM Release License, i.e. University of
Illinois/NCSA. Now (BSD-3-Clause AND NCSA), with the comment corrected.
upx: was GPL-2.0-or-later alone, which omits the vendored code compiled into
the binary. Established from the build rather than from the vendor/ listing,
which turns out to overstate it in one direction and understate it in another:
ucl GPL-2.0-or-later linked (own CMake target)
zlib Zlib linked (own CMake target)
lzma-sdk public domain linked INVISIBLY — compress_lzma.cpp #includes
its .cpp files directly, so it never appears as
its own objects in the ninja log
doctest MIT linked the same way, via src/check/dt_impl.cpp;
this release binary carries its test framework
bzip2 — NOT linked; CMakeLists.txt:269 hard-disables it
zstd — NOT linked; CMakeLists.txt:270 hard-disables it
So (GPL-2.0-or-later AND Zlib AND MIT); the LZMA SDK is public domain and adds
no conditions and no SPDX identifier. The earlier claim that five vendored
libraries ride invisibly in this package was wrong in both directions — it is
three, and two of the five named are not in the binary at all.1 parent 3ccfc4f commit e9fa9a3
6 files changed
Lines changed: 481 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments