npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-safeguard

v0.1.1

Published

面向 DeepSeek Harness(DSH)的危险命令 + 密钥泄漏拦截插件。挂载到 `tools/pre-execute` waterfall,在工具解析前短路拒绝,被拦截的副作用不会发生。

Readme

dsh-safeguard

面向 DeepSeek Harness(DSH)的危险命令 + 密钥泄漏拦截插件。挂载到 tools/pre-execute waterfall,在工具解析前短路拒绝,被拦截的副作用不会发生。

简介

  • 危险命令拦截:对 bash 工具的命令做正则匹配,命中即 deny。
  • 密钥泄漏拦截:对所有工具的 arguments 做 JSON.stringify 后扫描常见密钥模式,命中即 deny。
  • 可配置:危险/密钥检测开关、额外正则、精确豁免名单。
  • 两个辅助工具:guard_list(列出当前规则)与 guard_check(纯检查不拦截,供调试/自检)。

重要:本插件是基于正则的启发式拦截,不验签、不识别密钥真伪、不做沙箱隔离。它无法替代密钥扫描器、签名校验或操作系统级沙箱,只能拦截明显的高风险动作。

安装

dsh plugin --profile <profile> add dsh-safeguard

本地开发安装:

dsh plugin --profile <profile> add file:./plugins/dsh-safeguard

默认规则表

危险命令(enableDanger)

| 规则名 | 匹配内容 | |---|---| | rm -rf | rm -rf / rm -fr 且目标是 /、*、./、../、., ~、$HOME | | git push --force | git push --force / --force-with-lease / -f | | git reset --hard | git reset --hard | | git clean -fd | git clean 带 -fd / -df 等同时含 f、d 的标志 | | chmod -R 777 | chmod -R 777 | | mkfs | mkfs / mkfs.ext4 等 | | dd 写盘 | dd if=... of=/dev/... | | 重定向到块设备 | > /dev/sd[a-z] | | curl|sh 管道执行 | curl ... \| sh、wget ... \| bash 等 | | SQL DROP | 以 DROP TABLE/DATABASE/INDEX/... 开头 | | SQL DELETE | 以 DELETE FROM 开头 | | SQL TRUNCATE | 以 TRUNCATE [TABLE] ... 开头 |

密钥泄漏(enableSecrets)

| 规则名 | 匹配模式 | |---|---| | AWS Access Key (AKIA) | AKIA[0-9A-Z]{16} | | sk- API Key | sk-[A-Za-z0-9]{20,} | | GitHub PAT (ghp_) | ghp_[A-Za-z0-9]{30,} | | GitHub Fine-grained PAT (github_pat_) | github_pat_[A-Za-z0-9_]{10,} | | PEM 私钥 | -----BEGIN (RSA\|OPENSSH\|EC\|PGP) PRIVATE KEY----- | | Slack Token (xox-) | xox[baprs]-... |

eyJ 开头的长 JWT 不拦截(模式太宽,误报率高)。

配置项

在 profile 的 cordis.patch.yml(或 bundle 配置)中覆盖:

- insert:
    - id: guard
      name: dsh-safeguard
      config:
        enableDanger: true      # 危险命令拦截开关(默认 true)
        enableSecrets: true     # 密钥泄漏拦截开关(默认 true)
        extraPatterns:          # 额外正则字符串(额外危险命令规则)
          - 'curl.*\|.*bash'
        allowList:              # 精确豁免名单(字符串完全一致才豁免)
          - 'rm -rf /tmp/safe-dir'

| 配置项 | 类型 | 默认 | 说明 | |---|---|---|---| | enableDanger | boolean | true | 是否拦截危险命令 | | enableSecrets | boolean | true | 是否拦截密钥泄漏 | | extraPatterns | string[] | [] | 额外危险命令正则(非法正则以警告跳过) | | allowList | string[] | [] | 精确豁免:危险命令按整条命令、密钥按命中片段做完全一致匹配 |

两个工具的用法

guard_list

无参,列出当前启用的规则类别与条目数:

[dsh-safeguard] 规则清单
危险命令: 启用(12 条规则)
密钥检测: 启用(6 条规则)
额外正则: 0 条
豁免名单: 0 条

guard_check

参数 text(必填 string)。纯检查不拦截,返回命中规则名 / 类别 / 是否豁免:

  • guard_check("rm -rf /") → 命中,类别 danger,规则 rm -rf
  • guard_check("aws key: AKIAIOSFODNN7EXAMPLE") → 命中,类别 secrets,规则 AWS Access Key (AKIA)
  • guard_check("echo hello") → 通过

模型可通过 await tools.guard_check({ text: "..." }) 做程序化自检。

不验签、不做沙箱替代

  • 本插件只做正则模式匹配,不校验密钥真实性,也不校验命令签名。
  • 它不是沙箱:不会隔离文件系统、网络或子进程,拦截的是「命中明显高风险模式」的调用。
  • 生产环境仍应配合密钥扫描器(如 gitleaks、trufflehog)、签名校验与操作系统级沙箱(如 dsh-bash-sandbox)使用。

License

MIT