# @al1prahman/slopgate 中文文档

规范地址：https://npmcn.com/package/%40al1prahman/slopgate/

版本：1\.0\.9
npm 元数据更新时间：2026-11-03T16:00:23.942Z
中文译文更新时间：2026-11-08T08:34:06.861Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40al1prahman/slopgate
原文对照：https://npmcn.com/package/%40al1prahman/slopgate/?lang=original
项目主页：https://github.com/al1prahman/slopgate#readme
源码仓库：https://github.com/al1prahman/slopgate

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：198 kB，47 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：\>=22\.13\.0
- 运行依赖：2 个
- 首次发布：2026-11-03T04:01:30.370Z
- 最新版本发布：2026-11-03T16:00:23.731Z
- 近 30 天下载量：1853（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：11（近 12 个月 11 个）

## 中文简介

Git-native 安全门 阻止AI编码代理 航运 幻觉依赖和泄露秘密

## 安装

```sh
npm install @al1prahman/slopgate
```

也可以使用：`pnpm add @al1prahman/slopgate`、`yarn add @al1prahman/slopgate`、`bun add @al1prahman/slopgate`

## README

# 斜门 qq

**停止你的AI编码代理 运输幻觉依赖和泄露秘密.**

`slopgate` 是一个为气相编码时代而建的土生土长的安全门。 它扫描代理授权的 diffs _在此之前_ 他们着陆了 封锁那些不存在的软件包名称(slopsquatting) 和不应该承诺的证书.

