code-audit-readonly
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Audit Readonly
只读代码审计
Run a full technical repository audit in read-only mode and record everything in .
improvements.md以只读模式运行完整的技术仓库审计,并将所有内容记录在中。
improvements.mdMandatory rules
强制规则
- Operate in read-only mode for the audited project.
- Do not edit source code, configs, or tests in the audited project.
- Do not run automatic refactors, formatters that write to disk, or destructive commands.
- Allow only the creation/update of as the final audit output.
improvements.md - Do not ask for confirmation to proceed with the audit; execute the plan end to end.
- Record every validated finding; do not impose arbitrary limits.
- If multiple locations share the same issue pattern, still register every location with explicit file and line references.
- This audit is intentionally slow: prioritize depth, evidence quality, and completeness over speed.
- Do not optimize for fast turnaround if that reduces analysis coverage or confidence.
- 对被审计项目以只读模式操作。
- 不得编辑被审计项目的源代码、配置文件或测试代码。
- 不得运行自动重构、会写入磁盘的格式化工具或破坏性命令。
- 仅允许创建/更新作为最终审计输出。
improvements.md - 无需请求确认即可执行审计计划,从头到尾完成流程。
- 记录所有经过验证的发现;不得设置任意限制。
- 如果多个位置存在相同的问题模式,仍需为每个位置注册记录,并明确标注文件和行号引用。
- 本次审计刻意追求全面性:优先保证深度、证据质量和完整性,而非速度。
- 不得为了快速交付而降低分析覆盖范围或可信度。
Mandatory analysis scope
强制分析范围
- Correctness and logic
- Detect obvious and subtle bugs.
- Check for race conditions, inconsistent states, and incorrect async/concurrency usage.
- Evaluate error/exception handling, nullability, typing, and unsafe conversions.
- Cover edge flows and extreme scenarios.
- Performance
- Find unnecessary allocations, expensive loops, N+1 patterns, excessive I/O, and repeated work.
- Check for caching opportunities and inappropriate data structures.
- Correlate bottlenecks across modules.
- Duplication and maintainability
- Detect literal duplication and logical duplication.
- Identify long functions, mixed responsibilities, and excessive coupling.
- Flag confusing internal APIs, ambiguous names, and outdated comments.
- Security (mandatory, thorough)
- Hardcoded secrets (tokens, keys, passwords, sensitive endpoints).
- Injection vectors (SQL/NoSQL/command/template).
- XSS, CSRF, SSRF, open redirect, path traversal.
- Insecure uploads (insufficient type/size/validation checks).
- Authentication/authorization issues (bypass, missing checks, privilege escalation).
- Insufficient validation/sanitization.
- Weak cryptography and inadequate hashing.
- Insecure configurations (overly broad CORS, missing headers, debug in production).
- Vulnerable dependencies and problematic versions.
- Sensitive data leakage in logs, errors, and telemetry.
- Observability and reliability
- Validate log quality without exposing secrets.
- Verify metrics/tracing where applicable.
- Evaluate consistency and actionability of error messages.
- Tests and quality
- Identify coverage gaps in critical areas.
- Detect brittle tests and missing integration coverage.
- Map untested edge cases.
- 正确性与逻辑
- 检测明显和潜在的Bug。
- 检查竞争条件、不一致状态以及异步/并发使用不当的问题。
- 评估错误/异常处理、空值处理、类型检查和不安全的类型转换。
- 覆盖边缘流程和极端场景。
- 性能
- 找出不必要的内存分配、低效循环、N+1查询模式、过度I/O操作和重复执行的任务。
- 检查可缓存的场景和不合适的数据结构。
- 关联跨模块的性能瓶颈。
- 代码重复与可维护性
- 检测字面重复和逻辑重复的代码。
- 识别过长函数、职责混合和过度耦合的问题。
- 标记易混淆的内部API、模糊的命名和过时的注释。
- 安全(强制且全面)
- 硬编码的密钥(令牌、密钥、密码、敏感端点)。
- 注入漏洞(SQL/NoSQL/命令/模板注入)。
- XSS、CSRF、SSRF、开放重定向、路径遍历。
- 不安全的上传(类型/大小/验证检查不足)。
- 认证/授权问题(绕过、缺失检查、权限提升)。
- 验证/ sanitization不足。
- 弱加密和不充分的哈希算法。
- 不安全的配置(过于宽松的CORS、缺失安全头、生产环境启用调试模式)。
- 存在漏洞的依赖和有问题的版本。
- 日志、错误信息和遥测中的敏感数据泄露。
- 可观测性与可靠性
- 在不暴露密钥的前提下验证日志质量。
- 验证指标/跟踪功能(如适用)。
- 评估错误信息的一致性和可操作性。
- 测试与质量
- 识别关键区域的测试覆盖缺口。
- 检测脆弱的测试用例和缺失的集成测试覆盖。
- 梳理未覆盖的边缘场景。
Execution method
执行方法
- Map the repository tree and list all relevant files:
- Application code, internal libraries, configs, scripts, CI, Docker, IaC, migrations, and tests.
- Initialize with:
improvements.md- A short system summary inferred from the structure.
- A "Progress Tracking" section with all relevant files marked as .
pending - Severity and category conventions.
- Review each file sequentially and deterministically:
- Read the entire file.
- Record specific findings and correlate with related imports/calls/contracts.
- Update progress tracking.
- Explicitly record: .
File fully reviewed: <path/to/file> - Before moving to the next file, run a quick self-check for missed edge cases, security vectors, and cross-file impacts.
- Run read-only auxiliary checks when useful:
- Static analysis, linter, and typecheck in read-only mode.
- Run tests without writing to disk.
- Dependency/CVE audit.
- Close with:
improvements.md- A complete finding inventory (all findings captured during the audit).
- A prioritized backlog that references finding IDs and contains no artificial cap.
- A detailed phased remediation plan (see "Detailed planning requirements").
- A brief completeness checkpoint describing what was verified to ensure no relevant area was rushed or skipped.
- 梳理仓库目录结构并列出所有相关文件:
- 应用代码、内部库、配置文件、脚本、CI配置、Docker文件、IaC、迁移脚本和测试代码。
- 初始化,包含:
improvements.md- 从结构推断出的简短系统概述。
- “进度跟踪”部分,所有相关文件标记为。
pending - 严重程度和类别的约定。
- 按顺序、确定性地审核每个文件:
- 阅读整个文件。
- 记录具体发现,并关联相关的导入/调用/契约。
- 更新进度跟踪。
- 明确记录:。
File fully reviewed: <path/to/file> - 在切换到下一个文件前,快速自我检查是否遗漏边缘场景、安全风险和跨文件影响。
- 必要时运行只读辅助检查:
- 静态分析、代码检查和类型检查(只读模式)。
- 运行测试但不写入磁盘。
- 依赖/CVE审计。
- 完成的最终内容:
improvements.md- 完整的发现清单(审计过程中捕获的所有发现)。
- 包含所有发现的优先级待办事项,引用发现ID且无人工限制。
- 详细的分阶段修复计划(见“详细规划要求”)。
- 简短的完整性检查说明,描述已验证的内容,确保没有相关区域被仓促处理或跳过。
Progress tracking
进度跟踪
Apply these rules to keep progress tracking clear and stable:
- Build a canonical file list once:
- Normalize paths (removed, no trailing slash, consistent case as seen on disk).
./ - Sort the list before writing "Progress Tracking".
- Normalize paths (
- Keep exactly one progress row per canonical file path.
- Update progress in-place:
- Change the existing row status (->
pending->in_progress).reviewed - Never append a second row for the same file.
- Change the existing row status (
- Write exactly once per file.
File fully reviewed: <path/to/file> - If a file is revisited, add notes under the same file entry; do not create a new checklist row or a second line.
File fully reviewed - Before finishing, validate:
- Number of rows == number of unique relevant files.
reviewed - "Progress Tracking" appears exactly once in the report.
- Every finding location appears in at least one reviewed file entry.
- Number of
遵循以下规则保持进度跟踪清晰稳定:
- 一次性构建标准文件列表:
- 标准化路径(移除,无末尾斜杠,与磁盘上的大小写保持一致)。
./ - 在写入“进度跟踪”前对列表排序。
- 标准化路径(移除
- 每个标准文件路径对应唯一的进度行。
- 原地更新进度:
- 修改现有行的状态(->
pending->in_progress)。reviewed - 切勿为同一文件添加第二行。
- 修改现有行的状态(
- 每个文件仅写入一次。
File fully reviewed: <path/to/file> - 如果重新查看某个文件,在同一文件条目下添加注释;不要创建新的检查行或第二条记录。
File fully reviewed - 完成前验证:
- 状态的行数 == 唯一相关文件的数量。
reviewed - 报告中“进度跟踪”部分仅出现一次。
- 每个发现的位置至少出现在一个已审核的文件条目中。
Example report structure
示例报告结构
Use this high-level structure to keep the report consistent and to ensure a single "Progress Tracking" section:
markdown
undefined使用以下高层级结构保持报告一致,并确保仅包含一个“进度跟踪”部分:
markdown
undefinedimprovements.md
improvements.md
1. System summary
1. System summary
- Inferred architecture and main modules.
- Main risk surfaces.
- Inferred architecture and main modules.
- Main risk surfaces.
2. Conventions
2. Conventions
- Categories and severity scale used in the audit.
- Finding ID convention (,
A001, ...).A002
- Categories and severity scale used in the audit.
- Finding ID convention (,
A001, ...).A002
3. Progress Tracking
3. Progress Tracking
- path/to/file-a.ext
- path/to/file-b.ext
- path/to/file-c.ext
- path/to/file-a.ext
- path/to/file-b.ext
- path/to/file-c.ext
4. Complete finding inventory
4. Complete finding inventory
A001
A001
Category: ...
Severity: ...
Location: ...
Problem: ...
Impact: ...
Suggestion: ...
Correlation notes: ...
Security (if applicable): ...
Category: ...
Severity: ...
Location: ...
Problem: ...
Impact: ...
Suggestion: ...
Correlation notes: ...
Security (if applicable): ...
A002
A002
...
...
5. Prioritized backlog (all findings)
5. Prioritized backlog (all findings)
- Priority 1: A00X, A00Y...
- Priority 2: A00Z...
- Priority 1: A00X, A00Y...
- Priority 2: A00Z...
6. Detailed phased remediation plan
6. Detailed phased remediation plan
Phase 1
Phase 1
- Objective
- Findings included
- Dependencies
- Validation gates
- Exit criteria
- Objective
- Findings included
- Dependencies
- Validation gates
- Exit criteria
Phase 2
Phase 2
...
...
Phase 3
Phase 3
...
undefined...
undefinedCategories and severity
类别与严重程度
Use only these categories:
BugPerformanceSecurityDuplicationCode QualityArchitectureMaintainabilityObservabilityTestsDependencies
Use only these severity levels:
CriticalHighMediumLow
仅使用以下类别:
BugPerformanceSecurityDuplicationCode QualityArchitectureMaintainabilityObservabilityTestsDependencies
仅使用以下严重程度级别:
CriticalHighMediumLow
Mandatory format for each finding
每个发现的强制格式
Use unique sequential IDs (, , ...).
A001A002text
A0XX
Category: <...>
Severity: <Critical|High|Medium|Low>
Location: <file>:<start line>-<end line>
Problem: <objective description>
Impact: <real or potential impact>
Suggestion: <high-level fix, without editing code>
Correlation notes: <related files/flows>
Security (if applicable): <plausible abuse scenario + mitigation>使用唯一的连续ID(, , ...)。
A001A002text
A0XX
Category: <...>
Severity: <Critical|High|Medium|Low>
Location: <file>:<start line>-<end line>
Problem: <objective description>
Impact: <real or potential impact>
Suggestion: <high-level fix, without editing code>
Correlation notes: <related files/flows>
Security (if applicable): <plausible abuse scenario + mitigation>Detailed planning requirements
详细规划要求
The planning phase in must be explicit and implementation-oriented. Use this structure:
improvements.md- Planning assumptions and constraints:
- Confirm read-only audit boundaries.
- List unknowns that may affect remediation sequencing.
- Prioritized backlog (complete):
- Include all findings () with:
A001...A0XX- Priority order.
- Estimated effort (,
S,M) with a short rationale.L - Primary risk type (,
Correctness,Security,Performance,Reliability).Maintainability
- Include all findings (
- Phase plan with objective and controls:
- For each phase, include:
- Objective.
- Findings included (explicit ID list).
- Dependencies and ordering constraints.
- Validation gates (tests/checks/evidence expected after fixes).
- Exit criteria (what must be true to close the phase).
- For each phase, include:
- Sequencing rules:
- Resolve and exploitable
Criticalsecurity/correctness findings first.High - Schedule performance and maintainability work after risk containment unless blocking.
- Call out parallelizable workstreams and non-parallelizable bottlenecks.
- Resolve
- Delivery roadmap:
- Provide a suggested execution order by batch/wave.
- For each batch, list expected risk reduction and verification focus.
improvements.md- 规划假设与约束:
- 确认只读审计的边界。
- 列出可能影响修复顺序的未知因素。
- 完整的优先级待办事项:
- 包含所有发现(),并附带:
A001...A0XX- 优先级顺序。
- 预估工作量(,
S,M)及简短理由。L - 主要风险类型(,
Correctness,Security,Performance,Reliability)。Maintainability
- 包含所有发现(
- 包含目标与控制措施的阶段计划:
- 每个阶段包含:
- 目标。
- 包含的发现(明确的ID列表)。
- 依赖关系和顺序约束。
- 验证 gate(修复后预期的测试/检查/证据)。
- 退出标准(完成阶段必须满足的条件)。
- 每个阶段包含:
- 排序规则:
- 优先解决和可被利用的
Critical级别安全/正确性发现。High - 除非存在阻塞,否则在风险控制后安排性能和可维护性工作。
- 指出可并行的工作流和不可并行的瓶颈。
- 优先解决
- 交付路线图:
- 按批次/阶段提供建议的执行顺序。
- 为每个批次列出预期的风险降低效果和验证重点。
Traceability requirements
可追溯性要求
- Make every finding traceable to file and line/section.
- Avoid generic recommendations without evidence.
- Register all validated findings found during the audit, including low-severity and repeated-location findings.
- Explicitly record uncertainties when evidence is partial.
- 每个发现必须可追溯到文件和行/章节。
- 避免无证据的通用建议。
- 记录审计过程中发现的所有经过验证的发现,包括低严重程度和重复位置的发现。
- 当证据不完整时,明确记录不确定性。
Completion criteria
完成标准
Finish only when:
- All relevant files are marked as reviewed in Progress Tracking.
- Each reviewed file has the line .
File fully reviewed: ... - contains the complete finding inventory, a prioritized backlog, and a detailed phased plan.
improvements.md - The audited project remains intact, with only as the audit output artifact.
improvements.md
仅在满足以下条件时结束:
- 所有相关文件在进度跟踪中标记为已审核。
- 每个已审核文件都有记录。
File fully reviewed: ... - 包含完整的发现清单、优先级待办事项和详细的分阶段计划。
improvements.md - 被审计项目保持完整,仅生成作为审计输出产物。
improvements.md