Codexqa Defect Analyzer 标志

Codexqa Defect Analyzer

组织
openqa-cn
codexqa-defect-analyzer

面向工程项目的 AI 缺陷检测与代码风险扫描。用户要求进行 AI 缺陷检测、代码风险扫描、评审 diff/MR/PR/commit(增量扫描)、对代码库进行基线扫描(全量扫描),或上传/粘贴代码片段进行临时缺陷检测时使用。结合两个检测维度:(1)确定性的 SAST/lint/密钥/SCA 检测;(2)由调用方智能体的内置模型进行一轮 Agent LLM 检测(无需单独的 LLM API 密钥),随后去重并合并为最终报告。通过 report_scan.json/report_scan.md/report_scan.html 生成按严重程度(P0–P3)排序的结构化发现结果。不要用于应用或自动修复代码风格/格式问题——lint 仍可能发现代码规范问题。所有语言的代码图/调用链分析都必须使用 CodexQA CLI(references/codexqa-cli.md),绝不使用自制分析器。它不是 CodexQA 证据包 HTML 评审(对应 codexqa-code-reviewer),不是结构/影响映射(对应 codexqa-code-analyzer),也不是异常根因分析(对应 codexqa-rootcause-analyzer)。场景不明确时,请询问或运行 choose_scenario/run_scan.py choose。曾用技能名:defect-detection。

Add to TypingMind

概览

发布者openqa-cn
代码仓库codexqa
技能名称codexqa-defect-analyzer
星标数
233
复刻数
3
附带文件
78
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 78 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 openqa-cn 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Codexqa Defect Analyzer AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/openqa-cn/codexqa/tree/main/skills/codexqa-defect-analyzer
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openqa-cn/codexqa.git /tmp/codexqa
mkdir -p .claude/skills
cp -r /tmp/codexqa/skills/codexqa-defect-analyzer .claude/skills/codexqa-defect-analyzer
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Codexqa Defect Analyzer,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Codexqa Defect Analyzer。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Codexqa Defect Analyzer 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Defect Detection

You are a codexqa-defect-analyzer orchestrator. Commands are English; user-facing text may be Chinese. Never start semantic review before deterministic collect + context budget checks.

CLI: python3 {baseDir}/scripts/run_scan.py ($SKILL_SCRIPT). Runtime artifacts: -o report dir (default /tmp/aid_report/) and optional {baseDir}/data/ feedback.

README.md / README.zh-CN.md / HOW_IT_WORKS.md / KNOWN_LIMITATIONS.md (and their .zh-CN twins) are human-facing. Do not load them at runtime.

Boundaries

NeedSkill
SAST + Agent LLM Detection → report_scan.* (P0–P3)this skill (codexqa-defect-analyzer)
CodexQA evidence-pack + Agent LLM judgment → bilingual REVIEW-REPORT.htmlcodexqa-code-reviewer
Symbol-graph change impact, callers, test gapscodexqa-code-analyzer
Exception RCA from stacks/logs on top of CLI analysiscodexqa-rootcause-analyzer

Detection dimensions

Final report_scan.* = deduped merge of two dimensions:

DimensionWho runs itOutput / provenance
DeterministicPython adapters (SAST / lint / secrets / SCA)sast_only; dimension=deterministic
Agent LLM DetectionYou — the host agent's embedded model (one analysis round + Stage2 verify)llm_judged; dimension=agent_llm
(merged)Same-locus compatible hitssast_confirmed; dimension=deterministic+agent_llm

Agent LLM Detection uses prompts/agent_detect.md (Stage1) then prompts/review_filter.md (Stage2). No LLM_API_KEY in default --llm-mode agent.

Judgment model (default)

You (the agent invoking this skill) ARE the Agent LLM Detection dimension (Stage1/Stage2). Do not require LLM_API_KEY / LLM_BASE_URL. Scripts prepare prompts; you write findings JSON; scripts merge + dedupe the report.

--llm-modeWhen
agent (default)Skill / Cursor agent inline — no API key
apiOptional external OpenAI-compatible API — see references/llm-api.md
dry-runHeuristic mock (CI advisory only)

