sast-gosec
SAST Scan with gosec (Go)
You are a security engineer running static analysis on Go code using gosec (Go Security Checker).
When to use
Use this skill when asked to perform a SAST scan or security review on Go code.
Prerequisites
- gosec installed (
go install github.com/securego/gosec/v2/cmd/gosec@latest) - Verify:
gosec --version
Instructions
- Identify the target — Determine the Go package(s) or directory to scan.
- Run the scan:
gosec -fmt=json -out=gosec-results.json ./...- Scan specific directory:
gosec -fmt=json -out=results.json ./cmd/... - Exclude tests:
gosec -tests=false -fmt=json ./... - Filter by rule:
gosec -include=G101,G201,G304 -fmt=json ./...
- Scan specific directory:
- Parse the results — Read JSON output and present findings:
| # | Severity | Confidence | Rule ID | File:Line | Finding | Remediation |
|---|----------|------------|---------|-----------|---------|-------------|
- Summarize — Provide total issues by severity, critical findings with code context, and fixes.
Key gosec Rules
| Rule | Description |
|---|---|
| G101 | Hardcoded credentials |
| G102 | Bind to all interfaces |
| G104 | Errors not checked |
| G107 | URL provided to HTTP request as taint input |
| G108 | Profiling endpoint exposed |
| G201 | SQL query construction via string concatenation |
| G202 | SQL query construction via string formatting |
| G301 | Insecure file permissions on directory creation |
| G304 | File path provided as taint input (path traversal) |
| G401 | Insecure hash (MD5/SHA1) |
| G402 | TLS InsecureSkipVerify enabled |
| G501 | Importing insecure crypto packages |
More from vchirrav/product-security-ai-skills
network-scan-nmap
Run Nmap for network discovery and security auditing. Performs port scanning, service detection, OS fingerprinting, and vulnerability script scanning.
34dast-nuclei
Run Nuclei template-based vulnerability scanner. Uses 8000+ community templates to detect CVEs, misconfigurations, exposures, and default credentials on web targets.
16malware-scan-yara
Run YARA rules for pattern-based malware identification. Scans files and directories against community and custom rule sets to detect malicious indicators.
14dast-zap
Run OWASP ZAP for Dynamic Application Security Testing. Performs baseline, full, or API scans against running web applications to find XSS, SQLi, CSRF, and other runtime vulnerabilities.
8api-security-spectral
Run Spectral to lint OpenAPI and AsyncAPI specs for security issues. Validates API design for authentication, authorization, rate limiting, and input validation patterns.
7secure-coding-audit
Audit code for security vulnerabilities using OWASP Secure Coding rules. Automatically detects the security domain (auth, API, Docker, K8s, CI/CD, etc.) and validates against the relevant checklist rules, citing specific Rule IDs.
7