<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# Detecting Malicious Code Commits — API Reference

## Semgrep

```bash
# Run security audit rules
semgrep --config "p/security-audit" --json .

# Custom rule for backdoor patterns
semgrep --config rules/backdoor-patterns.yml --json .

# Run specific rule
semgrep -e 'eval($X)' --lang python --json .
```

## TruffleHog

```bash
# Scan git history for secrets
trufflehog git file://. --json

# Scan specific branch
trufflehog git file://. --branch main --json

# Scan since specific commit
trufflehog git file://. --since-commit abc123 --json
```

## Git Analysis Commands

```bash
# Show commit diff stats
git log --stat --format='%H %an %s'

# Find commits touching specific patterns
git log -p --all -G 'pattern' --format='%H %an %ae %ai %s'

# List files changed per author
git log --author='name' --name-only --format='' | sort | uniq -c | sort -rn
```

