Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new gosec gh yaml file #846

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/gosec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Gosec
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
tests:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- name: Run Gosec
uses: securego/gosec@master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always running at the latest version of GoSec yeah ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's also the suggest way to structure the job taken from the gosec page

with:
args: '-exclude=G104,G115,G304,G406,G507 -exclude-dir=builtin/gen ./...'
2 changes: 0 additions & 2 deletions .github/workflows/lint-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ jobs:
args: --timeout=30m --config=.golangci.yml
only-new-issues: true
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run:
tests: true
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
exclude-dirs-use-default: true

linters:
disable-all: true
Expand Down
4 changes: 2 additions & 2 deletions cache/rnd_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (rc *RandCache) Pick() *Entry {
if len(rc.s) == 0 {
return nil
}
ent := rc.s[rand.Intn(len(rc.s))] // nolint:gosec
ent := rc.s[rand.Intn(len(rc.s))] // #nosec
cpy := ent.Entry
return &cpy
}
Expand Down Expand Up @@ -141,6 +141,6 @@ func (rc *RandCache) randDrop() {
if len(rc.s) == 0 {
return
}
ent := rc.s[rand.Intn(len(rc.s))] // nolint:gosec
ent := rc.s[rand.Intn(len(rc.s))] // #nosec
rc.remove(ent.Key)
}
2 changes: 1 addition & 1 deletion cmd/thor/solo/solo.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (s *Solo) newTx(clauses []*tx.Clause, from genesis.DevAccount) (*tx.Transac

newTx := builder.BlockRef(tx.NewBlockRef(0)).
Expiration(math.MaxUint32).
Nonce(rand.Uint64()). // nolint:gosec
Nonce(rand.Uint64()). // #nosec
DependsOn(nil).
Gas(1_000_000).
Build()
Expand Down
2 changes: 1 addition & 1 deletion comm/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (p *Peer) UpdateHead(id thor.Bytes32, totalScore uint64) {
// MarkTransaction marks a transaction to known.
func (p *Peer) MarkTransaction(hash thor.Bytes32) {
// that's 10~100 block intervals
expiration := mclock.AbsTime(time.Second * time.Duration(thor.BlockInterval*uint64(rand.Intn(91)+10))) // nolint:gosec
expiration := mclock.AbsTime(time.Second * time.Duration(thor.BlockInterval*uint64(rand.Intn(91)+10))) // #nosec

deadline := mclock.Now() + expiration
p.knownTxs.Add(hash, deadline)
Expand Down
2 changes: 1 addition & 1 deletion p2psrv/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (r *RPC) prepareCall(msgCode uint64, onResult func(*p2p.Msg) error) uint32
r.lock.Lock()
defer r.lock.Unlock()
for {
id := rand.Uint32() // nolint:gosec
id := rand.Uint32() // #nosec
if id == 0 {
// 0 id is taken by Notify
continue
Expand Down
4 changes: 2 additions & 2 deletions test/datagen/numbers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
)

func RandInt() int {
return mathrand.Int() // nolint:gosec
return mathrand.Int() // #nosec
}

func RandIntN(n int) int {
return mathrand.Intn(n) // nolint:gosec
return mathrand.Intn(n) // #nosec
}
2 changes: 1 addition & 1 deletion txpool/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (p *TxPool) fetchBlocklistLoop() {

for {
// delay 1~2 min
delay := time.Second * time.Duration(rand.Int()%60+60) // nolint:gosec
delay := time.Second * time.Duration(rand.Int()%60+60) // #nosec
select {
case <-p.ctx.Done():
return
Expand Down
Loading