[![CI](https://github.com/al1prahman/slopgate/actions/workflows/ci.yml/badge.svg)](https://github.com/al1prahman/slopgate/actions) [![npm version](https://img.shields.io/npm/v/@al1prahman%2Fslopgate.svg)](https://www.npmjs.com/package/@al1prahman/slopgate) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://npmcn.com/package/%40al1prahman/slopgate/LICENSE)

> **状态 :** MVP + 导入扫描 + 出错警告 + GitHub Action/SARIF + 代理承诺检测完成 – 252 测试为绿色, [发布到 npm](https://www.npmjs.com/package/@al1prahman/slopgate)22.13(使用内置) `node:sqlite` 模块——零本土依赖.

* * *

## 为什么会这样

AI编码代理快速写入代码. 他们也写 _已损坏_ 代码快 :

-   **~19.7% (中文(简体) )** aI生成的代码样本参考包 **不存在** (Cloud Security Conference, 2026)——攻击者登记那些准确的幻觉取名来毒害下一个安装. 这是 _挤压_。 。 。 .
-   Claude 代码协助 犯下暴露秘密 **经常超过2×** (GitGuardian, 2026年).
-   CVES 正式归属于 AI 生成的代码跳出 **2026年1月6起改为2026年3月35起**。 。 。 .

现有工具不涵盖: `gitleaks`编号 :`trufflehog` 找到一般的秘密 但不知道依赖幻觉。 商业供应链平台虽然存在,但并不具有自定义性、自定义性或免费性. `slopgate` 完全填补了这个空白:一个命令,运行在你的钩子,阻断承诺.

## 它会做什么

| 层 | 接头 | 流动人口调查 |
| --- | --- | --- |
| 秘密扫描 | API 密钥、 令牌、 私钥、 添加行中的 DB URL | ✅ |
| 📦 Slopsquat 防火墙 | Npm/ PyPI 中不存在的新解析器, 或存在但为 1–2 从通俗名称编辑的新解析器 | ✅ |
| 导入扫描 | 迷幻剂 `import`编号 :`require` 更改文件中的语句( JS/ TS + Python,别名- 意识) | ✅ |
| 代理人承诺检测 | 由编码代理撰写的旗帜( Name`Co-Authored-By: Claude`,"被赐与" | ✅ |
| GitHub 动作 | SARIF 关于 PR diff + 简要评论的说明 | ✅ |

## 快开始

```bash
# inside any repo
npx @al1prahman/slopgate init

# commit as usual — the hook does the rest
git commit -m "add fetch util"
```

多么糟糕的事业 看起来像:

```
$ git commit -m "add scraping deps"
slopgate: scanning 2 files, +34 -2 lines

  ✗ SECRET   src/fetch.ts:12    anthropic-api-key   ***...        [BLOCK]
  ✗ SLOP     requirements.txt:4 'reqeusts' not found on PyPI
                                → did you mean 'requests'?         [BLOCK]
  ⚠ SLOP     src/scrape.py:8    'beaufitulsoup' is 91% similar to
                                'beautifulsoup4' (registered 12 days ago)  [WARN]

commit blocked. 2 blocking findings.
  --no-verify to override (don't).
```

退出代码 : `0` - 干净 `1` 警告(非封锁) `2` 关闭.

## 配置

`init` 生成 `.slopgate.yml`数字 :

```yaml
mode: block                # block | warn | off
secrets:
  enabled: true
  ignore:
    - '**/*.test.*'
deps:
  enabled: true
  ecosystems: [npm, pypi]
  registries:
    npm: https://registry.npmjs.org
    pypi: https://pypi.org/pypi
  custom-index: []         # internal registries to check first
  allowlist: []            # trusted internal package names
  quarantine: false        # hold installs instead of blocking commit
  typosquat:
    enabled: true          # warn on young look-alikes of popular packages
    max-distance: 2        # edits from a popular name (0-5)
    max-age-days: 90       # packages younger than this look seeded
  cache:
    positive-ttl-hours: 24    # how long an "exists" verdict is trusted
    negative-ttl-minutes: 60  # how long a "missing" verdict is re-checked
python:
  unmapped-imports: warn   # import names with no known package mapping
imports:
  enabled: true            # scan import statements, not just manifests
agent:
  enabled: true            # flag agent-authored commits in range scans
```

手动扫描 :

```bash
slopgate scan --staged        # what pre-commit runs
slopgate scan --range origin/main..HEAD
slopgate scan --json          # machine-readable
slopgate scan --format sarif  # SARIF 2.1.0 for code scanning upload
slopgate scan --mode warn     # downgrade blocks to warnings for this run
slopgate scan --offline       # cache-only; registry misses warn (fail-open)
slopgate cache                # cache stats (path, entries, size)
slopgate cache clear          # drop the local verdict cache
```

## GitHub 动作

`.github/workflows/slopgate.yml` 在任何还款中:

```yaml
name: slopgate
on: pull_request
permissions:
  contents: read
  pull-requests: write      # for the summary comment
  security-events: write    # for the SARIF upload
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0    # the action needs the base ref for the diff
      - uses: al1prahman/slopgate@v1
        with:
          mode: block       # or warn — never fails the PR, just comments
```

调查结果 土地作为内部说明 `github/codeql-action/upload-sarif`)和作为对公关的一个高调的评论. 输入 : `range`, (中文(简体) ), `mode`, (中文(简体) ), `comment`, (中文(简体) ), `token`, (中文(简体) ), `version`。 。 。 .

## 代理授权犯罪

范围扫描( R)`--range`, 预推钩, GitHub 动作) 在范围中读取承诺信息, 并标出编码代理所撰写的信息 `Co-Authored-By: Claude <noreply@anthropic.com>` 拖车 `🤖 Generated with Claude Code` 脚印,以及来自Cursor、Copilot、Codex、双子座、Devin和助手的等同物:

```
slopgate: scanned 3 file(s), +42 added line(s), 38ms
  agent-authored commit (🤖 Generated with Claude Code) — extra scrutiny applied
  ⚠ dep.typosquat  requirements.txt:7  [WARN]
      "expres" exists but is 1 edit(s) from popular "express" and only 3 day(s) old — probable typosquat
1 warning(s). commit allowed.
```

信号是信息:它从不自行改变判决. 它告诉一个审查者,机器速度代码落在了这个diff中,所以上面的发现值得更仔细的审视. 完整标记列表运行在 `--format json` 在SARIF的地产袋里 分阶段扫描还没有承诺消息,因此Heuristic仅适用于范围扫描. 禁用为 `agent: { enabled: false }`。 。 。 .

## 承诺前框架

`.pre-commit-hooks.yaml` repo中的船只,所以框架用户不需要本地安装:

```yaml
repos:
  - repo: https://github.com/al1prahman/slopgate
    rev: v1.0.1
    hooks:
      - id: slopgate          # pre-commit: scans staged changes
      - id: slopgate-push     # pre-push: scans the pushed range
```

## 如何运作

```
git diff (staged / range / PR)
        │
        ▼
  added-lines only ──► secret detector ──► findings
        │
        ├──► dependency extractor ──► registry existence check ──► similarity check
        │                                      │                          │
        │                                SQLite cache            popular-package baseline
        │
        └──► import extractor ──► (alias table for Python) ──► same registry check
                                               │
                                         report ──► exit code (block / warn / pass)
```

三个设计规则保持了快而安静:

1.  **双镜** ——只扫描所添加的行;锁文件从不检查依赖性.
2.  **先缓存** ——每个注册裁定都以本地的SQLite来缓存;温暖的预承诺运行为 < 100ms.
3.  **注销登记失败** ——如果npm/PyPI无法到达,请警告而不是阻止你的承诺.
4.  **别忘了,别猜** —— Python 进口通过拼接别名表解决(`bs4` → `beautifulsoup4`);没有条目的名称按原样并仅检查 _警告( e)_ 当未知时, 因为地图可能只是缺失.

## 路线图

-   **流动人口调查** ——接钩+秘密扫描+依赖存在检查(`package.json`, (中文(简体) ), `requirements.txt`\+ 伤寒警告、CLI、配置
-   **单曲** ——导入扫描 (JS/Python) —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— 输入扫描 (JS/Python) —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— 进口扫描(JS/ Python) —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— -- —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— —— `.pre-commit-hooks.yaml`
-   **页:1** —— 说 `go.mod` 编号 : `Cargo.toml` 编号 : `Gemfile`,注册-元数据风险评分,隔离模式,MCP服务器(承诺前的代理人自查)

## 捐款

公关欢迎。 光谱存在于 [`docs/`](https://npmcn.com/package/%40al1prahman/slopgate/docs/) —— 说 `01-design-doc.md` 是产品PRD, `02-implementation-spec.md` 是工程计划, `03-agent-build-handoff.md` 是代理已准备好建立真相的来源.

```bash
git clone <repo>
cd slopgate
npm install
npm test
```

## 许可证

[麻省理工学院](https://npmcn.com/package/%40al1prahman/slopgate/LICENSE)

## 常见问题

### @al1prahman/slopgate 是什么？

Git-native 安全门 阻止AI编码代理 航运 幻觉依赖和泄露秘密

### 如何安装 @al1prahman/slopgate？

在项目目录运行 npm install @al1prahman/slopgate，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 slopgate，可以用 npx slopgate 直接运行。

### @al1prahman/slopgate 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/al1prahman\_\_slopgate 是否存在。

### @al1prahman/slopgate 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @al1prahman/slopgate 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.13\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @al1prahman/slopgate 可以商用吗？

@al1prahman/slopgate 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @al1prahman/slopgate 的下载量有多少？

根据 npm 官方下载统计，@al1prahman/slopgate 在 2026/10/06 – 2026/11/04 这 30 天内被下载 1,853 次，日均约 62 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @al1prahman/slopgate 还在维护吗？

最新版本 1\.0\.9 发布于 2026/11/04（4 天前）；至今共发布 11 个版本，其中过去 12 个月发布了 11 个；首次发布于 2026/11/03。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

