Get the FREE Ultimate OpenClaw Setup Guide →

audit

npx machina-cli add skill mrsknetwork/supernova/audit --openclaw
Files (1)
SKILL.md
4.4 KB

Audit Engineering

Purpose

Auditing is the quality gate that catches what the executor misses. It exists to provide an independent, systematic review of the codebase - not a casual read-through, but a structured analysis against a predefined checklist. The output is a finding report that can be actioned, not a vague list of "things to improve."

SOP: Code and Security Audit

Step 1 - Audit Scope Definition

Ask before beginning:

  1. What is the scope? (Single file, a PR diff, an entire module, the full codebase?)
  2. What type of audit? (Security, performance, code quality, architecture, or all four?)
  3. Is there a specific concern that triggered this audit?

A scoped audit is more useful than a comprehensive one that produces 50 findings nobody will act on.

Step 2 - Severity Taxonomy

Every finding must be categorized. Use this scale consistently:

SeverityDefinitionSLA to Fix
CriticalCan be exploited immediately; data breach or system compromise riskBefore next deploy
HighSignificant functional or security flaw; likely to cause production incidentWithin 1 sprint
MediumCode quality, maintainability, or minor security hardening issueWithin 2 sprints
LowStylistic issue, minor improvement, or best practice deviationBacklog
InfoObservation with no immediate action requiredRecord only

Never skip severity assignment. "This is bad" is not actionable. "This is Critical because..." is.

Step 3 - Security Audit Checklist (FastAPI + Next.js)

Walk through each check and log findings:

Authentication and Authorization:

  • Every non-public route has Depends(get_current_user) or session check.
  • Service-layer functions check current_user.id == resource.user_id before returning data.
  • JWT expiry is enforced; tokens expire within 15-60 minutes.

Input Handling:

  • All external inputs pass through Pydantic validators or Zod schemas.
  • No raw f-string SQL construction anywhere in the codebase (grep -r "f\"" -- "*.py" and check for SQL patterns).
  • File uploads validate MIME type and size server-side (not just client-side).

Secrets:

  • git log -p | grep -i "password\|secret\|key\|token" - no secrets in git history.
  • .env is in .gitignore.
  • No hardcoded API keys or connection strings in source files.

Dependencies:

  • pip-audit or safety check passes with no known CVEs.
  • npm audit passes with 0 critical or high vulnerabilities.

Step 4 - Code Quality Checklist

Complexity:

  • No function exceeds 40 lines. Extract helpers if needed.
  • No function has more than 4 levels of nesting. Flatten with early returns.
  • Cyclomatic complexity: ruff check --select C901 src/.

Test Coverage:

  • pytest --cov=src --cov-report=term-missing - identify untested files.
  • Critical paths (auth, payment, data deletion) have explicit test coverage.
  • No known failing tests are being skipped with @pytest.mark.skip.

Duplication:

  • No copy-pasted logic between files. Common patterns extracted to utilities.

Step 5 - Finding Evidence Format

Every finding must cite specific evidence:

[Severity] Finding: [Short title]
File: src/api/v1/orders.py, Line 47
Code: `order = await db.execute(f"SELECT * FROM orders WHERE id = '{order_id}'")`
Risk: SQL injection via unsanitized `order_id` parameter. An attacker can pass `' OR '1'='1` to exfiltrate all orders.
Remediation: Replace with ORM query: `await db.execute(select(Order).where(Order.id == order_id))`.

No finding is valid without a File: and Code: cite. "The auth looks weak" is not a finding.

Step 6 - Audit Report Output Format

# Audit Report: [Scope] - [Date]

## Summary
| Severity | Count |
|---|---|
| Critical | 1 |
| High | 2 |
| Medium | 5 |
| Low | 8 |
| Info | 3 |

## Critical Findings
[Finding detail as per Step 5 format]

## High Findings
...

## Remediation Checklist
- [ ] [File:Line] Fix SQL injection in orders endpoint
- [ ] [File:Line] Add row-level authorization to GET /invoices/{id}

Source

git clone https://github.com/mrsknetwork/supernova/blob/main/skills/audit/SKILL.mdView on GitHub

Overview

Audit provides an independent, systematic review of the codebase using a predefined checklist, producing severity-categorized findings with file/line evidence and actionable remediation. It guides reviews of PRs, security postures, technical debt, and release readiness, and mandates resolution before merging critical findings.

How This Skill Works

Define audit scope, assign a severity using a formal taxonomy, and apply both security and code quality checklists. Findings include precise evidence and remediation steps, with evidence formats and SLA expectations to ensure actionable outcomes.

When to Use It

  • Reviewing a PR to ensure changes are auditable and compliant
  • Conducting a security review of the codebase
  • Evaluating technical debt and maintainability
  • Assessing code quality before a release
  • Performing architecture or component audits to validate design decisions

Quick Start

  1. Step 1: Define the audit scope and type (security, code quality, architecture) for the target PR or codebase
  2. Step 2: Run the Severity Taxonomy and the Security + Code Quality checklists to surface findings
  3. Step 3: Compile findings with file/line evidence and remediation; enforce resolution before merging critical items

Best Practices

  • Define the audit scope up front (files, modules, or entire codebase)
  • Always assign a severity and an SLA for every finding
  • Require concrete file/line evidence and explicit remediation in findings
  • Run both Security Audit Checklist and Code Quality Checklist for comprehensive coverage
  • Do not merge critical findings until a documented resolution is in place

Example Use Cases

  • PR audit reveals a missing authorization check on a non-public route; severity High; remediation: enforce access via Depends(get_current_user) and add role checks
  • SQL construction uses unsafe string formatting; remediation: switch to ORM queries or parameterized statements
  • Secrets appear in git history; remediation: purge history, rotate keys, and add .gitignore safeguards
  • Input data lacks validation; remediation: add Pydantic validators and schema enforcement
  • Critical paths lack test coverage; remediation: introduce targeted pytest coverage for auth, payment, and data deletion

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers