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

codex-security-momu

v0.1.3

Published

面向自定义 OpenAI 兼容 Provider 的交互式 AI 安全代码扫描 CLI

Downloads

682

Readme

Codex Security Momu

面向日常代码审查的安全扫描 CLI 和 TypeScript SDK。它可以使用 OpenAI、OpenRouter、Fireworks,或任意兼容 Responses / Chat Completions 的自定义 Provider,对当前 Git 仓库执行普通或深度安全扫描。

扫描过程会把完成审查所需的代码与上下文交给你选择的模型 Provider。只扫描你有权提交给该 Provider 的仓库和内容。

快速开始

需要 Node.js 22.13+、Python 3.10+ 和 Git。

npm install --global codex-security-momu
cd /path/to/your/repository
csm

首次使用建议打开 csm:在一个全屏页面里创建 Provider 预设、填写 API 地址与 Key、选择扫描模式,然后开始扫描。

安装后也可以直接使用两个命令:

# 全屏配置页:目录、Provider 预设、模型、思考强度、扫描模式和成本上限
csm

# 参数式 CLI
codex-security-momu scan .

Windows 如果 PowerShell 的脚本策略拦截 .ps1 包装器,可以使用:

codex-security-momu.cmd --help
csm.cmd

csm 全屏配置页

运行 csm 后可以在全屏页面中填写:

  • 扫描目录
  • Provider 预设:用左右箭头切换 OpenAI 和已创建的自定义预设
  • 自定义 Provider 的 API 地址、认证方式和 API Key
  • 新增多个自定义 Provider 预设
  • 模型,例如 gpt-5.6-terra
  • 思考强度:minimallowmediumhighxhigh
  • 普通扫描或深度扫描
  • 成本上限(美元),留空表示不限制

目录在开始扫描前会解析为真实绝对目录,并再次交给扫描器校验。向模型传递的目标始终只有这一个目录,不会自动追加父目录、同级目录或其他仓库。按 Enter 编辑当前项,在“开始扫描”处按 Enter 启动;Provider、认证方式和扫描模式用左右箭头切换;按 EscQ 取消。

csm 页面输入的 API Key 会保存到本机私有密钥文件:macOS/Linux 为 ~/.codex/codex-security-momu/provider-secrets.json,Windows 为 %USERPROFILE%\\.codex\\codex-security-momu\\provider-secrets.json。文件权限为 0600,启动 csmcodex-security-momu scan 时都会自动读取,并仅在扫描进程内作为对应 env_key 注入。它不会写入 providers.toml、Shell 配置、日志或扫描报告。Provider 预设本身会保存 ID、API 地址、认证方式和协议,便于下一次直接切换。该文件是权限保护的明文文件,不是加密密钥链;需要更高保护级别时请使用系统密钥管理器或环境变量。

Provider 配置

Provider 配置文件只保存连接元数据,API Key 单独保存在权限为 0600 的本地密钥文件中,绝不写入 TOML。

Windows:%USERPROFILE%\\.codex\\codex-security-momu\\providers.toml

macOS/Linux:~/.codex/codex-security-momu/providers.toml

示例:

default_provider = "ftmine"
default_model = "gpt-5.6-terra"
default_effort = "xhigh"

[providers.ftmine]
name = "ftmine"
base_url = "https://api.ftmine.cn/v1"
env_key = "FTMINE_API_KEY"
wire_api = "responses"

如果 Provider 使用 Codex 已保存的登录凭据,而不是单独的环境变量,可以改用:

[providers.ftmine]
name = "ftmine"
base_url = "https://api.ftmine.cn/v1"
requires_openai_auth = true
wire_api = "responses"

env_keyrequires_openai_auth 只能配置一个。前者缺少变量时,扫描会在本地预检阶段停止并给出设置命令;后者会复用 codex-security-momu login 或现有 Codex 凭据。

API Key 放在环境变量中。Windows PowerShell:

$env:FTMINE_API_KEY = "你的 API Key"

需要让新开的终端也能读取时:

setx FTMINE_API_KEY "你的 API Key"

macOS/Linux:

export FTMINE_API_KEY="你的 API Key"

已有旧版 %USERPROFILE%\\.codex\\codex-security\\providers.toml 的配置仍会自动兼容读取。可用 --provider-config 指定其他 TOML 文件,或使用临时参数:

codex-security-momu scan . `
  --provider private_gateway `
  --provider-base-url https://gateway.example.com/v1 `
  --provider-api-key-env PRIVATE_GATEWAY_API_KEY `
  --provider-wire-api responses `
  --model gpt-5.6-terra `
  --effort xhigh

常用命令

codex-security-momu scan .
codex-security-momu scan . --headless
codex-security-momu scan . --dry-run --json
codex-security-momu scan . --mode deep --workers 2 --subagents 0
codex-security-momu scan . --path src --path packages/api
codex-security-momu scan . --diff origin/main
codex-security-momu scan . --working-tree --base origin/main
codex-security-momu scan . --max-cost 5
codex-security-momu bulk-scan repositories.csv --output-dir ./security-scans
codex-security-momu scans list
codex-security-momu scans show SCAN_ID
codex-security-momu export ./scan-dir --export-format sarif --output results.sarif
codex-security-momu install-hook
codex-security-momu info --json

默认终端使用交互式全屏扫描进度页;CI、重定向、结构化输出和显式 --headless 使用普通文本进度。

登录认证

自定义 Provider 使用对应的 env_key 环境变量或通过 csm 保存的本地 Key,不会执行 OpenAI 登录。内置 OpenAI Provider 可以使用:

codex-security-momu login
codex-security-momu login status
codex-security-momu logout
codex-security-momu scan . --provider openai --auth chatgpt

TypeScript SDK

import { CodexSecurity } from "codex-security-momu";

const security = new CodexSecurity({
  codexOverrides: {
    model: "gpt-5.6-terra",
    model_reasoning_effort: "xhigh",
  },
});
const result = await security.run("/path/to/repository", {
  mode: "standard",
});
console.log(result.toJSON());
await security.close();

SDK 使用同一套 Provider 配置和认证规则。扫描结果、历史和导出文件默认放在扫描仓库之外的状态目录中。

安全说明

  • API Key 只从环境变量、外部密钥管理系统或 csm 的本地私有密钥文件读取,不写入 TOML、日志、报告或 Git。
  • 只扫描你有权提交给所选模型 Provider 的源码、配置和历史信息。
  • csm 只生成一个明确的 scan <目录> 目标,且开始前会执行真实路径和目录类型校验。
  • 输出目录必须位于扫描目录及其 Git 工作树之外。
  • 扫描结果可能包含敏感源码上下文,请按敏感数据处理。

开发

npm install
npm run lint
npm run build
npm run format
npm pack --dry-run

项目地址:https://github.com/SpringMomu/codex-security-momu