Skip to content
Cisco AI Defense logo
CiscoAI Security

CodeGuard — DefenseClaw

Overview

CodeGuard is the Go source-code scanner exposed by defenseclaw-gateway scan code. It walks a file or directory, filters to supported code/config extensions, applies built-in regex rules plus optional custom YAML rules, and emits scan results through the same audit path as other scanners.

What it scans

  • Files passed to defenseclaw-gateway scan code <path>.
  • Directories passed to scan code; the scanner skips .git, node_modules, __pycache__, .venv, and venv.
  • Extensions listed in internal/scanner/codeguard.go::codeExtensions.
  • Custom YAML rules from ~/.defenseclaw/codeguard-rules by default, or the configured scanners.codeguard directory.

Categories

Built-in ruleSeverityCategory
CG-CRED-001HIGHHardcoded API key or secret
CG-CRED-002HIGHAWS access key ID
CG-CRED-003CRITICALPrivate key embedded in source
CG-EXEC-001HIGHUnsafe command execution
CG-EXEC-002MEDIUMshell=True in Python subprocess
CG-NET-001MEDIUMOutbound HTTP request
CG-DESER-001HIGHUnsafe deserialization
CG-SQL-001HIGHPotential SQL injection
CG-CRYPTO-001MEDIUMWeak cryptographic algorithm
CG-PATH-001MEDIUMPotential path traversal

Configuration

scanners:
  codeguard: ~/.defenseclaw/codeguard-rules

Custom rule files are YAML documents with version and rules; each rule includes id, severity, title, pattern, remediation, and optional extensions.

CLI

defenseclaw-gateway scan code path/to/file.py
defenseclaw-gateway scan code ./src --json
defenseclaw-gateway scan code ./src --schema

The Python defenseclaw codeguard group currently manages the OpenClaw CodeGuard skill only:

defenseclaw codeguard install-skill

See CodeGuard CLI and gateway scan CLI.

Result shape

internal/cli/scan_v7.go serializes --json output with scanner name, target, timestamp, findings, duration, scan ID, schema version, and optional agent identifiers from environment variables.

Related