Metadata-Version: 2.4
Name: vibeguard-gate
Version: 0.6.0
Summary: Guardrails for vibe-coded software — a pre-merge safety gate for AI-generated changes
Project-URL: Homepage, https://github.com/dgenio/vibeguard
Project-URL: Repository, https://github.com/dgenio/vibeguard
Project-URL: Issues, https://github.com/dgenio/vibeguard/issues
Project-URL: Changelog, https://github.com/dgenio/vibeguard/releases
Author: VibeGuard Contributors
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Keywords: ai,code-review,devtools,security,static-analysis
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Requires-Dist: pathspec>=0.12.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0.0
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
Requires-Dist: typer>=0.12.0
Provides-Extra: dev
Requires-Dist: mypy>=1.10.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
Description-Content-Type: text/markdown

# VibeGuard

**Guardrails for vibe-coded software.**

> "AI coding tools made it cheap to generate code. They did not make it cheap to trust code."

[![CI](https://github.com/dgenio/vibeguard/actions/workflows/ci.yml/badge.svg)](https://github.com/dgenio/vibeguard/actions/workflows/ci.yml)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
[![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](LICENSE)

---

## The Problem

AI coding tools let developers ship in hours what used to take days. That is genuinely great. But accepting large AI-generated diffs without scrutiny creates a new failure mode that traditional security tools were not designed to catch:

- **Accidentally committed secrets** — API keys, tokens, and database URLs sneak in through AI-generated config files
- **Package publish leaks** — source maps, .env files, and test fixtures end up in npm/PyPI packages
- **Dependency supply chain risks** — AI agents pull in git URLs, typosquatted packages, or broad version ranges
- **Security control bypasses** — AI comments out auth checks or disables SSL verification to "make things work"
- **Risky code changes without tests** — huge diffs touching auth, crypto, and database writes with zero test coverage
- **AI footprints** — placeholder credentials, `# TODO: implement real auth`, and `trust all certificates`

## Why VibeGuard Exists

VibeGuard is **not** another AI wrapper, SAST scanner, or dependency checker.

It is a **fast, deterministic pre-merge safety gate** specifically designed for the failure modes of AI-assisted coding ("vibe coding"). It runs in seconds, works offline, and requires no API key.

Think of it as the check between "AI generated this diff" and "this diff reaches production."

## What It Catches

| Category | Examples |
|---|---|
| 🔑 **Secrets** | AWS keys, GitHub tokens, OpenAI keys, database URLs, private keys, .env files |
| 🗺️ **Source maps** | .map files in dist/, sourceMappingURL in bundles, npm packages that publish maps |
| 📦 **Packaging leaks** | .env, tests/, .github/, source maps in npm/PyPI packages |
| 🔗 **Dependency risks** | git/URL deps, typosquatted packages, unpinned versions (strict mode) |
| ⚠️ **Risky code patterns** | eval/exec, shell=True, JWT verify=False, CORS wildcard, pickle.loads, SQL construction |
| 🧪 **Missing tests** | Source changes with no corresponding test changes |
| 🤖 **AI footprints** | Placeholder creds, disabled auth, trust-all-certs, TODO stubs, temporary bypasses |

---

## Quickstart

```bash
pip install vibeguard
```

Or from source:

```bash
git clone https://github.com/dgenio/vibeguard
cd vibeguard
pip install -e ".[dev]"
```

Initialize a config file:

```bash
vibeguard init
```

Scan a directory:

```bash
vibeguard scan --path .
```

Gate your CI (exits 1 if blocking findings found):

```bash
vibeguard gate --diff --fail-on high
```

---

## CLI Reference

### `vibeguard init`

Creates a `vibeguard.yaml` config file with sensible defaults.

```bash
vibeguard init
vibeguard init --path /path/to/repo
```

### `vibeguard scan`

Scans a repository and prints findings. **Always exits 0** (informational).

```bash
vibeguard scan
vibeguard scan --path .
vibeguard scan --diff                  # only changed files (requires git)
vibeguard scan --json                  # machine-readable output
vibeguard scan --markdown              # for PR comments
vibeguard scan --verbose               # detailed descriptions
vibeguard scan --fail-on medium        # set threshold (informational only)
```

### `vibeguard gate`

Same as `scan` but **exits 1** when findings meet or exceed the threshold.

```bash
vibeguard gate --path . --fail-on high
vibeguard gate --diff --fail-on medium
```

### `vibeguard publish-check`

Simulate `npm publish` or `python -m build` and gate on findings in the
published file set, before anything reaches the registry.

```bash
vibeguard publish-check --path .
vibeguard publish-check --ecosystem npm --manifest-out publish-manifest.json
vibeguard publish-check --ecosystem python-sdist --fail-on medium
```

See [docs/pre-publish.md](docs/pre-publish.md) for the full guide,
finding IDs, and a GitHub Actions release-gate template.

### `vibeguard explain <finding-id>`

Print a detailed explanation and remediation guide for a finding.

```bash
vibeguard explain SEC-ENV
vibeguard explain MAP-DIST
vibeguard explain TEST-MISSING
```

---

## Example Output

```
                         VibeGuard Findings
┌──────────┬──────────────┬─────────────────────────────┬──────────────────────────────────────┐
│ Sev      │ Rule         │ Path                        │ Title                                │
├──────────┼──────────────┼─────────────────────────────┼──────────────────────────────────────┤
│ ☠ CRIT   │ secrets      │ .env                        │ Sensitive file committed: .env       │
│ ☠ CRIT   │ secrets      │ src/server.js:9             │ GitHub Token detected                │
│ ✗ HIGH   │ sourcemaps   │ dist/app.js.map             │ Source map file in publish directory │
│ ✗ HIGH   │ dependencies │ package.json                │ URL/git/path dependency: axios       │
│ ✗ HIGH   │ packaging    │ package.json                │ npm package may publish .env files   │
│ ⚠ MEDIUM │ risky_diff   │ src/server.js:24            │ Risk-sensitive area: eval() usage    │
│ ⚠ MEDIUM │ ai_footprints│ src/server.js:14            │ AI footprint: security disabled      │
│ ↓ LOW    │ tests        │ src/server.js               │ Source changes without test changes  │
└──────────┴──────────────┴─────────────────────────────┴──────────────────────────────────────┘

  Scanned 6 file(s)  •  8 finding(s)  |  critical: 2  high: 3  medium: 2  low: 1  •  policy: balanced

✗ Gate failed: findings at or above high severity detected.
```

Try it yourself:

```bash
vibeguard scan --path examples/vulnerable-node-package
vibeguard gate --path examples/vulnerable-python-package --fail-on medium
```

---

## Policy Levels

| Policy | Description |
|---|---|
| `relaxed` | Only critical and high findings |
| `balanced` | High + medium findings (default) |
| `strict` | All findings; unpinned dependencies and missing tests are elevated |

Set in `vibeguard.yaml`:

```yaml
policy: strict
fail_on: medium
```

Or override on the command line:

```bash
vibeguard gate --fail-on medium
```

---

## Configuration

Run `vibeguard init` to create a `vibeguard.yaml`:

```yaml
policy: balanced
fail_on: high

ignore:
  paths:
    - .git/
    - node_modules/
    - .venv/
    - dist/
    - build/
  findings: []        # suppress specific finding IDs

secrets:
  enabled: true
  min_entropy: 3.5

sourcemaps:
  enabled: true

packaging:
  enabled: true

dependencies:
  enabled: true

risky_patterns:
  enabled: true

tests:
  enabled: true

ai_footprints:
  enabled: true
```

---

## GitHub Actions Usage

Add to your pull request workflow:

```yaml
name: VibeGuard
on: [pull_request]
jobs:
  vibeguard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - run: pip install vibeguard
      - run: vibeguard gate --diff --fail-on high
```

For local development (before publishing to PyPI):

```yaml
      - run: pip install -e .
      - run: vibeguard gate --fail-on high
```

---

## Rules

### `secrets` — Secret Detection

Detects likely committed secrets using regex patterns and Shannon entropy heuristics.

Patterns: AWS access keys, GitHub tokens, OpenAI keys, private keys, bearer tokens, Stripe keys, Slack tokens, hardcoded passwords, database URLs with credentials, committed `.env` files.

### `sourcemaps` — Source Map Exposure

Source maps in distribution directories expose your original source code to anyone who downloads your package or opens browser DevTools.

Checks: `.map` files in `dist/`, `build/`, `public/`; `sourceMappingURL` comments in JS bundles; `package.json` `files` arrays that include `.map` patterns.

### `packaging` — Packaging Hygiene

Checks common package manifests for files that should not be published.

Checks: `package.json`, `.npmignore`, `pyproject.toml`, `MANIFEST.in`, `setup.cfg`.

Flags: `.env` files, test directories, source maps, `.github/`, coverage reports, broad include patterns.

### `dependencies` — Dependency Risk

Checks for risky dependency declarations.

Flags: git/URL/path dependencies (bypass registry integrity), typosquatting-like package names (heuristic), broad version constraints in strict mode.

### `risky_diff` — Risky Code Patterns

Flags changes to security-sensitive areas for human review. **Does not claim a vulnerability** — says "risk-sensitive area changed, human review recommended."

Areas: auth/authz, crypto, eval/exec, subprocess/shell, file deletion, network calls, database writes, payment logic, CORS, SQL construction, deserialization, JWT handling, certificate validation.

### `tests` — Missing Tests

If source files changed but no test files changed, emits a low/medium finding.

### `ai_footprints` — AI Footprint Detection

Detects common AI-generated artifacts that indicate incomplete, insecure, or placeholder code.

Patterns: AI generation comments, placeholder credentials, disabled security controls, trust-all-certs, CORS wildcards, temporary bypasses, skip-validation patterns, hallucinated TODO stubs.

---

## Roadmap

### v0.1 (current)
- [x] Deterministic local scanner
- [x] CLI (`scan`, `gate`, `init`, `explain`)
- [x] Config file with policy levels
- [x] All core rules: secrets, sourcemaps, packaging, dependencies, risky patterns, tests, AI footprints
- [x] Console, JSON, Markdown reporters
- [x] GitHub Actions integration
- [x] Example vulnerable packages

### v0.2
- [ ] SARIF output for GitHub Code Scanning
- [ ] GitHub PR comment reporter
- [ ] Baseline file (suppress existing findings, only alert on new ones)
- [ ] More language-specific rules (Go, Ruby, PHP)
- [ ] `.vibeguardignore` file support

### v0.3
- [ ] Package publish simulation (`vibeguard publish-check`)
- [ ] npm/PyPI pre-publish hooks
- [ ] Dependency reputation checks (via public advisories)
- [ ] Diff size / big-diff warning

### v0.4
- [ ] Optional LLM explanation mode (bring your own key)
- [ ] VS Code / IDE extension
- [ ] Policy packs for startups, enterprise, OSS maintainers
- [ ] Pre-commit hook integration

---

## Philosophy

VibeGuard is not a replacement for:
- SAST tools (Semgrep, CodeQL, Bandit)
- Secret scanners (truffleHog, gitleaks)
- Dependency scanners (Dependabot, Snyk, pip-audit)
- Human code review

It is a **fast first gate** specifically for the failure modes of AI-assisted coding — the things that fall through because the diff is too large to review carefully, or because AI agents bypass security controls to make things work quickly.

The goal is to catch the 80% of AI-coding mistakes in 5 seconds before your existing tools and reviewers spend time on a fundamentally broken diff.

**Deterministic > AI-powered for this use case.** No hallucinations, no API costs, no false confidence from an LLM that thinks the code looks fine.

---

## Contributing

Contributions welcome. See the [issues page](https://github.com/dgenio/vibeguard/issues) for ideas.

```bash
git clone https://github.com/dgenio/vibeguard
cd vibeguard
pip install -e ".[dev]"
pytest
ruff check vibeguard/ tests/
```

---

## License

Apache 2.0 — see [LICENSE](LICENSE).
