An open-source static code analysis engine, a fork of Semgrep, for finding security issues and code patterns with semantic grep rules.
securego/gosec
A static analysis tool that scans Go source code for common security vulnerabilities and insecure coding patterns.
- Stars
- 9,000
- Forks
- 731
- Open issues
- 5
- Last commit
- 4 days ago
What is it?
gosec inspects Go source code for security problems by walking the AST and SSA representations of the code. It ships with rule groups covering hardcoded credentials, unsafe API usage, weak cryptography and TLS settings, file permission and path handling, and blocklisted imports, each mapped to a CWE identifier.
Its taint analysis rules track data flow from user input into sensitive sinks, covering injection classes such as SQL, command, template and SMTP injection, along with SSRF, path traversal, XSS, open redirect and unsafe deserialization. Findings can be suppressed inline with #nosec or //gosec:disable comments, or filtered by rule, path, severity and confidence.
Results can be exported as text, JSON, YAML, CSV, JUnit XML, HTML, SonarQube, golint or SARIF, and the tool can run as a GitHub Action or be installed with go install.
Key features
- 01Pattern-based rules for common Go security issues such as hardcoded credentials and weak crypto
- 02Taint analysis tracking user input into SQL, command, path, SSRF and XSS sinks
- 03Inline suppression with #nosec or //gosec:disable, with optional justification requirements
- 04Path-based rule exclusions and severity and confidence filters
- 05Multiple report formats including SARIF for GitHub code scanning
Use cases
- Running security checks on Go code in CI pipelines via the GitHub Action
- Uploading SARIF results to GitHub code scanning for pull request review
- Auditing a Go codebase for injection, weak crypto or insecure TLS settings before release
Quick start
- 1
Install gosec with go install (requires Go 1.25 or newer)
go install github.com/securego/gosec/v2/cmd/gosec@latest - 2
Scan all packages in the current module
gosec ./...
Things to know
- Requires Go 1.25 or newer to install and build.
In collections
Topics
FAQ
- What is gosec?
- A static analysis tool that scans Go source code for common security vulnerabilities and insecure coding patterns. gosec inspects Go source code for security problems by walking the AST and SSA representations of the code. It ships with rule groups covering hardcoded credentials, unsafe API usage, weak cryptography and TLS settings, file permission and path handling, and blocklisted imports, each mapped to a CWE identifier.
- Is gosec free to use? What license does it have?
- gosec is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is gosec still maintained?
- Actively maintained. The last commit to gosec was on Nov 3, 2026.
- What can I use gosec for?
- Running security checks on Go code in CI pipelines via the GitHub Action Uploading SARIF results to GitHub code scanning for pull request review Auditing a Go codebase for injection, weak crypto or insecure TLS settings before release
- How do I install gosec?
- Install gosec with go install (requires Go 1.25 or newer): go install github.com/securego/gosec/v2/cmd/gosec@latest Scan all packages in the current module: gosec ./...
- Where can I get gosec?
- The source code and installation instructions are on GitHub: https://github.com/securego/gosec
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Rust-based secret scanner that detects leaked credentials, validates which are live, maps their access, and supports revocation.
AI-first security scanner for code and AI agent configs, with built-in rules for LLM apps, MCP servers, and secrets leaked in chat or shell history.
A static analysis tool that finds and fixes security issues in CI/CD configurations such as GitHub Actions, Dependabot and pre-commit.
Fast, open-source static analysis CLI that finds bugs and enforces coding standards using code-like patterns instead of regex or ASTs.
Open source AI code review that runs a separate reviewer over your agent's changes before you push, for Claude Code, Codex, Cursor and Cline.