Skip to content
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
mainfrom
cognis-audit/repo-hardening
Open

Repo hardening: fix install instructions, dead imports, hygiene#1
cognis-digital wants to merge 4 commits into
mainfrom
cognis-audit/repo-hardening

Conversation

@cognis-digital

@cognis-digital cognis-digital commented Jun 12, 2026

Copy link
Copy Markdown
Owner

This PR applies a few small, mechanically-verified hardening fixes found by an automated audit of the Cognis suite:

  • 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)

Each change is deterministic; all touched Python files were confirmed to still compile (py_compile) before this PR was opened.

- 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)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first PR! 🚀 A maintainer will review under the collaboration-pull model (see CONTRIBUTING.md).

@cognis-digital cognis-digital force-pushed the cognis-audit/repo-hardening branch from 74e7b58 to 0d8ea4f Compare June 12, 2026 22:06
… 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.
Comment thread yararun/core.py Outdated
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]*|"
Cognis Digital 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).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants