Skip to content

Repo hardening: fix install instructions, dead imports, hygiene#1

Open
cognis-digital wants to merge 3 commits into
mainfrom
cognis-audit/repo-hardening
Open

Repo hardening: fix install instructions, dead imports, hygiene#1
cognis-digital wants to merge 3 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 3 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 3 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 75cfb11 to d7bddf4 Compare June 12, 2026 21:57
Cognis Digital added 2 commits June 13, 2026 04:16
…e overview and install instructions

The CLI's --format option was only registered on the top-level parser,
so passing it after the 'analyze' subcommand ('analyze <file> --format json')
caused argparse to reject it with 'unrecognized arguments'. Added --format to
the analyze subparser (with None default so the top-level value still acts as
fallback) and updated _cmd_analyze to merge both levels. All 13 tests now pass.

Also inserted a plain-language "What is this?" section into README.md,
refreshed install.sh, and added install.ps1 for Windows users.
- cli.py: validate --port in range 1-65535, exit 2 with clear message
- cli.py: add per-connection recv timeout (30s) to prevent hanging on
  stalled/hostile clients; guard MBAP struct.unpack in serve loop
- cli.py: cap MBAP body read to 260 bytes to block memory-exhaustion
  via oversized length field
- cli.py: catch UnicodeDecodeError from binary files passed as hexlog,
  surface as clean error/exit 2 instead of raw traceback
- core.py: cap build_response coil/register quantities at Modbus spec
  maximums so byte-count field never overflows (was crashing on qty>2040)
- mcp_server.py: fix dead imports (scan/to_json do not exist); wire to
  analyze_capture instead; guard empty hexlog input
- tests/test_hardening.py: 10 new tests covering missing file, binary
  file, empty input, oversized quantity, out-of-range port, no subcommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant