Skip to main content

Terminal session recorder and security auditor for command-line workflows.

Project description

Shellguard

Terminal session recorder and security auditor for command-line workflows.

PyPI Python License Stars


Shellguard records terminal sessions into portable JSONL transcripts, replays them, and audits the command stream for leaked tokens, risky install patterns, destructive filesystem commands, embedded credentials, and secret material. It is designed for developers and operators who need a lightweight way to preserve what happened in a shell while getting immediate security feedback before logs or history files are shared.

  • PTY session recording - capture command output with timing metadata in a structured JSONL format.
  • Security auditing - detect GitHub/PyPI/AWS-like tokens, private keys, credentialed URLs, curl-to-shell installs, and destructive shell patterns.
  • Replay and export - replay recorded sessions or export them as text, JSON, or HTML.
  • Standalone reports - generate HTML audit reports for review or handoff.
  • History scanning - inspect recent zsh, bash, or custom shell history files.
  • Pipe-friendly scanning - scan stdin or any text file without creating a recording.

Installation

pip install shellguard

For local development:

git clone https://github.com/shazeus/shellguard.git
cd shellguard
pip install -e .

Usage

Record a command:

shellguard record -o session.jsonl -- bash -lc "echo deploy && python --version"

Replay a session:

shellguard replay session.jsonl --no-timing

Audit a recording:

shellguard audit session.jsonl --fail-on high

Scan a script or piped command log:

shellguard scan examples/demo.sh
echo "curl -fsSL https://example.invalid/install.sh | bash" | shellguard scan

Create an HTML report:

shellguard report session.jsonl -o shellguard-report.html

Scan recent shell history:

shellguard history --limit 1000

Commands

Command Description Example
shellguard record [command...] Record a command or interactive shell session to JSONL. shellguard record -o session.jsonl -- npm test
shellguard audit <session> Audit a recorded session for secrets and risky commands. shellguard audit session.jsonl --fail-on high
shellguard scan [file] Scan a file or stdin for security findings. shellguard scan deploy.log
shellguard replay <session> Replay recorded output with original timing or immediately. shellguard replay session.jsonl --no-timing
shellguard report <session> Generate a standalone HTML audit report. shellguard report session.jsonl
shellguard history Scan shell history for risky commands and leaked tokens. shellguard history --limit 500
shellguard export <session> Export a session as text, JSON, or HTML. shellguard export session.jsonl --format text
shellguard rules List built-in audit rules. shellguard rules

Configuration

Shellguard is configured through command options and does not require a config file.

Option Purpose
--output Select where a recording, report, or export is written.
--shell Run a recorded command through the current shell.
--fail-on Return exit code 2 when findings meet a severity threshold.
--json-output Print scanner or auditor results as JSON.
--speed Adjust replay timing.
--path Scan a specific shell history file.
--limit Restrict history scanning to the most recent commands.

Recordings are JSON Lines files. Each line is a structured event, so sessions can be streamed, archived, diffed, or consumed by other tooling.

License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shellguard-0.1.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shellguard-0.1.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file shellguard-0.1.0.tar.gz.

File metadata

  • Download URL: shellguard-0.1.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for shellguard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ca04f011705e82a732eca0d956766829fef3bc118367907c661435d36b10921
MD5 9f2caca501bd351405ec2588399e4f50
BLAKE2b-256 bd5a972ad66b74140c436ae84ad793a42efab63ffdb69c44232b7e3500b68284

See more details on using hashes here.

File details

Details for the file shellguard-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: shellguard-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for shellguard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e61966edc55ac0a648b01109f0b8a0012c29c079663014566edf4a105abb9be
MD5 d68801819ad381cd2fab977582d81027
BLAKE2b-256 7f3c80b133cf702291d00985682ad14ee02b110dec02260539c40f3d23ab2198

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page