From 06d211ec3cf5c80ec3897a11bd0a0a32aed04aeb Mon Sep 17 00:00:00 2001 From: Harshavardhan Date: Mon, 15 Jun 2026 23:23:59 +0530 Subject: [PATCH] gosec: add page (#22635) Co-authored-by: Lena Pastwa --- pages/common/gosec.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pages/common/gosec.md diff --git a/pages/common/gosec.md b/pages/common/gosec.md new file mode 100644 index 0000000000..3fdbe12f24 --- /dev/null +++ b/pages/common/gosec.md @@ -0,0 +1,37 @@ +# gosec + +> Inspect Go source code for security problems. +> Note: `./...` is a Go package pattern understood by Go tooling. It matches the current package and all packages recursively under the current directory. +> More information: . + +- Scan a Go package recursively in the current directory: + +`gosec ./...` + +- Scan a specific Go package: + +`gosec {{path/to/package}}` + +- Scan a Go package recursively and save results to a file: + +`gosec -fmt {{json|yaml|csv|html|sonarqube|golint|sarif|junit-xml}} -out {{path/to/report}} {{./...}}` + +- Only include a specific set of rules (by default, all rules will run): + +`gosec -include {{G101,G203,G401,...}} {{./...}}` + +- Exclude directories from scanning: + +`gosec -exclude-dir {{path/to/excluded_directory}} {{./...}}` + +- Scan with a specific severity or confidence level: + +`gosec -severity {{low|medium|high}} -confidence {{low|medium|high}} {{./...}}` + +- Exclude a specific set of rules from scanning: + +`gosec -exclude {{G101,G304,G401,...}} {{./...}}` + +- Scan test files as well: + +`gosec -tests {{./...}}`