This repository was archived by the owner on Jul 5, 2026. It is now read-only.
Repo hardening: fix install instructions, dead imports, hygiene#1
Open
cognis-digital wants to merge 4 commits into
Open
Repo hardening: fix install instructions, dead imports, hygiene#1cognis-digital wants to merge 4 commits into
cognis-digital wants to merge 4 commits into
Conversation
- fix 2 broken `pip install` line(s) in README (package is not on PyPI; use the working git+https install) - remove 6 unused import(s) (ruff F401/F811)
74e7b58 to
0d8ea4f
Compare
… scripts Test fixes: - core.py: add shannon_entropy, sniff_filetype, file_hashes helpers; implement xor string modifier, uint8/uint16/uint32 condition functions, entropy and filetype condition variables, fix comment stripper, hex literal parsing; parse_rules raises ValueError on empty input; ScanResult gains entropy/filetype/hashes - cli.py: add info subcommand, -e/--expr flag to scan, enrich scan JSON output - tests/test_smoke.py: rewrite stale tests to use actual API - demos/02-deep: add triage.yar with XOR/entropy rules, decode suspicious_sample.bin from base64 fixture - DEFAULT_RULES: add High_Entropy_Blob and XOR_Encoded_MZ rules Enrichment: add plain-language overview section to README, install section, install.sh and install.ps1 scripts, layman.md summary.
| r"\(|\)|,|\.\.|>=|<=|==|!=|>|<|" | ||
| r"\b(?:and|or|not|of|them|all|any|at|in|filesize|entropy|filetype|" | ||
| r"uint8|uint16|uint32|true|false)\b|" | ||
| r"[#$@!][\w*\[\]0-9]*|" |
added 2 commits
June 13, 2026 09:19
- core.py: parse_rules() now validates that input is a str (raises ValueError with a clear message for None/int/bytes); re.error from an invalid regex pattern in a rule string is caught and re-raised as ValueError so callers only need to handle one exception type. - core.py: _parse_xor_range() clamps byte values to [0,255] and normalises an inverted range (lo > hi) by swapping endpoints, preventing silent zero-iteration XOR scans. - cli.py: _cmd_scan, _cmd_rules, and _cmd_compile now catch re.error in addition to OSError/ValueError so a bad regex in a rules file or inline expression always exits with rc=2 and a clear stderr message rather than an unhandled traceback. - mcp_server.py: fix broken import of non-existent 'to_json'; fix scan() call to read file bytes before calling scan(); add per-call error handling so the MCP tool returns a JSON error dict instead of crashing. - tests/test_hardening.py: 17 new tests covering bad-regex rules, non-string input to parse_rules, missing files (exit 2), inverted/ out-of-range XOR parameters, and edge cases (empty bytes, empty rules list, zero-length data).
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR applies a few small, mechanically-verified hardening fixes found by an automated audit of the Cognis suite:
pip installline(s) in README (package is not on PyPI; use the working git+https install)Each change is deterministic; all touched Python files were confirmed to still compile (
py_compile) before this PR was opened.