ilmanzo / ilmanzo/BinaryCoverage
Reliable direct detection of an already-shimmed binary
- Dominant language
- C
- Stars
- 9
- Forks
- 6
- Avg merge
- 1h 32m
- Merged PRs (30d)
- 11
Description
`install` (cmd/shim.go:45-47) refuses to re-shim a binary today, but only
indirectly: it checks whether a backup file exists at
`SAFE_BIN_DIR/`. That's sidecar bookkeeping, not inspection of the
target binary itself — if the backup is missing (wiped SAFE_BIN_DIR, manual
cleanup, state drift) the check false-negatives and `install` will shim an
already-shimmed binary, silently burying the real original underneath.
We need a function that looks at an arbitrary ELF file and reliably answers
"is this a funkoverage shim?" by inspecting the file directly, independent of
SAFE_BIN_DIR state. Two consumers:
- `install()` should call it as an additional guard alongside the existing
SAFE_BIN_DIR check.
- #105 wants an `is-shimmed` / `is-installed` subcommand , it's the same primitive.
Constraint: `funkoverage-shim` is built with `-ldflags="-s -w"` (build.sh:32),
so symbol table and DWARF are stripped. Detection can't rely on looking up an
exported symbol name. Two options that survive stripping:
- Embed a fixed marker string constant in the shim_binary source (lands in
`.rodata` regardless of stripping) and scan candidate files for it.
- Hash/byte-compare the candidate against the current `funkoverage-shim`
reference binary (already locatable via `findShimBinary()`, cmd/shim.go:283).
- don't build stripped shim (keep this option as last resort)
Scope: a new function alongside `isELF` / `hasDebugInfo` (cmd/elfutil.go),
wired into `install()`'s existing check.
Related to #105.
Contributor guide
No contributing guide indexed for this repository
Research direction
Read cmd/elfutil.go, especially isELF and hasDebugInfo, then inspect the existing guard in cmd/shim.go:45-47 and findShimBinary() at cmd/shim.go:283. Review build.sh:32 and the shim_binary source to choose a marker or reference-binary approach that survives stripping. Done means direct detection works for arbitrary ELF files and install() uses it alongside the SAFE_BIN_DIR check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- devtools, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100