Skip to main content

Khopesh

CI PyPI GitHub Marketplace Python Engines SARIF License: MIT

Khopesh (v1.2.2) is a zero-dependency, 9-engine network, CI/CD, and application vulnerability scanner built in Python 3.11+. Point it at an authorized IPv4/IPv6 host, CIDR subnet (up to /16), packet capture, web URL, or source code repository — it discovers open ports, fingerprints services across arbitrary ports, prioritizes CVEs with CISA KEV and FIRST EPSS, audits GitHub Actions workflows, exports CycloneDX v1.5 SBOMs, and supports inline suppression (# khopesh: ignore[...]) and --baseline diffing for CI/CD gates.


Nine Detection Engines

Network, Infrastructure & SOC Engines

  1. Network IPv4/IPv6 Port, Service Version & Hybrid CVE Scanner (KHOPESH-SCAN-*):
    • Scans authorized IPv4/IPv6 hosts, hostnames, or CIDR subnets up to /16 (IPv4) / /112 (IPv6) with ICMP/ARP/NDP/OUI/NetBIOS/OS discovery.
    • Performs port-agnostic multi-stage probing (server-first greeting + client-first HTTP/TLS fallback on arbitrary ports) and normalized version range comparison (SemVer, PEP 440, OpenSSH p1/p2, OpenSSL letter suffixes, last_affected, and introduced_exclusive).
    • Hybrid Vulnerability & Threat Intelligence (cve_intel.py, intel_updater.py, threat_intel.py): Loads schema v2 databases refreshed from NIST NVD CVE API 2.0, OSV.dev, CISA KEV, and FIRST EPSS via khopesh update-db (and weekly GitHub Actions), supplemented online by live NVD CPE 2.3 and FIRST EPSS lookups with 24h local caching.
  2. PCAP Network Traffic Forensics Engine (KHOPESH-NET-*):
    • Pure-Python binary libpcap (.pcap / .cap) parser detecting TCP SYN port scan sweeps (CWE-200), cleartext FTP/HTTP Basic credentials (CWE-319, redacted), and SMBv1 negotiations (CVE-2017-0144).
  3. Endpoint Socket, Process, Firewall & Reverse-Shell SOC Auditor (KHOPESH-HOST-*):
    • White-box host endpoint auditor (audit-host) correlating active sockets with Process Names & PIDs, checking Windows Firewall / UFW state, flagging exposed admin/DB listeners, and detecting Bind/Reverse Shells & C2 ports (MITRE ATT&CK T1059 / T1571).
  4. Passive TLS & HTTP Security Headers Auditor (KHOPESH-WEB-*):
    • Single passive TLS & HTTP compliance check verifying TLS version, HSTS, CSP, clickjacking headers, nosniff, version banner disclosure, and Set-Cookie flags.

Application, Supply-Chain & CI/CD Engines

  1. SAST Engine (KHOPESH-SAST-*):
    • Python AST with intraprocedural variable & taint tracking (CWE-89, CWE-78, CWE-95, CWE-502, context-aware CWE-327, CWE-295, CWE-377, CWE-489) plus a JavaScript/TypeScript lexical comment & static-literal stripper (CWE-79, CWE-95, CWE-78).
  2. Secret & Shannon Entropy Engine (KHOPESH-SEC-*):
    • Signature + Shannon entropy detection (CWE-798) with automatic snippet redaction.
  3. Dependency CVE / SCA Engine & CycloneDX v1.5 SBOM (KHOPESH-SCA-*):
    • Parses manifests and lockfiles (requirements.txt, pyproject.toml, poetry.lock, uv.lock, Pipfile.lock, package.json, package-lock.json, yarn.lock, pnpm-lock.yaml), queries OSV.dev with CVSS/severity extraction, enriches CVEs with CISA KEV & FIRST EPSS, and exports CycloneDX v1.5 JSON SBOMs (khopesh sbom or --sbom).
  4. Container & Config Hardening Engine (KHOPESH-CFG-*):
    • Audits Dockerfile, docker-compose.yml, and web configs (next.config.js, nginx.conf, vercel.json, netlify.toml).
  5. GitHub Actions CI/CD Supply-Chain Engine (KHOPESH-GHA-*):
    • Audits .github/workflows/*.yml and action.yml for dangerous pull_request_target / workflow_run head checkouts (KHOPESH-GHA-001), script injection via untrusted ${{ github.event.* }} contexts (KHOPESH-GHA-002), unpinned actions/reusable workflows/Docker tags (KHOPESH-GHA-003), missing or write-all permissions (KHOPESH-GHA-004), ACTIONS_ALLOW_UNSECURE_COMMANDS (KHOPESH-GHA-005), secrets: inherit (KHOPESH-GHA-006), persisted checkout credentials (KHOPESH-GHA-007), and self-hosted runners exposed to PRs (KHOPESH-GHA-008).

Benchmarks (Honest Measurement)

Full methodology, corpus fixtures, known biases, and miss/FP breakdowns are published in benchmark/README.md and run weekly in .github/workflows/benchmark.yml.

SAST Corpus Results (61 Labeled Files: 48 Python, 13 JS/TS)

Tool Scope Files TP FP FN Precision Recall F1
Khopesh v1.2.1 All (Python + JS/TS) 61 31 3 7 91.2% 81.6% 86.1%
Khopesh v1.2.1 Python only 48 24 2 7 92.3% 77.4% 84.2%
Bandit 1.9.4 Python only 48 26 17 5 60.5% 83.9% 70.3%

Known gaps measured by the hard test cases (documented transparently): interprocedural taint across helper returns, dict/list subscript taint, aliased imports (from os import system as s), insecure random token detection, and sanitizer recognition (shlex.quote, DOMPurify.sanitize).


Quick Start

Installation

pip install khopesh-sec

Or install from source for development:

git clone https://github.com/andronagy48-sudo/Khopesh.git
cd Khopesh
pip install -e ".[dev]"

Usage Examples

# 1. Refresh authoritative CVE, CISA KEV, and FIRST EPSS databases locally
khopesh update-db
khopesh db-info

# 2. Scan an IPv4/IPv6 host or CIDR subnet (up to /16) for open ports, versions, KEV/EPSS CVEs
khopesh netscan 192.168.1.10 --html net_report.html
khopesh netscan 2001:db8::1 --ports 22,80,443,8080

# 3. Scan a repository (SAST + Secrets + SCA + Config + GitHub Actions CI/CD + PCAP)
#    with inline `# khopesh: ignore[RULE-ID]`, `.khopeshignore`, `--baseline`, SARIF, and CycloneDX SBOM
khopesh scan ./my-app --sarif results.sarif --sbom bom.cdx.json --fail-on high
khopesh scan ./my-app --baseline previous.json --exclude "vendor/**" --fail-on medium

# 4. Export a standalone CycloneDX v1.5 JSON SBOM
khopesh sbom ./my-app -o bom.cdx.json

# 5. Audit local endpoint sockets, PIDs, firewall state, and C2/reverse-shell indicators
khopesh audit-host --html host_edr.html

# 6. Analyze a packet capture (.pcap) or passively audit a URL's TLS & HTTP headers
khopesh pcap ./traffic.pcap --html pcap_report.html
khopesh headers https://andro-dev.com --html web_headers.html

Use as a GitHub Action

- name: Run Khopesh
  uses: andronagy48-sudo/Khopesh@main
  with:
    path: "."
    fail-on: "high"
    sarif-file: "khopesh.sarif"
    sbom-file: "bom.cdx.json"

Quality Gates (Lint, Strict Typecheck & Coverage)

ruff check khopesh tests benchmark
mypy khopesh
pytest -v --cov=khopesh --cov-report=term-missing --cov-fail-under=80

Responsible Use

Khopesh is an authorized vulnerability assessment, hardening, and SOC analysis framework. Only run netscan / headers against hosts, lab environments, and networks that you own or have explicit permission to assess.


Author

Andro Nagy — Aspiring SOC Analyst & Cybersecurity Student
Portfolio: https://andro-dev.com/ · LinkedIn: Andro Nagy · TryHackMe: Andro48

Metadata

Release files for khopesh-sec 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for khopesh-sec 1.2.2
File Size Uploaded Provenance Actions
khopesh_sec-1.2.2.tar.gz 136.3 kB With provenance Details for khopesh_sec-1.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for khopesh-sec 1.2.2
File Interpreter ABI Platform Actions
khopesh_sec-1.2.2-py3-none-any.whl Python 3 none any Details for khopesh_sec-1.2.2-py3-none-any.whl

Total release size: 254.7 kB

Release files / khopesh_sec-1.2.2.tar.gz

Download URL khopesh_sec-1.2.2.tar.gz
Size 136.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6a534e609e3c90e909ff8a67febd140091169acf6088096eb21e3501fc902c54
BLAKE2b-256 checksum
How to use checksums
a5666953fa6559b843790a154a3d7befe149f02691617be517f9e6119d036cb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / khopesh_sec-1.2.2-py3-none-any.whl

Download URL khopesh_sec-1.2.2-py3-none-any.whl
Size 118.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8715986e0ccc7aea9d2fa31ea1f152ca3d300ed216b6b01542bb90cc47d7c180
BLAKE2b-256 checksum
How to use checksums
be48365eb1a434442cc8c76d546936f423bbfb1bcae3cb2137ed8600f83272ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for khopesh-sec 1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for khopesh_sec-1.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page