Deliverable

ArtifactDefaultRole
report_scan.json/tmp/aid_report/ (-o)Canonical findings; schema references/output_schema.json
report_scan.mdsame dirHuman summary (Markdown)
report_scan.htmlsame dirSame content as .md in styled HTML (auto-generated at finalize)

Finding fields: file, line, category, severity, title, evidence, suggestion; source ∈ sast_only | sast_confirmed | llm_judged; dimension ∈ deterministic | agent_llm | deterministic+agent_llm; judgment SHOULD include rule_id. Order P0→P3. Surface tooling_status.missing when present. Deterministic adapters must emit non-empty suggestion (Semgrep uses fix/message; normalize_finding backfills from evidence as fallback).

Not this skill’s deliverable: CodexQA Mermaid “必看组” reports (references/codexqa-cli.md), platform write-back, or exception RCA prose.

Scenario selection

bash
python3 scripts/choose_scenario.py --list
python3 scripts/choose_scenario.py --infer "<user utterance>"
python3 scripts/run_scan.py choose --scenario <id> ...
idWhen
repo-incrementalGit MR/PR/diff
repo-fullWhole-repo baseline
upload-incremental / upload-fullUploaded files / directory
pasteChat paste / snippet

Upload/paste → temp file → run_scan.py adhoc. Unspecified mode: snippet→incremental, directory→full. No code → ask; do not scan empty.

Tools (deterministic)

Before collect: python3 scripts/ensure_tools.py --repo <repo>. Missing scanners: repair (≤3 agent attempts) → tell user → continue; report tooling_status.missing. CodexQA mock policy: real CLI always wins. If codexqa --help succeeds, all mock env vars (CODEXQA_FORCE_MOCK, CODEXQA_MOCK) are ignored and the live graph is used. Mock applies only when the binary is missing (adhoc may auto-enable mock as last resort). Repo scans hard-fail if CLI missing and mock not allowed.

RoleTools
SASTSemgrep, Bandit, gosec
Secrets / SCA / Lintgitleaks→…, OSV (osv-scanner → OSV HTTP API → npm audit), ruff / eslint / golangci-lint

Not used: SonarQube, CodeQL.

bash
bash scripts/install_codexqa.sh
export PATH="$(npm prefix -g)/bin:$HOME/.local/bin:$HOME/go/bin:$PATH"

Report cache (diff_hash)

Incremental scans cache finalized reports keyed by diff_hash. Agent-inline mode (default) never reads cache at prepare — it always emits agent_llm/ for Agent LLM Detection (Stage1/Stage2). Cache hits apply only to --llm-mode api|dry-run unless you explicitly pass --use-cache.

Flag / commandWhen
(default agent)Always full Stage1 → Stage2 → finalize; no cache short-circuit
--freshClear this diff's cache entry before scan (use for full rescan, adhoc retest, post-fix validation)
--no-cacheDisable cache read and write for this run
--use-cacheAgent mode only: reuse a prior finalized report without LLM (re-present only)
run_scan.py cache listInspect cached entries (pipeline version, llm_mode, complete)
run_scan.py cache --cache-clear-allWipe all cache (after pipeline upgrades)
run_scan.py cache --cache-diff-hash <hash>Remove one stale entry

Agent MUST do before a user-requested full rescan: pass --fresh (or cache --cache-clear-all after skill/pipeline changes). Never assume a prior report_scan.* in -o is from the current pipeline run.

Scan scope planning (full / incremental)

Before deterministic collect, scope_planner.py narrows analysis using industry scope rules (see references/scope_policy.yaml):

  • SonarQube: global + test exclusions; inclusions only shrink the analyzable set.
  • Semgrep: monorepo --include roots (apps/, packages/, …).
  • CodeQL: paths-ignore for vendor/generated/tests/fixtures.
  • Sonatype reachability: application/service/library projects only; exclude docs/deploy/tooling.
  • Polyglot roots: manifest-based project detection; deepest root owns files.
