{"id":13416624,"url":"https://github.com/securego/gosec","last_synced_at":"2026-02-28T15:06:51.350Z","repository":{"id":37334664,"uuid":"63625434","full_name":"securego/gosec","owner":"securego","description":"Go security checker","archived":false,"fork":false,"pushed_at":"2026-01-06T13:44:42.000Z","size":5640,"stargazers_count":8603,"open_issues_count":13,"forks_count":674,"subscribers_count":82,"default_branch":"master","last_synced_at":"2026-01-08T05:26:35.025Z","etag":null,"topics":["golang","security","security-automation","security-tools","static-analysis","static-code-analysis"],"latest_commit_sha":null,"homepage":"https://securego.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/securego.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["ccojocar","gcmurphy"]}},"created_at":"2016-07-18T18:01:08.000Z","updated_at":"2026-01-08T03:16:24.000Z","dependencies_parsed_at":"2023-11-16T10:26:11.997Z","dependency_job_id":"103ee2de-2567-493f-9c36-51f3e9c00101","html_url":"https://github.com/securego/gosec","commit_stats":{"total_commits":969,"total_committers":166,"mean_commits":5.837349397590361,"dds":0.8008255933952528,"last_synced_commit":"1501618b90fccbe51cb283a4b21496a0ba86c311"},"previous_names":["goastscanner/gas","hewlettpackard/gas","securego/gas"],"tags_count":54,"template":false,"template_full_name":null,"purl":"pkg:github/securego/gosec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securego%2Fgosec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securego%2Fgosec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securego%2Fgosec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securego%2Fgosec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/securego","download_url":"https://codeload.github.com/securego/gosec/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securego%2Fgosec/sbom","scorecard":{"id":809183,"data":{"date":"2025-08-11","repo":{"name":"github.com/securego/gosec","commit":"cee0aeae8a8b6c2d59571e500bc69010f2630db6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":6.1,"checks":[{"name":"Code-Review","score":2,"reason":"Found 3/15 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/scan.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":10,"reason":"24 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:63: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/scan.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/scan.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/scan.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/scan.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/scan.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/securego/gosec/scan.yml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:2","Warn: containerImage not pinned by hash: Dockerfile:10","Info:   0 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of  12 third-party GitHubAction dependencies pinned","Info:   0 out of   2 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"CII-Best-Practices","score":5,"reason":"badge detected: Passing","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":8,"reason":"5 out of the last 5 releases have a total of 5 signed artifacts.","details":["Info: signed release artifact: gosec_2.22.8_checksums.txt.sig: https://github.com/securego/gosec/releases/tag/v2.22.8","Info: signed release artifact: gosec_2.22.7_checksums.txt.sig: https://github.com/securego/gosec/releases/tag/v2.22.7","Info: signed release artifact: gosec_2.22.6_checksums.txt.sig: https://github.com/securego/gosec/releases/tag/v2.22.6","Info: signed release artifact: gosec_2.22.5_checksums.txt.sig: https://github.com/securego/gosec/releases/tag/v2.22.5","Info: signed release artifact: gosec_2.22.4_checksums.txt.sig: https://github.com/securego/gosec/releases/tag/v2.22.4","Warn: release artifact v2.22.8 does not have provenance: https://api.github.com/repos/securego/gosec/releases/239961439","Warn: release artifact v2.22.7 does not have provenance: https://api.github.com/repos/securego/gosec/releases/233958837","Warn: release artifact v2.22.6 does not have provenance: https://api.github.com/repos/securego/gosec/releases/233854222","Warn: release artifact v2.22.5 does not have provenance: https://api.github.com/repos/securego/gosec/releases/225512105","Warn: release artifact v2.22.4 does not have provenance: https://api.github.com/repos/securego/gosec/releases/217272152"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":10,"reason":"SAST tool is run on all commits","details":["Info: all commits (30) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T12:38:58.783Z","repository_id":37334664,"created_at":"2025-08-23T12:38:58.783Z","updated_at":"2025-08-23T12:38:58.783Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28335066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","security","security-automation","security-tools","static-analysis","static-code-analysis"],"created_at":"2024-07-30T22:00:17.260Z","updated_at":"2026-01-12T04:54:46.676Z","avatar_url":"https://github.com/securego.png","language":"Go","readme":"\n# gosec - Go Security Checker\n\nInspects source code for security problems by scanning the Go AST and SSA code representation.\n\n\u003cimg src=\"https://securego.io/img/gosec.png\" width=\"320\"\u003e\n\n## License\n\nLicensed under the Apache License, Version 2.0 (the \"License\").\nYou may not use this file except in compliance with the License.\nYou may obtain a copy of the License [here](http://www.apache.org/licenses/LICENSE-2.0).\n\n## Project status\n\n[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3218/badge)](https://bestpractices.coreinfrastructure.org/projects/3218)\n[![Build Status](https://github.com/securego/gosec/workflows/CI/badge.svg)](https://github.com/securego/gosec/actions?query=workflows%3ACI)\n[![Coverage Status](https://codecov.io/gh/securego/gosec/branch/master/graph/badge.svg)](https://codecov.io/gh/securego/gosec)\n[![GoReport](https://goreportcard.com/badge/github.com/securego/gosec)](https://goreportcard.com/report/github.com/securego/gosec)\n[![GoDoc](https://pkg.go.dev/badge/github.com/securego/gosec/v2)](https://pkg.go.dev/github.com/securego/gosec/v2)\n[![Docs](https://readthedocs.org/projects/docs/badge/?version=latest)](https://securego.io/)\n[![Downloads](https://img.shields.io/github/downloads/securego/gosec/total.svg)](https://github.com/securego/gosec/releases)\n[![Docker Pulls](https://img.shields.io/docker/pulls/securego/gosec.svg)](https://hub.docker.com/r/securego/gosec/tags)\n[![Slack](https://img.shields.io/badge/Slack-4A154B?style=for-the-badge\u0026logo=slack\u0026logoColor=white)](http://securego.slack.com)\n[![go-recipes](https://raw.githubusercontent.com/nikolaydubina/go-recipes/main/badge.svg?raw=true)](https://github.com/nikolaydubina/go-recipes)\n\n## Install\n\n### CI Installation\n\n```bash\n# binary will be $(go env GOPATH)/bin/gosec\ncurl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z\n\n# or install it into ./bin/\ncurl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s vX.Y.Z\n\n# In alpine linux (as it does not come with curl by default)\nwget -O - -q https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s vX.Y.Z\n\n# If you want to use the checksums provided on the \"Releases\" page\n# then you will have to download a tar.gz file for your operating system instead of a binary file\nwget https://github.com/securego/gosec/releases/download/vX.Y.Z/gosec_vX.Y.Z_OS.tar.gz\n\n# The file will be in the current folder where you run the command\n# and you can check the checksum like this\necho \"\u003ccheck sum from the check sum file\u003e  gosec_vX.Y.Z_OS.tar.gz\" | sha256sum -c -\n\ngosec --help\n```\n\n### GitHub Action\n\nYou can run `gosec` as a GitHub action as follows:\n\n```yaml\nname: Run Gosec\non:\n  push:\n    branches:\n      - master\n  pull_request:\n    branches:\n      - master\njobs:\n  tests:\n    runs-on: ubuntu-latest\n    env:\n      GO111MODULE: on\n    steps:\n      - name: Checkout Source\n        uses: actions/checkout@v3\n      - name: Run Gosec Security Scanner\n        uses: securego/gosec@master\n        with:\n          args: ./...\n```\n\n#### Scanning Projects with Private Modules\n\nIf your project imports private Go modules, you need to configure authentication so that `gosec` can fetch the dependencies. Set the following environment variables in your workflow:\n\n- `GOPRIVATE`: A comma-separated list of module path prefixes that should be considered private (e.g., `github.com/your-org/*`).\n- `GITHUB_AUTHENTICATION_TOKEN`: A GitHub token with read access to your private repositories.\n\n```yaml\nname: Run Gosec\non:\n  push:\n    branches:\n      - master\n  pull_request:\n    branches:\n      - master\njobs:\n  tests:\n    runs-on: ubuntu-latest\n    env:\n      GO111MODULE: on\n      GOPRIVATE: github.com/your-org/*\n      GITHUB_AUTHENTICATION_TOKEN: ${{ secrets.PRIVATE_REPO_TOKEN }}\n    steps:\n      - name: Checkout Source\n        uses: actions/checkout@v3\n      - name: Run Gosec Security Scanner\n        uses: securego/gosec@master\n        with:\n          args: ./...\n```\n\n### Integrating with code scanning\n\nYou can [integrate third-party code analysis tools](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/integrating-with-code-scanning) with GitHub code scanning by uploading data as SARIF files.\n\nThe workflow shows an example of running the `gosec` as a step in a GitHub action workflow which outputs the `results.sarif` file. The workflow then uploads the `results.sarif` file to GitHub using the `upload-sarif` action.\n\n```yaml\nname: \"Security Scan\"\n\n# Run workflow each time code is pushed to your repository and on a schedule.\n# The scheduled workflow runs every at 00:00 on Sunday UTC time.\non:\n  push:\n  schedule:\n  - cron: '0 0 * * 0'\n\njobs:\n  tests:\n    runs-on: ubuntu-latest\n    env:\n      GO111MODULE: on\n    steps:\n      - name: Checkout Source\n        uses: actions/checkout@v3\n      - name: Run Gosec Security Scanner\n        uses: securego/gosec@master\n        with:\n          # we let the report trigger content trigger a failure using the GitHub Security features.\n          args: '-no-fail -fmt sarif -out results.sarif ./...'\n      - name: Upload SARIF file\n        uses: github/codeql-action/upload-sarif@v2\n        with:\n          # Path to SARIF file relative to the root of the repository\n          sarif_file: results.sarif\n```\n\n### Local Installation\n\n```bash\ngo install github.com/securego/gosec/v2/cmd/gosec@latest\n```\n\n## Usage\n\nGosec can be configured to only run a subset of rules, to exclude certain file\npaths, and produce reports in different formats. By default all rules will be\nrun against the supplied input files. To recursively scan from the current\ndirectory you can supply `./...` as the input argument.\n\n### Available rules\n\n- G101: Look for hard coded credentials\n- G102: Bind to all interfaces\n- G103: Audit the use of unsafe block\n- G104: Audit errors not checked\n- G106: Audit the use of ssh.InsecureIgnoreHostKey\n- G107: Url provided to HTTP request as taint input\n- G108: Profiling endpoint automatically exposed on /debug/pprof\n- G109: Potential Integer overflow made by strconv.Atoi result conversion to int16/32\n- G110: Potential DoS vulnerability via decompression bomb\n- G111: Potential directory traversal\n- G112: Potential slowloris attack\n- G114: Use of net/http serve function that has no support for setting timeouts\n- G115: Potential integer overflow when converting between integer types\n- G116: Detect Trojan Source attacks using bidirectional Unicode control characters\n- G117: Potential exposure of secrets via JSON marshaling\n- G201: SQL query construction using format string\n- G202: SQL query construction using string concatenation\n- G203: Use of unescaped data in HTML templates\n- G204: Audit use of command execution\n- G301: Poor file permissions used when creating a directory\n- G302: Poor file permissions used with chmod\n- G303: Creating tempfile using a predictable path\n- G304: File path provided as taint input\n- G305: File traversal when extracting zip/tar archive\n- G306: Poor file permissions used when writing to a new file\n- G307: Poor file permissions used when creating a file with os.Create\n- G401: Detect the usage of MD5 or SHA1\n- G402: Look for bad TLS connection settings\n- G403: Ensure minimum RSA key length of 2048 bits\n- G404: Insecure random number source (rand)\n- G405: Detect the usage of DES or RC4\n- G406: Detect the usage of MD4 or RIPEMD160\n- G407: Detect the usage of hardcoded Initialization Vector(IV)/Nonce\n- G501: Import blocklist: crypto/md5\n- G502: Import blocklist: crypto/des\n- G503: Import blocklist: crypto/rc4\n- G504: Import blocklist: net/http/cgi\n- G505: Import blocklist: crypto/sha1\n- G506: Import blocklist: golang.org/x/crypto/md4\n- G507: Import blocklist: golang.org/x/crypto/ripemd160\n- G601: Implicit memory aliasing of items from a range statement (only for Go 1.21 or lower)\n- G602: Slice access out of bounds\n\n### Retired rules\n\n- G105: Audit the use of math/big.Int.Exp - [CVE is fixed](https://github.com/golang/go/issues/15184)\n- G113: Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772). This affected Go \u003c1.16.14 and Go \u003c1.17.7, which are no longer supported by gosec. \n- G307: Deferring a method which returns an error - causing more inconvenience than fixing a security issue, despite the details from this [blog post](https://www.joeshaw.org/dont-defer-close-on-writable-files/)\n\n### Selecting rules\n\nBy default, gosec will run all rules against the supplied file paths. It is however possible to select a subset of rules to run via the `-include=` flag,\nor to specify a set of rules to explicitly exclude using the `-exclude=` flag.\n\n```bash\n# Run a specific set of rules\n$ gosec -include=G101,G203,G401 ./...\n\n# Run everything except for rule G303\n$ gosec -exclude=G303 ./...\n```\n\n### CWE Mapping\n\nEvery issue detected by `gosec` is mapped to a [CWE (Common Weakness Enumeration)](http://cwe.mitre.org/data/index.html) which describes in more generic terms the vulnerability. The exact mapping can be found  [here](https://github.com/securego/gosec/blob/master/issue/issue.go#L50).\n\n### Configuration\n\nA number of global settings can be provided in a configuration file as follows:\n\n```JSON\n{\n    \"global\": {\n        \"nosec\": \"enabled\",\n        \"audit\": \"enabled\"\n    }\n}\n```\n\n- `nosec`: this setting will overwrite all `#nosec` directives defined throughout the code base\n- `audit`: runs in audit mode which enables addition checks that for normal code analysis might be too nosy\n\n```bash\n# Run with a global configuration file\n$ gosec -conf config.json .\n```\n\n#### Rule Configuration\n\nSome rules accept configuration flags as well; these flags are documented in [RULES.md](https://github.com/securego/gosec/blob/master/RULES.md).\n\n#### Go version\n\nSome rules require a specific Go version which is retrieved from the Go module file present in the project. If this version cannot be found, it will fallback to Go runtime version.\n\nThe Go module version is parsed using the `go list` command which in some cases might lead to performance degradation. In this situation, the go module version can be easily provided by setting the environment variable `GOSECGOVERSION=go1.21.1`.\n\n### Dependencies\n\ngosec will fetch automatically the dependencies of the code which is being analyzed when go module is turned on (e.g.`GO111MODULE=on`). If this is not the case,\nthe dependencies need to be explicitly downloaded by running the `go get -d` command before the scan.\n\n### Excluding test files and folders\n\ngosec will ignore test files across all packages and any dependencies in your vendor directory.\n\nThe scanning of test files can be enabled with the following flag:\n\n```bash\ngosec -tests ./...\n```\n\nAlso additional folders can be excluded as follows:\n\n```bash\n gosec -exclude-dir=rules -exclude-dir=cmd ./...\n```\n\n### Excluding generated files\n\ngosec can ignore generated go files with default generated code comment.\n\n```\n// Code generated by some generator DO NOT EDIT.\n```\n\n```bash\ngosec -exclude-generated ./...\n```\n\n### Auto fixing vulnerabilities\n\ngosec can suggest fixes based on AI recommendation. It will call an AI API to receive a suggestion for a security finding.\n\nYou can enable this feature by providing the following command line arguments:\n\n- `ai-api-provider`: the name of the AI API provider. Supported providers:\n  - **Gemini**: `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-2.5-flash-lite`, `gemini-2.0-flash`, `gemini-2.0-flash-lite` (default)\n  - **Claude**: `claude-sonnet-4-0` (default), `claude-opus-4-0`, `claude-opus-4-1`, `claude-sonnet-3-7`\n  - **OpenAI**: `gpt-4o` (default), `gpt-4o-mini`\n  - **Custom OpenAI-compatible**: Any custom model name (requires `ai-base-url`)\n- `ai-api-key` or set the environment variable `GOSEC_AI_API_KEY`: the key to access the AI API\n  - For Gemini, you can create an API key following [these instructions](https://ai.google.dev/gemini-api/docs/api-key)\n  - For Claude, get your API key from [Anthropic Console](https://console.anthropic.com/)\n  - For OpenAI, get your API key from [OpenAI Platform](https://platform.openai.com/api-keys)\n- `ai-base-url`: (optional) custom base URL for OpenAI-compatible APIs (e.g., Azure OpenAI, LocalAI, Ollama)\n- `ai-skip-ssl`: (optional) skip SSL certificate verification for AI API (useful for self-signed certificates)\n\n**Examples:**\n\n```bash\n# Using Gemini\ngosec -ai-api-provider=\"gemini-2.0-flash\" -ai-api-key=\"your_key\" ./...\n\n# Using Claude\ngosec -ai-api-provider=\"claude-sonnet-4-0\" -ai-api-key=\"your_key\" ./...\n\n# Using OpenAI\ngosec -ai-api-provider=\"gpt-4o\" -ai-api-key=\"your_key\" ./...\n\n# Using Azure OpenAI\ngosec -ai-api-provider=\"gpt-4o\" \\\n  -ai-api-key=\"your_azure_key\" \\\n  -ai-base-url=\"https://your-resource.openai.azure.com/openai/deployments/your-deployment\" \\\n  ./...\n\n# Using local Ollama with custom model\ngosec -ai-api-provider=\"llama3.2\" \\\n  -ai-base-url=\"http://localhost:11434/v1\" \\\n  ./...\n\n# Using self-signed certificate API\ngosec -ai-api-provider=\"custom-model\" \\\n  -ai-api-key=\"your_key\" \\\n  -ai-base-url=\"https://internal-api.company.com/v1\" \\\n  -ai-skip-ssl \\\n  ./...\n```\n\n### Annotating code\n\nAs with all automated detection tools, there will be cases of false positives.\nIn cases where gosec reports a failure that has been manually verified as being safe,\nit is possible to annotate the code with a comment that starts with `#nosec`.\n\nThe `#nosec` comment should have the format `#nosec [RuleList] [-- Justification]`.\n\nThe `#nosec` comment needs to be placed on the line where the warning is reported.\n\n```go\nfunc main() {\n\ttr := \u0026http.Transport{\n\t\tTLSClientConfig: \u0026tls.Config{\n\t\t\tInsecureSkipVerify: true, // #nosec G402\n\t\t},\n\t}\n\n\tclient := \u0026http.Client{Transport: tr}\n\t_, err := client.Get(\"https://go.dev/\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n}\n```\n\nWhen a specific false positive has been identified and verified as safe, you may\nwish to suppress only that single rule (or a specific set of rules) within a section of code,\nwhile continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within\nthe `#nosec` annotation, e.g: `/* #nosec G401 */` or `//#nosec G201 G202 G203`\n\nYou could put the description or justification text for the annotation. The\njustification should be after the rule(s) to suppress and start with two or\nmore dashes, e.g: `//#nosec G101 G102 -- This is a false positive`\n\nAlternatively, gosec also supports the `//gosec:disable` directive, which functions similar to `#nosec`:\n\n```go\n//gosec:disable G101 -- This is a false positive\n```\n\nIn some cases you may also want to revisit places where `#nosec` or `//gosec:disable` annotations\nhave been used. To run the scanner and ignore any `#nosec` annotations you\ncan do the following:\n\n```bash\ngosec -nosec=true ./...\n```\n\n### Tracking suppressions\n\nAs described above, we could suppress violations externally (using `-include`/\n`-exclude`) or inline (using `#nosec` annotations) in gosec. This suppression\ninflammation can be used to generate corresponding signals for auditing\npurposes.\n\nWe could track suppressions by the `-track-suppressions` flag as follows:\n\n```bash\ngosec -track-suppressions -exclude=G101 -fmt=sarif -out=results.sarif ./...\n```\n\n- For external suppressions, gosec records suppression info where `kind` is\n`external` and `justification` is a certain sentence \"Globally suppressed\".\n- For inline suppressions, gosec records suppression info where `kind` is\n`inSource` and `justification` is the text after two or more dashes in the\ncomment.\n\n**Note:** Only SARIF and JSON formats support tracking suppressions.\n\n### Build tags\n\ngosec is able to pass your [Go build tags](https://pkg.go.dev/go/build/) to the analyzer.\nThey can be provided as a comma separated list as follows:\n\n```bash\ngosec -tags debug,ignore ./...\n```\n\n### Output formats\n\ngosec currently supports `text`, `json`, `yaml`, `csv`, `sonarqube`, `JUnit XML`, `html` and `golint` output formats. By default\nresults will be reported to stdout, but can also be written to an output\nfile. The output format is controlled by the `-fmt` flag, and the output file is controlled by the `-out` flag as follows:\n\n```bash\n# Write output in json format to results.json\n$ gosec -fmt=json -out=results.json *.go\n```\n\nResults will be reported to stdout as well as to the provided output file by `-stdout` flag. The `-verbose` flag overrides the\noutput format when stdout the results while saving them in the output file\n```bash\n# Write output in json format to results.json as well as stdout\n$ gosec -fmt=json -out=results.json -stdout *.go\n\n# Overrides the output format to 'text' when stdout the results, while writing it to results.json\n$ gosec -fmt=json -out=results.json -stdout -verbose=text *.go\n```\n\n**Note:** gosec generates the [generic issue import format](https://docs.sonarqube.org/latest/analysis/generic-issue/) for SonarQube, and a report has to be imported into SonarQube using `sonar.externalIssuesReportPaths=path/to/gosec-report.json`.\n\n## Development\n\n[CONTRIBUTING.md](https://github.com/securego/gosec/blob/master/CONTRIBUTING.md) contains detailed information about adding new rules to gosec.\n\n### Build\n\nYou can build the binary with:\n\n```bash\nmake\n```\n\n### Note on Sarif Types Generation\n\nInstall the tool with :\n\n```bash\ngo get -u github.com/a-h/generate/cmd/schema-generate\n```\n\nThen generate the types with :\n\n```bash\nschema-generate -i sarif-schema-2.1.0.json -o mypath/types.go\n```\n\nMost of the MarshallJSON/UnmarshalJSON are removed except the one for PropertyBag which is handy to inline the additional properties. The rest can be removed.\nThe URI,ID, UUID, GUID were renamed so it fits the Go convention defined [here](https://github.com/golang/lint/blob/master/lint.go#L700)\n\n### Tests\n\nYou can run all unit tests using:\n\n```bash\nmake test\n```\n\n### Release\n\nYou can create a release by tagging the version as follows:\n\n``` bash\ngit tag v1.0.0 -m \"Release version v1.0.0\"\ngit push origin v1.0.0\n```\n\nThe GitHub [release workflow](.github/workflows/release.yml) triggers immediately after the tag is pushed upstream. This flow will\nrelease the binaries using the [goreleaser](https://goreleaser.com/actions/) action and then it will build and publish the docker image into Docker Hub.\n\nThe released artifacts are signed using [cosign](https://docs.sigstore.dev/). You can use the public key from [cosign.pub](cosign.pub)\nfile to verify the signature of docker image and binaries files.\n\nThe docker image signature can be verified with the following command:\n```\ncosign verify --key cosign.pub securego/gosec:\u003cTAG\u003e\n```\n\nThe binary files signature can be verified with the following command:\n```\ncosign verify-blob --key cosign.pub --signature gosec_\u003cVERSION\u003e_darwin_amd64.tar.gz.sig  gosec_\u003cVERSION\u003e_darwin_amd64.tar.gz\n```\n\n### Docker image\n\nYou can also build locally the docker image by using the command:\n\n```bash\nmake image\n```\n\nYou can run the `gosec` tool in a container against your local Go project. You only have to mount the project\ninto a volume as follows:\n\n```bash\ndocker run --rm -it -w /\u003cPROJECT\u003e/ -v \u003cYOUR PROJECT PATH\u003e/\u003cPROJECT\u003e:/\u003cPROJECT\u003e securego/gosec /\u003cPROJECT\u003e/...\n```\n\n**Note:** the current working directory needs to be set with `-w` option in order to get successfully resolved the dependencies from go module file\n\n### Generate TLS rule\n\nThe configuration of TLS rule can be generated from [Mozilla's TLS ciphers recommendation](https://statics.tls.security.mozilla.org/server-side-tls-conf.json).\n\nFirst you need to install the generator tool:\n\n```bash\ngo get github.com/securego/gosec/v2/cmd/tlsconfig/...\n```\n\nYou can invoke now the `go generate` in the root of the project:\n\n```bash\ngo generate ./...\n```\n\nThis will generate the `rules/tls_config.go` file which will contain the current ciphers recommendation from Mozilla.\n\n## Who is using gosec?\n\nThis is a [list](USERS.md) with some of the gosec's users.\n\n## Sponsors\n\nSupport this project by becoming a sponsor. Your logo will show up here with a link to your website\n\n\u003ca href=\"https://github.com/mercedes-benz\" target=\"_blank\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/34240465?s=80\u0026v=4\"\u003e\u003c/a\u003e\n","funding_links":["https://github.com/sponsors/ccojocar","https://github.com/sponsors/gcmurphy"],"categories":["Misc","开源类库","Go","Tools","SAST","Open source library","Static Code Analysis","Go (531)","📚 Learning Resources","\u003ca id=\"eb2d1ffb231cee014ed24d59ca987da2\"\u003e\u003c/a\u003e未分类-XxTarget","漏洞库_漏洞靶场","Popular","Build techniques","Static Application Security Testing (SAST)"],"sub_categories":["代码分析","Static Analysis","Code Analysis","Go Security","\u003ca id=\"0476f6b97e87176da0a0d7328f8747e7\"\u003e\u003c/a\u003eblog","资源传输下载","Supply chain beyond libraries","Language Specific"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecurego%2Fgosec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecurego%2Fgosec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecurego%2Fgosec/lists"}