JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 53
  • Score
    100M100P100Q86173F
  • License MIT

Pre-commit security gate for OWASP Top 10 2021 — SAST, SCA and misconfig checks for Node/Express, Go and React codebases

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sec-gate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    sec-gate

    npm version npm downloads License: MIT Node.js OWASP Top 10


    A pre-commit security gate that automatically blocks vulnerable code before every git commit. Covers SAST · SCA · Misconfigurations · SQL Injection · Hardcoded Secrets and more.


      git commit  →  sec-gate scans  →  vulnerability?  →  BLOCKED ✗
                                     →  clean?          →  committed ✓

    ⚡ Quick Start

    # Step 1 — Install globally (once per machine)
    npm install -g sec-gate
    
    # Step 2 — Hook into your repo (once per clone)
    cd your-project
    sec-gate install
    
    # Step 3 — Commit as normal — scans run automatically
    git commit -m "your changes"

    That's it. No config needed. No extra tools to install. Everything is bundled.


    🛡️ What gets scanned

    Layer Tool What it catches
    SAST Semgrep + AST rules SQL injection, XSS, command injection, hardcoded secrets
    SCA OSV-Scanner Known CVEs in npm/pnpm/yarn dependencies
    GO govulncheck Known CVEs in Go modules
    CUSTOM acorn AST walker Prototype pollution, insecure random, eval injection

    🔴 What blocked output looks like

    sec-gate: scan started (staged files)
    sec-gate: excluding 3 high-noise rule(s)
    sec-gate: scanning src/services/payment.js (js) with owasp-top10 rules...
    
    sec-gate: SECURITY FINDINGS (commit blocked):
    
    - src/services/payment.js:40 [CRITICAL] [sql-injection-template-literal] (A03:2021 Injection)
      SQL query built with template literal interpolation.
      Use parameterized queries: sequelize.query(sql, { replacements: [...] })
    
    - src/services/payment.js:82 [LOW] [insecure-object-assign] (A01:2021)
      Object.assign with potentially user-controlled data.
    
    - package-lock.json [OSV:GHSA-r5fr-rjxr-66jc]
      lodash: vulnerable to Code Injection via _.template

    🟢 What a clean commit looks like

    sec-gate: scan started (staged files)
    sec-gate: excluding 3 high-noise rule(s)
    sec-gate: all checks passed — no vulnerabilities found by sec-gate
    sec-gate: checks ran: SAST (3 files), SCA-node (package-lock.json)

    🗂️ OWASP Top 10 (2021) Coverage

    # Category Status
    A01 Broken Access Control covered
    A02 Cryptographic Failures covered
    A03 Injection (SQL · XSS · CMD) covered
    A04 Insecure Design covered
    A05 Security Misconfiguration covered
    A06 Vulnerable Components covered
    A07 Authentication Failures covered
    A08 Software Integrity Failures covered
    A09 Security Logging Failures covered
    A10 Server-Side Request Forgery covered

    🔧 All Commands

    sec-gate install        # Install/inject pre-commit hook (auto-detects husky, lefthook etc.)
    sec-gate scan           # Scan all tracked files
    sec-gate scan --staged  # Scan only staged files
    sec-gate doctor         # Diagnose installation issues
    sec-gate --version      # Print installed version
    sec-gate --help         # Show help

    🔕 Suppressing False Positives

    Two formats supported — use whichever you prefer:

    Short format (quick)

    // sec-gate-disable: sql-injection-template-literal
    const rawQuery = `SELECT * FROM payments WHERE status = '${status}'`;

    Long format (recommended for PRs — shows reason)

    // security-scan: disable rule-id: sql-injection-template-literal reason: status validated against enum
    const rawQuery = `SELECT * FROM payments WHERE status = '${status}'`;

    Suppress all rules on a line

    // sec-gate-disable: *
    dangerousLegacyFunction();

    ⚙️ Configuration (.sec-gate.yml)

    Create this file in your project root to tune the scanner:

    # .sec-gate.yml
    
    # Block only on high/critical findings
    severity_threshold: high
    
    # Exclude specific rules globally
    exclude_rules:
      - path-join-resolve-traversal
      - detect-non-literal-regexp
    
    # Skip test and mock files
    exclude_paths:
      - "**/__tests__/**"
      - "**/*.test.js"
      - "**/mocks/**"
    
    # Toggle scanners
    sca: true
    custom_rules: true
    📋 All severity threshold options
    Value Blocks on
    all (default) Every finding
    high High + Critical only
    critical Critical only
    medium Medium + High + Critical
    low Everything (same as all)

    🪝 Hook Manager Support

    sec-gate install automatically detects your hook manager — no manual config needed:

    Tool Detection Auto-injected
    Husky .husky/ directory .husky/pre-commit
    Husky package.json hooks ✅ prepended to command
    lefthook lefthook.yml ✅ priority 1 command
    simple-git-hooks package.json ✅ prepended to command
    pre-commit .pre-commit-config.yaml ✅ local hook entry
    bare git no manager .git/hooks/pre-commit

    🔒 Supported Package Managers

    npm pnpm yarn go


    🚨 Emergency Bypass

    # Skip the scan for this commit only (emergency use only)
    SEC_GATE_SKIP=1 git commit -m "emergency fix"

    ⚠️ This only skips the local pre-commit hook. CI will still catch it.


    👥 Team Auto-Setup

    Add to your project's package.json so every developer gets the hook automatically on npm install:

    {
      "scripts": {
        "prepare": "sec-gate install"
      }
    }

    Then new developer onboarding is just:

    npm install -g sec-gate   # once per machine
    npm install               # installs hook automatically via prepare script

    🏗️ How it works internally

    git commit
        │
        ▼
    pre-commit hook
        │
        ├── Load .sec-gate.yml config
        │
        ├── SAST ──► Semgrep (owasp-top10)
        │        ──► AST walker (acorn) — SQL injection, secrets, prototype pollution
        │
        ├── SCA  ──► osv-scanner (npm/pnpm/yarn lockfile)
        │        ──► govulncheck (go.mod)
        │
        ├── Apply inline suppressions (sec-gate-disable / security-scan: disable)
        │
        ├── Apply config filters (exclude_rules, exclude_paths, severity_threshold)
        │
        ├── Findings? → exit 1 → commit BLOCKED ✗
        └── Clean?   → exit 0 → commit proceeds ✓

    Built with ❤️ to make security automatic, not optional.

    npm GitHub