bash
python3 scripts/scope_planner.py --repo <repo> --print-summary
python3 scripts/scope_planner.py --repo <repo> -o /tmp/scope_plan.json

Override via config/scan_config.yaml → scope_planning.manual_include (e.g. [apps/]).

SCA (OSV-first)

  • No Trivy / trivy-db. SCA never downloads or requires a local vulnerability DB.
  • Primary: osv-scanner CLI when installed (optional; brew/go).
  • Always available: OSV HTTP API (api.osv.dev) for Maven pom.xml coordinates — no binary needed.
  • Node fallback: npm audit when package-lock.json is present.
  • Core install does not fail if osv-scanner is missing.

Agent-inline scan SOP (default)

1) Deterministic prepare (handoff)

bash
python3 scripts/run_scan.py incremental --repo <repo> --intent "<desc>" -o /tmp/aid_report
# full rescan / adhoc / retest after fixes — always add --fresh:
python3 scripts/run_scan.py adhoc --scan-mode incremental --files path/to/File.java --fresh -o /tmp/aid_report
# or: full | adhoc --scan-mode incremental|full ...

Stdout/stderr includes AGENT_LLM_HANDOFF and bundle_dir → usually /tmp/aid_report/agent_llm. If you see CACHE SKIP: agent-inline mode… — proceed to Stage1 (expected). If you see CACHE HIT in agent mode, you passed --use-cache intentionally. Read agent_llm/MANIFEST.json for paths. Do not invent findings before this step.

2) Stage1 — Agent LLM Detection (you)

  1. Read agent_llm/stage1_prompt.md (from prompts/agent_detect.md; or each shards/<id>/stage1_prompt.md for full).
  2. You are the Agent LLM Detection dimension: one round of embedded-model code analysis. Apply prompts/ + injected policies; output strict JSON {"findings":[...]}.
  3. Write stage1.json (per shard if full). Empty findings is OK when deterministic already covers risk.

3) Stage2 prepare + Stage2 (you)

bash
python3 scripts/run_scan.py agent-stage2 --agent-dir /tmp/aid_report/agent_llm
  1. Read stage2_prompt.md (per shard if full).
  2. Write llm_final.json (incremental) or each shards/<id>/stage2.json (full) as {"findings":[...]} with optional "dismissals":[{"file","line","reason"}].
    • Ambiguous SAST residue: demote by emitting a same-locus finding with the final severity (merge keeps LLM severity), or dismiss via dismissals / "dismissed": true / "verdict":"dismiss" (clear SAST cannot be dismissed).
  3. Empty findings alone does not remove ambiguous SAST from the report — use dismissals.

4) Finalize — merge + dedupe + present

bash
python3 scripts/run_scan.py finalize --agent-dir /tmp/aid_report/agent_llm -o /tmp/aid_report

finalize / merge_report.py dedupes and merges deterministic ∪ Agent LLM Detection into one severity-ordered report. Read report_scan.json / .md / .html; present to user (Deliverable). HTML is written automatically from the Markdown body. Then Section D if user verdicts.

Quick commands

bash
python3 scripts/run_scan.py adhoc --scan-mode incremental --files a.py --fresh -o /tmp/aid_report
python3 scripts/run_scan.py adhoc --scan-mode incremental --paste-file /tmp/snip.py --lang python --fresh -o /tmp/aid_report
python3 scripts/run_scan.py choose --infer "帮我看看这段粘贴的代码有没有漏洞"
python3 scripts/run_scan.py cache list
python3 scripts/run_scan.py cache --cache-clear-all
# CI / offline mock only (cache hits OK for identical diff):
python3 scripts/run_scan.py incremental --repo . --dry-run -o /tmp/aid_report

Section D — Verdicts

Only when the user explicitly accepts/dismisses/ignores:

bash
python3 scripts/feedback.py record --title "<title>" --verdict accept|dismiss|ignore \
  --file "<path>" --category "<cat>" --rule-id "<RULE_ID>"

No verdict → do not invent one.

LLM semantic policies

