"git@web.lueluesay.top:chenxi/sub2api.git" did not exist on "9fd95df5cf276ab545f82591de47d8a82bd2cf89"
Commit fbfbb26f authored by shaw's avatar shaw
Browse files

fix(ci): 将 gosec 集成到 golangci-lint 解决安全扫描超时

standalone gosec 扫描 24 万行 Go 代码在 CI 中持续超时,
将其作为 golangci-lint 的内置 linter 运行,复用 AST 解析和缓存大幅提速。

- 在 .golangci.yml 中启用 gosec 并迁移原有排除规则
- golangci-lint timeout 从 5m 提升到 30m
- 从 security-scan.yml 移除 standalone gosec 步骤
- 删除不再需要的 .gosec.json 配置文件
parent 493bd188
...@@ -43,5 +43,5 @@ jobs: ...@@ -43,5 +43,5 @@ jobs:
uses: golangci/golangci-lint-action@v9 uses: golangci/golangci-lint-action@v9
with: with:
version: v2.7 version: v2.7
args: --timeout=5m args: --timeout=30m
working-directory: backend working-directory: backend
\ No newline at end of file
...@@ -29,12 +29,6 @@ jobs: ...@@ -29,12 +29,6 @@ jobs:
run: | run: |
go install golang.org/x/vuln/cmd/govulncheck@latest go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./... govulncheck ./...
- name: Run gosec
working-directory: backend
run: |
go install github.com/securego/gosec/v2/cmd/gosec@latest
# exclude ent/ — auto-generated ORM code, not subject to manual security review
gosec -conf .gosec.json -severity high -confidence high -exclude-generated -exclude-dir=ent ./...
frontend-security: frontend-security:
runs-on: ubuntu-latest runs-on: ubuntu-latest
......
...@@ -5,6 +5,7 @@ linters: ...@@ -5,6 +5,7 @@ linters:
enable: enable:
- depguard - depguard
- errcheck - errcheck
- gosec
- govet - govet
- ineffassign - ineffassign
- staticcheck - staticcheck
...@@ -42,6 +43,22 @@ linters: ...@@ -42,6 +43,22 @@ linters:
desc: "handler must not import gorm" desc: "handler must not import gorm"
- pkg: github.com/redis/go-redis/v9 - pkg: github.com/redis/go-redis/v9
desc: "handler must not import redis" desc: "handler must not import redis"
gosec:
excludes:
- G101
- G103
- G104
- G109
- G115
- G201
- G202
- G301
- G302
- G304
- G306
- G404
severity: high
confidence: high
errcheck: errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`. # Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default. # Such cases aren't reported by default.
......
{
"global": {
"exclude": "G704,G101,G103,G104,G109,G115,G201,G202,G301,G302,G304,G306,G404"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment