Skip to content

Commit 13cf11a

Browse files
authored
chore: codeql changes (#20091)
1 parent d41aa7a commit 13cf11a

File tree

5 files changed

+29
-44
lines changed

5 files changed

+29
-44
lines changed

.github/codeql/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
packs:
2+
- crypto-com/cosmos-sdk-codeql
3+
queries:
4+
- uses: security-and-quality
5+
- uses: security-experimental
6+
- uses: security-extended
7+
paths-ignore:
8+
- api
9+
- '**/*_test.go'
10+
- '**/*.pulsar.go'
11+
- '**/*.pb.gp'

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
uses: github/codeql-action/init@v3
3333
with:
3434
languages: "go"
35-
queries: +security-and-quality,github/codeql/go/ql/src/experimental/InconsistentCode/DeferInLoop.ql@main,github/codeql/go/ql/src/experimental/Unsafe/WrongUsageOfUnsafe.ql@main,github/codeql/go/ql/src/experimental/CWE-369/DivideByZero.ql@main
36-
packs: +crypto-com/cosmos-sdk-codeql
35+
config-file: ./.github/codeql/config.yml
36+
3737
# If you wish to specify custom queries, you can do so here or in a config file.
3838
# By default, queries listed here will override any specified in a config file.
3939
# Prefix the list here with "+" to use these queries and those in the config file.

crypto/keys/bcrypt/bcrypt.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ func (p *hashed) decodeVersion(sbytes []byte) (int, error) {
268268

269269
// decodeCost sbytes should begin where decodeVersion left off.
270270
func (p *hashed) decodeCost(sbytes []byte) (int, error) {
271-
cost, err := strconv.Atoi(string(sbytes[0:2]))
271+
cost, err := strconv.ParseUint(string(sbytes[0:2]), 10, 32)
272272
if err != nil {
273273
return -1, err
274274
}
275-
err = checkCost(uint32(cost))
275+
err = checkCost(uint64to32(cost))
276276
if err != nil {
277277
return -1, err
278278
}
279-
p.cost = uint32(cost)
279+
p.cost = uint64to32(cost)
280280
return 3, nil
281281
}
282282

@@ -290,3 +290,13 @@ func checkCost(cost uint32) error {
290290
}
291291
return nil
292292
}
293+
294+
// uint64to32 converts a uint64 value to a uint32 value.
295+
// If the input value is greater than 0xFFFFFFFF, it returns 0xFFFFFFFF.
296+
// Otherwise, it returns the input value converted to uint32.
297+
func uint64to32(u uint64) uint32 {
298+
if u > 0xFFFFFFFF {
299+
return 0xFFFFFFFF
300+
}
301+
return uint32(u)
302+
}

store/db/db.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ type RawDBType string
1010

1111
const (
1212
DBTypeGoLevelDB RawDBType = "goleveldb"
13-
DBTypeRocksDB = "rocksdb"
14-
DBTypePebbleDB = "pebbledb"
15-
DBTypePrefixDB = "prefixdb"
13+
DBTypeRocksDB RawDBType = "rocksdb"
14+
DBTypePebbleDB RawDBType = "pebbledb"
15+
DBTypePrefixDB RawDBType = "prefixdb"
1616

1717
DBFileSuffix string = ".db"
1818
)

store/db/rocksdb_noflag.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,3 @@ func (db *RocksDB) NewBatch() store.RawBatch {
5050
func (db *RocksDB) NewBatchWithSize(_ int) store.RawBatch {
5151
return db.NewBatch()
5252
}
53-
54-
var _ corestore.Iterator = (*rocksDBIterator)(nil)
55-
56-
type rocksDBIterator struct{}
57-
58-
func (itr *rocksDBIterator) Domain() (start, end []byte) {
59-
panic("rocksdb must be built with -tags rocksdb")
60-
}
61-
62-
func (itr *rocksDBIterator) Valid() bool {
63-
panic("rocksdb must be built with -tags rocksdb")
64-
}
65-
66-
func (itr *rocksDBIterator) Key() []byte {
67-
panic("rocksdb must be built with -tags rocksdb")
68-
}
69-
70-
func (itr *rocksDBIterator) Value() []byte {
71-
panic("rocksdb must be built with -tags rocksdb")
72-
}
73-
74-
func (itr *rocksDBIterator) Next() {
75-
panic("rocksdb must be built with -tags rocksdb")
76-
}
77-
78-
func (itr *rocksDBIterator) Error() error {
79-
panic("rocksdb must be built with -tags rocksdb")
80-
}
81-
82-
func (itr *rocksDBIterator) Close() error {
83-
panic("rocksdb must be built with -tags rocksdb")
84-
}
85-
86-
func (itr *rocksDBIterator) assertIsValid() {
87-
panic("rocksdb must be built with -tags rocksdb")
88-
}

0 commit comments

Comments
 (0)