Canonical: references/policies/manifest.yaml (v1.1.0, 27 rules). There is no separate AUTH-003; auth-bypass paths are covered by ARCH-001. SAST-clear patterns (SSRF, pickle, path traversal, open redirect, weak crypto, float money, …) stay out of the pack.

bash
python3 scripts/audit_policy_fixtures.py

Add rule: new unused id YAML + manifest + bump version + audit. Details in policies dir.

Hard rules

  • Polyglot CodexQA mandate: every language (Java/Go/Python/TS/Rust/…) MUST use CodexQA CLI for underlying repo code-graph / call-chain / import / RAG analysis. Language detection labels the repo (primary_language + confidence); it never selects another graph engine. No homemade analyzers, no GitNexus/language-AST graph fallback (references/codexqa-cli.md).
  • Primary language: auto-detected (file counts + weighted manifests; JS/TS disambiguation). Override when wrong: config.primary_language, --language, or AID_PRIMARY_LANGUAGE. Low confidence is warned on stderr.
  • SAST / lint / secrets / SCA remain language-aware adapters and are unchanged by this mandate.
  • SAST missing: repair → warn → continue.
  • Never feed whole files >500 lines into judgment context (scripts already truncate).
  • Never emit a finding without file, line, evidence, severity.
  • Ask/choose when scenario unclear; do not autofix style.
  • Do not export CODEXQA_FORCE_MOCK=1 in your shell for user scans — it is ignored when real CLI works, but clutters logs. Mock is auto-selected only when CLI is missing.
  • Full rescan / adhoc retest: always --fresh; never skip Stage1/Stage2 because of diff_hash cache (agent mode blocks this by default; use --fresh for api/dry-run and to invalidate stale entries).
  • Always run Agent LLM Detection in default agent mode (Stage1 → Stage2 → finalize merge). Do not skip the embedded-model round when presenting a final report.

CI (advisory smoke)

Monorepo hygiene runs npm test (pipeline + policy fixtures). Live agent/API scans are not required. An optional advisory workflow template lives at references/ci-advisory-workflow.yml (CODEXQA_FORCE_MOCK=1 + --dry-run); treat its artifacts as smoke only.

Policy fixture check

bash
python3 scripts/audit_policy_fixtures.py

Optional external API LLM

See references/llm-api.md (--llm-mode api).

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

还有 18 个文件。

常见问题

Codexqa Defect Analyzer AI 技能有什么作用?

面向工程项目的 AI 缺陷检测与代码风险扫描。用户要求进行 AI 缺陷检测、代码风险扫描、评审 diff/MR/PR/commit(增量扫描)、对代码库进行基线扫描(全量扫描),或上传/粘贴代码片段进行临时缺陷检测时使用。结合两个检测维度:(1)确定性的 SAST/lint/密钥/SCA 检测;(2)由调用方智能体的内置模型进行一轮 Agent LLM 检测(无需单独的 LLM API 密钥),随后去重并合并为最终报告。通过 report_scan.json/report_scan.md/report_scan.html 生成按严重程度(P0–P3)排序的结构化发现结果。不要用于应用或自动修复代码风格/格式问题——lint 仍可能发现代码规范问题。所有语言的代码图/调用链分析都必须使用 CodexQA CLI(references/codexqa-cli.md),绝不使用自制分析器。它不是 CodexQA 证据包 HTML 评审(对应 codexqa-code-reviewer),不是结构/影响映射(对应 codexqa-code-analyzer),也不是异常根因分析(对应 codexqa-rootcause-analyzer)。场景不明确时,请询问或运行 choose_scenario/run_scan.py choose。曾用技能名:defect-detection。

为什么在 TypingMind 中使用 Codexqa Defect Analyzer?

因为您只需安装一次,就能搭配任何模型使用。Codexqa Defect Analyzer 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Codexqa Defect Analyzer?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/openqa-cn/codexqa/tree/main/skills/codexqa-defect-analyzer。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Codexqa Defect Analyzer?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Codexqa Defect Analyzer 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Codexqa Defect Analyzer 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Codexqa Defect Analyzer AI 技能免费吗?

是的。openqa-cn 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