chore(confix): audit (#16764)

This commit is contained in:
Julien Robert
2023-06-29 14:43:11 +00:00
committed by GitHub
parent ec27fbb84e
commit d1e81d2d69
6 changed files with 64 additions and 27 deletions
+38 -3
View File
@@ -59,8 +59,7 @@ inter-block-cache = true
# ["message.sender", "message.recipient"]
index-events = []
# IavlCacheSize set the size of the iavl tree cache.
# Default cache size is 50mb.
# IavlCacheSize set the size of the iavl tree cache (in number of nodes).
iavl-cache-size = 781250
# IAVLDisableFastNode enables or disables the fast node feature of IAVL.
@@ -141,6 +140,42 @@ rpc-max-body-bytes = 1000000
# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk).
enabled-unsafe-cors = false
###############################################################################
### Rosetta Configuration ###
###############################################################################
[rosetta]
# Enable defines if the Rosetta API server should be enabled.
enable = false
# Address defines the Rosetta API server to listen on.
address = ":8080"
# Network defines the name of the blockchain that will be returned by Rosetta.
blockchain = "app"
# Network defines the name of the network that will be returned by Rosetta.
network = "network"
# Retries defines the number of retries when connecting to the node before failing.
retries = 3
# Offline defines if Rosetta server should run in offline mode.
offline = false
# EnableDefaultSuggestedFee defines if the server should suggest fee by default.
# If 'construction/medata' is called without gas limit and gas price,
# suggested fee based on gas-to-suggest and denom-to-suggest will be given.
enable-fee-suggestion = false
# GasToSuggest defines gas limit when calculating the fee
gas-to-suggest = 200000
# DenomToSuggest defines the defult denom for fee suggestion.
# Price must be in minimum-gas-prices.
denom-to-suggest = "uatom"
###############################################################################
### gRPC Configuration ###
###############################################################################
@@ -233,4 +268,4 @@ max-txs = "5000"
query_gas_limit = 300000
# This is the number of wasm vm instances we keep cached in memory for speed-up
# Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
lru_size = 0
lru_size = 0
+5 -4
View File
@@ -10,9 +10,11 @@ import (
"github.com/creachadair/tomledit/transform"
)
type DiffType string
const (
Section = "S"
Mapping = "M"
Section DiffType = "S"
Mapping DiffType = "M"
)
type KV struct {
@@ -22,7 +24,7 @@ type KV struct {
}
type Diff struct {
Type string // "section" or "mapping"
Type DiffType
Deleted bool
KV KV
@@ -41,7 +43,6 @@ func DiffKeys(lhs, rhs *tomledit.Document) []Diff {
i, j := 0, 0
for i < len(lsec) && j < len(rsec) {
switch {
case lsec[i].Name.Before(rsec[j].Name):
diff = append(diff, Diff{Type: Section, Deleted: true, KV: KV{Key: lsec[i].Name.String()}})
for _, kv := range allKVs(lsec[i]) {
+19 -14
View File
@@ -51,12 +51,13 @@ func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
step = transform.Step{
Desc: fmt.Sprintf("add %s section", kv.Key),
T: transform.Func(func(_ context.Context, doc *tomledit.Document) error {
title := fmt.Sprintf("### %s Configuration ###", strings.Title(kv.Key))
doc.Sections = append(doc.Sections, &tomledit.Section{
Heading: &parser.Heading{
Block: parser.Comments{
"###############################################################################",
fmt.Sprintf("### %s Configuration ###", strings.Title(kv.Key)),
"###############################################################################",
strings.Repeat("#", len(title)),
title,
strings.Repeat("#", len(title)),
},
Name: keys,
},
@@ -77,9 +78,9 @@ func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
} else if len(keys) > 1 {
step = transform.Step{
Desc: fmt.Sprintf("add %s key", kv.Key),
T: transform.EnsureKey(parser.Key{keys[0]}, &parser.KeyValue{
T: transform.EnsureKey(keys[0:len(keys)-1], &parser.KeyValue{
Block: kv.Block,
Name: parser.Key{keys[1]},
Name: parser.Key{keys[len(keys)-1]},
Value: parser.MustValue(kv.Value),
}),
}
@@ -90,16 +91,20 @@ func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
} else {
if diff.Type == Section {
deletedSections[kv.Key] = true
}
step = transform.Step{
Desc: fmt.Sprintf("remove %s section", kv.Key),
T: transform.Remove(keys),
}
} else {
// when the whole section is deleted we don't need to remove the keys
if len(keys) > 1 && deletedSections[keys[0]] {
continue
}
// when the whole section is deleted we don't need to remove the keys
if len(keys) > 1 && deletedSections[keys[0]] {
continue
}
step = transform.Step{
Desc: fmt.Sprintf("remove %s key", kv.Key),
T: transform.Remove(keys),
step = transform.Step{
Desc: fmt.Sprintf("remove %s key", kv.Key),
T: transform.Remove(keys),
}
}
}
+1 -1
View File
@@ -83,7 +83,7 @@ func CheckValid(fileName string, data []byte) error {
}
if err := cfg.ValidateBasic(); err != nil {
return fmt.Errorf("server config invalid : %w", err)
return fmt.Errorf("server config invalid: %w", err)
}
case strings.HasSuffix(fileName, ClientConfig):
var cfg clientcfg.ClientConfig
-4
View File
@@ -18,10 +18,6 @@ func mustReadConfig(t *testing.T, path string) []byte {
return f
}
func TestUpgrade(t *testing.T) {
// TODO: add more test cases
}
func TestCheckValid(t *testing.T) {
err := confix.CheckValid("foo", []byte{})
assert.ErrorContains(t, err, "unknown config")