Deep expansion: test suite, CI, docs, batch/Markdown companion, and roadmap - #1
Open
cognis-digital wants to merge 1 commit into
Open
Deep expansion: test suite, CI, docs, batch/Markdown companion, and roadmap#1cognis-digital wants to merge 1 commit into
cognis-digital wants to merge 1 commit into
Conversation
Tests & CI:
- Add a pytest suite: 36 Python unit tests for the SARIF/YARA/Markdown
companion (report normalisation, rendering, batch aggregation, CI gate,
error paths) plus 12 end-to-end tests that build packpeek.c and exercise
verdicts, exit codes, offsets, --threshold, and error handling. C tests
skip automatically when no compiler is present.
- Extend the CI workflow with dedicated pytest and flake8 jobs and new smoke
checks for the Markdown output and the --fail-on gate; keep all existing
C build/verdict steps.
- Add pyproject.toml (packaging + pytest config, `packpeek-sarif` entry
point) and requirements-dev.txt.
Docs:
- Overhaul README: overview, architecture diagram, install/build, usage,
configuration reference, exit-code table, companion reference, and FAQ.
Replace the placeholder "Example output" with a real packpeek report.
- Add docs/ARCHITECTURE.md (JSON contract, verdict logic, entropy, signature
table, companion internals) and docs/USAGE.md (worked examples).
- Add ROADMAP.md (near/mid/long-term direction and non-goals).
Features (companion, additive):
- Markdown summary output (--md/--markdown).
- Batch input: accept a single report, a JSON array, or newline-delimited
JSON; aggregate SARIF (one result per non-clean file), YARA (union of
markers), and Markdown (one row per file with worst-verdict footer).
- CI gate: --fail-on {clean,likely-packed,packed} exits non-zero on the worst
verdict without altering emitted output.
Refactor:
- Type hints, docstrings, and shared helpers (load_reports, worst_verdict,
_MARKERS) with no change to existing single-report SARIF/YARA behavior.
Backward compatible: no files removed, no existing flags or JSON fields
changed; new capabilities are opt-in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
packpeekis a solid, single-purpose triage tool, but before this PR the repository had no automated test suite (only inline CI smoke commands), the README's "Example output" block showed a generic placeholder unrelated to the tool (apacks/weight/contentsschema that packpeek never emits), and the Python companion could only produce SARIF and YARA for one report at a time.This PR raises the repo to production grade across four axes — tests/CI, docs, features, and internal cleanup — while remaining strictly additive: nothing is removed, and every existing flag, entry point, and JSON field keeps its meaning and output.
What changed
Tests & CI
tests/suite (48 tests).tests/test_sarif.py— 36 Python unit tests for the companion: report normalisation (single object / JSON array / NDJSON / blank lines / garbage), SARIF rendering (packed→error, likely→warning, clean→no results, rule declaration, batch aggregation), YARA (family→marker mapping, dedup, sorted family names, batch union, worst-verdict meta), Markdown,worst_verdict, and fullmain()behavior over stdin/files including the--fail-ongate and every error path.tests/test_packpeek_c.py— 12 end-to-end tests that compilepackpeek.cand drive the real binary: packed/clean/likely verdicts, exit codes, marker offset accuracy, family de-duplication,--thresholdbehavior, missing-file / no-input /--helphandling, JSON schema completeness, and a pipe into the companion. These skip automatically when no C compiler is available (via thepackpeek_binsession fixture intests/conftest.py)..github/workflows/ci.yml) now has three jobs: the existingbuild-test(C build + verdict smoke tests, plus new Markdown and--fail-ongate checks), apytestjob (installsrequirements-dev.txtand runs the full suite), and alintjob (flake8 syntax/undefined-name checks).PYTHONUTF8=1is set workflow-wide.pyproject.toml(setuptools build, pytest config, and apackpeek-sarifconsole entry point) andrequirements-dev.txt.Docs
docs/ARCHITECTURE.md— the JSON contract, verdict truth-table, entropy formula, signature-table design, and companion internals.docs/USAGE.md— worked examples for SARIF, YARA, Markdown, batching, CI gating, and programmatic use.ROADMAP.md— near/mid/long-term direction and explicit non-goals.Features (companion, additive)
python sarif.py --md/--markdownrenders a summary table (one row per file) with a worst-verdict footer. Great for PR comments.for f in *; do packpeek "$f"; done | python sarif.pyworks. SARIF gains one result per non-clean file, YARA unions every detected marker, Markdown renders every row.--fail-on {clean,likely-packed,packed}exits2when the worst verdict across all inputs meets the level, without changing the emitted document (so you canteethe report and still gate).Refactor (no behavior change)
sarif.py; extracted shared helpers (load_reports,worst_verdict,_result_for,_MARKERS,_parse_args).to_sarif/to_yaraaccept a singledictor a list; the single-dictpath is byte-for-byte identical to the previous output (covered by a test).Test results
Locally (Windows, no C toolchain): 36 passed, 12 skipped (C tests skip without a compiler). On CI (ubuntu, gcc present) all 48 run. flake8 selection
E9,F63,F7,F82passes clean.Run it yourself:
New usage examples
Backward compatibility
Additive only. No files or public functionality removed. Existing
packpeekflags/exit codes and the emitted JSON contract are unchanged; the companion's default (no-flag) SARIF and--yaraoutputs are unchanged for a single report. All new capabilities are opt-in.Checklist