hardenship1.0.1
Defensive source-code security scanner, release-artifact hygiene gate, and layered software hardening plugin for coding agents.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
HardenShip
Zero-dependency SAST & secret scanner, release-artifact gate, STRIDE threat modeler, and 5-layer code hardening plugin for Claude Code, Pi Agent, Antigravity, Codex, Cursor, Gemini CLI, and OpenCode.
Install · Workflow · CLI Quickstart · 5-Layer Model · Harnesses · Rules
Why HardenShip?
Shipping desktop tools, CLIs, SDKs, or local-companion web apps fails in the same quiet ways:
- A bundler leaves
.js.mapsourcemaps orconsolelogs insidedist/. - A PyInstaller build ships
.pycproduct modules when an AOT Nuitka/Cython step was skipped. - A "sealed" client config embeds XOR/PBKDF2 key material right beside the ciphertext it decrypts.
- A local FastAPI/Express server leaves
/docsand/openapi.jsonenabled in production or passes session tokens in?k=query strings. - A secret hides in UTF-16-LE config data or inside a file larger than a naive scanner's size cutoff.
HardenShip combines a zero-dependency Node.js CLI (source scanner, release-folder gate, stack-aware 5-layer planner, SARIF 2.1.0 exporter) with cross-harness agent skills so both your CI pipeline and your coding agent enforce the same defensive engineering bar before anything ships.
Core rule: Obfuscation raises reverse-engineering cost. Only an authoritative trust boundary keeps a secret.
How It Works
flowchart LR
Repo["Source & Build Tree"] --> Map["1. Surface Map\nhardenship map ."]
Repo --> Scan["2. Static & Secret Scan\nhardenship scan .\n(UTF-8 + UTF-16-LE)"]
Map --> Audit["3. 3-Pass Invariant Audit\n& Fresh-Eyes Reviewers"]
Scan --> Audit
Audit --> Model["4. STRIDE Threat Model\n& 5-Layer Hardening Plan"]
Model --> Dist["5. Release Artifact Gate\nhardenship dist ./dist"]
Dist --> Verify["6. Verify & CI SARIF Gate\nGitHub Code Scanning"]
Install
Use HardenShip natively in your coding agent, through skills.sh, or directly via npx.
Claude Code
claude plugin marketplace add TranHoaiPhu/hardenship
claude plugin install hardenship@hardenship
Pi Coding Agent (pi.dev/packages)
Includes native Pi extension tools (hardenship_map, hardenship_scan, hardenship_dist, hardenship_plan), TUI commands (/hardenship-scan, /hardenship-map, /hardenship-dist), prompt templates, and all six skills:
# Install from npm
pi install npm:hardenship
# Or install directly from GitHub
pi install git:github.com/TranHoaiPhu/hardenship
# Try once without adding to settings
pi -e npm:hardenship
Antigravity
agy plugin install https://github.com/TranHoaiPhu/hardenship
OpenAI Codex CLI
codex plugin marketplace add TranHoaiPhu/hardenship
codex plugin add hardenship@hardenship
Gemini CLI
gemini extensions install https://github.com/TranHoaiPhu/hardenship
Vercel Agent Skills (skills.sh)
npx skills add TranHoaiPhu/hardenship
npm / Multi-Harness CLI Installer (Cursor, OpenCode, Copilot, Project-Scoped .agents/skills)
# Install skills into the current project (.agents/skills by default)
npx hardenship install
# Target specific harnesses (claude, antigravity, cursor, codex, gemini, opencode, copilot, pi, agents, all)
npx hardenship install --agent claude --agent cursor --scope project
# List every supported harness and native command
npx hardenship install --list
See docs/harnesses.md for the complete support matrix and verification details.
CLI Quickstart
Zero runtime dependencies. Requires Node.js 20+.
# 1. Map trust-boundary zones, API/IPC routes, and signing/CI posture
npx hardenship map .
# 2. Scan source code for trust-boundary flaws, secret leaks (UTF-8 + UTF-16-LE), and build gaps
npx hardenship scan .
# 3. Generate a repository-grounded STRIDE threat model
npx hardenship threat-model . --dist ./dist -o THREAT-MODEL.md
# 4. Gate a built release directory against sourcemaps, debug symbols, raw source, bytecode, and secrets
npx hardenship dist ./dist --fail-on high
# 5. Check Python AOT builds to assert zero uncompiled product .py/.pyc files remain
npx hardenship dist ./dist/MyApp --product-package myapp --fail-on high
# 6. Generate a stack-aware 5-layer defense-in-depth hardening plan
npx hardenship plan . --dist ./dist -o HARDENING-PLAN.md
# 7. Export SARIF 2.1.0 for GitHub Code Scanning
npx hardenship scan . --format sarif -o hardenship.sarif --fail-on high
Example Output
HardenShip Source Security Scan v1.0.0
Target: /workspace/my-desktop-app
Detected stacks: fastapi, python, pyinstaller, vite
Scanned 84 file(s) in 38ms
Score: 54/100 | Critical: 0 | High: 2 | Medium: 2 | Low: 1
Findings:
[HIGH] TB-001 src/app/sealed.py:29 - Client-side embedded key derivation or obfuscated secret unpacking
Detail: Key derivation/decryption routine paired with embedded static key/salt material in client code.
Fix: Obfuscating key material in client code does not create a secret boundary. Move credentials to an authenticated server API or use user-supplied short-lived tokens.
[HIGH] PKG-001 web/vite.config.ts:14 - Frontend sourcemaps enabled in production bundler config
Detail: Shipping JavaScript/TypeScript sourcemaps reconstructs full original frontend source code directly from production assets.
Fix: Set sourcemap: false (or devtool: false) for shipped builds; if crash symbolication is needed, upload private sourcemaps to an internal collector and strip them from dist/.
Agent Skills, Commands & Fresh-Eyes Reviewers
When installed as a plugin, coding agents load skills progressively and reason from verified repository maps, six architectural invariants, and isolated fresh-eyes review passes:
| Skill | Command | Purpose |
|---|---|---|
hardenship-audit |
/hardenship:audit |
3-pass source audit: surface cartography, first-principles invariant tracing, and multi-perspective cross-check. |
hardenship-threat-model |
/hardenship:threat-model |
Codebase-grounded STRIDE matrix, asset custody table, Mermaid trust-boundary map, and falsifiable CI requirements. |
hardenship-plan |
/hardenship:harden-plan |
Stack-specific 5-layer defense-in-depth hardening roadmap with runnable acceptance checks. |
hardenship-dist-gate |
/hardenship:dist-gate |
Release-folder inspection for leaked sourcemaps, bytecode, .pdb, .env, backups, secrets, and signatures. |
hardenship-trust-boundary |
— | Step-by-step migration of embedded client secrets and local privilege checks behind server authority. |
hardenship-verify |
/hardenship:verify |
Evidence-before-completion gate proving every implemented fix with fresh scans, negative tests, and score deltas. |
Read-only reviewer personas in agents/: security-auditor.md, trust-boundary-reviewer.md, packaging-supply-chain-reviewer.md, runtime-ipc-reviewer.md, and hardening-architect.md.
5-Layer Hardening Model
HardenShip organizes recommendations from strongest security boundary to automated verification:
| Layer | Focus | Concrete Controls |
|---|---|---|
| Layer 0: Trust Boundaries | True secrecy & authorization | Move static API keys, tokens, and admin/entitlement checks to an authenticated server; issue short-lived signed grants. |
| Layer 1: Compilation & Bundle Hygiene | Raise offline inspection cost | Native AOT compilation (Nuitka, Cython, NativeAOT, stripped Rust/Go LTO), sourcemap: false, esbuild.drop, Electron Fuses, zero raw helper source or .pdb in dist/. |
| Layer 2: Signing & Integrity | Tamper resistance | OS code signing (Authenticode / Apple notarization / Sigstore), Ed25519-signed files.sha256 and update/policy manifests verified fail-closed. |
| Layer 3: Runtime & Local IPC | Shrink local attack surface | Bind loopback APIs to 127.0.0.1, disable production OpenAPI/Swagger and DevTools, eliminate URL query tokens (?k=), validate archive extraction paths. |
| Layer 4: CI/CD Release Gates | Stop regressions automatically | Block PRs and releases on hardenship scan --format sarif and hardenship dist --fail-on high. |
GitHub Actions CI Integration
name: HardenShip Security Gate
on: [push, pull_request]
jobs:
hardenship:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Run HardenShip source audit (SARIF)
run: npx hardenship scan . --format sarif -o hardenship.sarif --fail-on high
- name: Upload SARIF to GitHub Code Scanning
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: hardenship.sarif
Suppressing Known Exceptions
- File/directory exclusions: create
.hardenshipignoreat the repository root using gitignore-style globs (one per line,#for comments). Patterns without a slash match at any depth (*.min.js), a leading/anchors to the root (/legacy), and**matches zero or more directories (docs/**/generated). Negation (!pattern) is not supported. - Single-line suppression: append
hardenship-ignore: RULE-IDin a comment on the specific line (for example,# hardenship-ignore: TB-003). - Non-shipped trees: files under test, fixture, example, template, benchmark, and docs directories (and
*_test.go,test_*.py,*.test.ts,*.spec.js) are scanned for leaked secrets only. Pass--include-teststo apply every rule there. - Comments: structural rules skip whole-line comments; secret patterns (
SEC-001..SEC-003) still scan them.
Exit Codes
| Code | Meaning |
|---|---|
0 |
Success; no finding met the --fail-on threshold (default none). |
1 |
At least one finding met or exceeded --fail-on, or doctor validation failed. |
2 |
Usage or runtime error (unknown option, invalid --format/--fail-on, missing directory). |
Options accept both --flag value and --flag=value.
Scope & Honest Limits
- HardenShip is strictly a defensive static analyzer, release-surface auditor, and architecture guide. It does not disassemble binaries, run exploit payloads, or attempt to bypass software protections.
- Zero findings from a static scan is not a formal proof of security; use
hardenship scanandhardenship distalongside code review, dependency auditing, and signed release pipelines. - Secret scanning never prints matched credential values to stdout, stderr, JSON, Markdown, or SARIF output.
Development
npm run validate # Verify all 8 multi-harness manifests, skills, and relative links
npm test # Run Node.js unit and CLI integration test suite
npm run self-scan # Dogfood HardenShip against itself
npm run check # Run all checks in sequence
Support
If hardenship caught a leak or tightened a release pipeline for your team, consider starring the repository, opening ideas in GitHub Discussions, or supporting ongoing maintenance via GitHub Sponsors.
License
MIT © Tran Hoai Phu