π‘οΈ CodexSentinel

CodexSentinel is a powerful, blazing-fast static code analyzer for Go, built to identify security vulnerabilities, bad practices, architectural violations, and dependency risks. Designed for developers, DevSecOps, and auditors, it supports both CLI usage and structured JSON reports for integration with CI/CD pipelines.
π Table of Contents
π Features
- π OWASP Top 10 & common vulnerability detection (XSS, SQLi, SSRF, etc.)
- π¦ Third-party dependency audit (licenses, entropy, vulnerabilities via OSV)
- π§ Taint analysis and SSA-based dataflow tracing
- π Architecture compliance (direct calls, layer violations)
- π Code metrics (cyclomatic complexity, size, duplication, dead code)
- π
.codexsentinel.ignore support for suppressions
- β‘ CLI-first experience, ready for automation and pipelines
- π Reports in SARIF, JSON, Markdown, and HTML formats
- βοΈ YAML-based custom rule definition
- β
Zero-config startup with smart defaults
- π Individual file analysis - scan files with different package names
- π‘οΈ Graceful error handling - continues analysis even with package conflicts
- π Automatic report organization - saves reports to
scan_reports/ directory
- π SLSA Level 3 compliant releases for supply chain security
π¦ Installation and Usage (All OS)
π― Quick Install (Recommended)
curl -sSfL https://raw.githubusercontent.com/Voskan/codexsentinel/main/scripts/install.sh | sh
This script will:
- Download the latest binary for your OS
- Install it globally (add to PATH)
- Create a convenient
codex alias
- Work on Linux, macOS, and Windows (via Git Bash/WSL)
π§ Manual Install via Go
go install github.com/Voskan/codexsentinel/cmd/codex-cli@latest
π Where to find the binary
- By default, Go installs the binary as codex-cli in:
- Linux/macOS:
$HOME/go/bin/
- Windows:
%USERPROFILE%\go\bin\
π Make codex-cli globally available
Linux/macOS:
# Add to PATH permanently
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.bashrc
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.zshrc
# Reload shell configuration
source ~/.bashrc # or source ~/.zshrc
# Now you can run from anywhere:
codex-cli version
Windows (PowerShell):
# Add to PATH permanently
$goBinPath = "$env:USERPROFILE\go\bin"
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
[Environment]::SetEnvironmentVariable("PATH", "$currentPath;$goBinPath", "User")
# Reload environment variables
refreshenv # if you have Chocolatey installed
# or restart your terminal
# Now you can run from anywhere:
codex-cli version
Windows (Command Prompt):
# Add to PATH permanently
setx PATH "%PATH%;%USERPROFILE%\go\bin"
# Restart your terminal, then run:
codex-cli version
β‘ (Optional) Create a shorter alias
Linux/macOS:
# Add alias to your shell config
echo 'alias codex="codex-cli"' >> ~/.bashrc
echo 'alias codex="codex-cli"' >> ~/.zshrc
# Reload and use:
source ~/.bashrc # or source ~/.zshrc
codex version
Windows (PowerShell):
# Add to PowerShell profile
echo 'Set-Alias codex codex-cli' >> $PROFILE
# Reload and use:
. $PROFILE
codex version
β
Verify installation
# Should work from any directory:
codex-cli version
π¦ Usage
π Basic Scan
# Scan current directory
codex-cli scan .
# Scan specific file
codex-cli scan ./main.go
# Scan specific directory
codex-cli scan ./pkg/
# Scan with custom output
codex-cli scan . --format html --out report.html
# Scan individual files (even with different package names)
codex-cli scan testdata/command_injection.go
codex-cli scan testdata/xss_vulnerability.go
βοΈ Advanced Usage
# Scan with specific severity
codex-cli scan . --severity high
# Use custom config
codex-cli scan . --config .codex.yml
# Ignore specific files
codex-cli scan . --ignore-file .codexsentinel.ignore
# Generate SARIF for CI/CD
codex-cli scan . --format sarif --out results.sarif
# Generate HTML report (saved to scan_reports/)
codex-cli scan . --format html --out report.html
# Generate JSON report (saved to scan_reports/)
codex-cli scan . --format json --out report.json
# Run dependency analysis only
codex-cli scan . --deps
# Filter by severity (high and above)
codex-cli scan . --severity high
# Use custom config file
codex-cli scan . --config custom-config.yml
π Available Flags
| Flag |
Description |
Default |
-p, --path |
Target directory or file to scan |
. (current directory) |
-f, --format |
Output report format:sarif, html, markdown, json |
sarif |
-o, --out |
Path to write the output report to |
scan_reports/codex-report.{format} |
--strict |
Exit with code 1 if issues are found |
false |
--ignore-file |
Path to ignore file |
.codexsentinel.ignore |
--deps |
Run dependency analysis only |
false |
--config |
Path to a custom config file |
.codex.yml (if exists) |
--severity |
Filter issues by severity:low, medium, high, critical |
all (no filtering) |
π Report Output
Reports are automatically saved to the scan_reports/ directory:
- HTML reports:
scan_reports/codex-report.html
- JSON reports:
scan_reports/codex-report.json
- SARIF reports:
scan_reports/codex-report.sarif
- Markdown reports:
scan_reports/codex-report.md
The directory is created automatically if it doesn't exist.
π Project Structure
codexsentinel/
βββ analyzer/ # Core analyzers (AST, SSA, Taint, Rules)
βββ deps/ # Dependency & license scanners
βββ metrics/ # Complexity, duplication, dead code
βββ arch/ # Architecture layer rules
βββ report/ # Report generation (HTML, SARIF, etc.)
βββ cmd/ # CLI entrypoints
βββ internal/ # Internal utils (logging, config, fs)
βββ testdata/ # Example test files with security vulnerabilities
β βββ command_injection.go # Command injection examples
β βββ xss_vulnerability.go # XSS vulnerability examples
β βββ sql_injection.go # SQL injection examples
β βββ path_traversal.go # Path traversal examples
βββ assets/ # Rules, templates, CSS, etc.
π Examples
π Security Vulnerabilities
SQL Injection:
// β Vulnerable
query := "SELECT * FROM users WHERE id = " + userInput
db.Query(query)
// β
Safe
query := "SELECT * FROM users WHERE id = ?"
db.Query(query, userInput)
Command Injection:
// β Vulnerable
cmd := exec.Command("sh", "-c", userInput)
cmd.Run()
// β
Safe
cmd := exec.Command("echo", userInput)
cmd.Run()
XSS (Cross-Site Scripting):
// β Vulnerable
w.Write([]byte(userInput))
// β
Safe
w.Write([]byte(html.EscapeString(userInput)))
ποΈ Architecture Violations
Direct Layer Calls:
// β Handler directly calling repository
func (h *Handler) GetUser(id string) {
user := h.repo.GetUser(id) // Direct call to repo layer
}
// β
Handler calling service layer
func (h *Handler) GetUser(id string) {
user := h.service.GetUser(id) // Proper layer separation
}
π Running Analysis
# Scan for security issues
codex-cli scan ./... --strict
# Generate HTML report
codex-cli scan ./... --format html --out security-report.html
# Check architecture compliance
codex-cli scan ./... --config .codex.yml
# Scan test files with vulnerabilities
codex-cli scan testdata/
π Custom Rules
Create custom YAML rules and place them under assets/rules/.
id: go.insecure.xss.reflected_input
title: "XSS via Reflected Input"
category: "security"
severity: "high"
pattern: "w.Write([]byte({{input}}))"
filters:
- type: param
sources: [r.FormValue, r.URL.Query]
description: "Potential XSS vulnerability when writing user input directly to response"
suggestion: "Use html.EscapeString() to sanitize user input"
π Rule Structure
id: "unique.rule.identifier"
title: "Human readable title"
category: "security|style|performance"
severity: "low|medium|high|critical"
pattern: "Go AST pattern to match"
filters:
- type: "param|call|import"
sources: ["list", "of", "sources"]
description: "Detailed description of the issue"
suggestion: "How to fix the issue"
references:
- "https://owasp.org/..."
Learn more in assets/rules/.
π§ͺ Testing
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific test
go test ./analyzer/...
π CI/CD Integration
GitHub Actions
name: Security Scan
on: [push, pull_request]
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.24"
- name: Install CodexSentinel
run: go install github.com/Voskan/codexsentinel/cmd/codex-cli@latest
- name: Run Security Scan
run: codex-cli scan ./... --format sarif --out results.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
GitLab CI
security-scan:
stage: test
image: golang:1.24
script:
- go install github.com/Voskan/codexsentinel/cmd/codex-cli@latest
- codex-cli scan ./... --format sarif --out results.sarif
artifacts:
reports:
sarif: results.sarif
π License
MIT Β© Voskan - see the LICENSE file for details.
π¬ Contributing
We welcome PRs and new rule contributions. Please follow our contribution guide and ensure all changes are covered by tests.
π€ How to Contribute
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
π Development Setup
# Clone the repository
git clone https://github.com/Voskan/codexsentinel.git
cd codexsentinel
# Install dependencies
go mod download
# Run tests
go test ./...
# Build the binary
go build -o codex ./cmd/codex-cli
β¨ Example Reports
π JSON Report
{
"version": "0.1.0",
"timestamp": "2024-01-01T12:00:00Z",
"issues": [
{
"id": "SEC001",
"title": "SQL Injection",
"description": "Potential SQL injection vulnerability detected",
"severity": "high",
"location": {
"file": "main.go",
"line": 42,
"column": 10
},
"category": "security",
"rule_id": "go.insecure.sql_injection",
"suggestion": "Use parameterized queries"
}
]
}
π SARIF Report (for CI/CD)
{
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "CodexSentinel",
"version": "1.0.0"
}
},
"results": [
{
"ruleId": "go.insecure.sql_injection",
"level": "error",
"message": {
"text": "Potential SQL injection vulnerability"
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "main.go"
},
"region": {
"startLine": 42,
"startColumn": 10
}
}
}
]
}
]
}
]
}
π SLSA Level 3 Compliance
CodexSentinel releases are built with SLSA Level 3 compliance, ensuring:
- β
Provenance: Every release includes a provenance file describing the build process
- β
Verification: Anyone can verify that binaries were built from expected source code
- β
Reproducibility: Builds are reproducible and verifiable
- β
Supply Chain Security: Protection against supply chain attacks
π Verifying Releases
# Install slsa-verifier
go install github.com/slsa-framework/slsa-verifier/v2/cli/slsa-verifier@latest
# Verify a release
slsa-verifier verify-artifact \
--provenance-path codex-linux-amd64.intoto.jsonl \
--source-uri github.com/Voskan/codexsentinel \
--source-tag v1.0.0 \
codex-linux-amd64
π Release History
Latest Release: v1.0.0
Features:
- π Initial release with comprehensive security scanning
- π OWASP Top 10 vulnerability detection
- π¦ Dependency analysis with OSV integration
- ποΈ Architecture compliance checking
- π Multiple report formats (SARIF, JSON, HTML, Markdown)
- π SLSA Level 3 compliant releases
Supported Platforms:
- π§ Linux (AMD64, ARM64)
- π macOS (AMD64, ARM64)
- πͺ Windows (AMD64, ARM64)
Download: Latest Release
π Star History

π Project Statistics


π― Roadmap
- π Enhanced taint analysis with more precise data flow tracking
- π Advanced code metrics and visualization
- π§ IDE integration (VS Code, GoLand extensions)
- π Web-based dashboard for analysis results
- π Comprehensive rule library expansion
- π Real-time monitoring and alerting
- π§ͺ Integration with more CI/CD platforms
- π± Mobile app for quick scans
π€ Support
π Acknowledgments
- OWASP for security guidelines
- Go Team for the amazing language
- SLSA Framework for supply chain security
- All contributors and users of CodexSentinel
Made with β€οΈ by the CodexSentinel Team
