-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use go-mask to mask sensitive information in zetaclient config file
- Loading branch information
1 parent
19cbeea
commit 1b23e96
Showing
6 changed files
with
41 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ import ( | |
"strings" | ||
"sync" | ||
|
||
"github.com/showa-93/go-mask" | ||
|
||
"github.com/zeta-chain/node/pkg/chains" | ||
) | ||
|
||
|
@@ -38,23 +40,23 @@ type ClientConfiguration struct { | |
// EVMConfig is the config for EVM chain | ||
type EVMConfig struct { | ||
Chain chains.Chain | ||
Endpoint string | ||
Endpoint string `mask:"filled"` | ||
RPCAlertLatency int64 | ||
} | ||
|
||
// BTCConfig is the config for Bitcoin chain | ||
type BTCConfig struct { | ||
// the following are rpcclient ConnConfig fields | ||
RPCUsername string | ||
RPCPassword string | ||
RPCHost string | ||
RPCUsername string `mask:"filled"` | ||
RPCPassword string `mask:"filled"` | ||
RPCHost string `mask:"filled"` | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ws4charlie
Author
Contributor
|
||
RPCParams string // "regtest", "mainnet", "testnet3" , "signet" | ||
RPCAlertLatency int64 | ||
} | ||
|
||
// SolanaConfig is the config for Solana chain | ||
type SolanaConfig struct { | ||
Endpoint string | ||
Endpoint string `mask:"filled"` | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ws4charlie
Author
Contributor
|
||
RPCAlertLatency int64 | ||
} | ||
|
||
|
@@ -147,9 +149,20 @@ func (c Config) GetSolanaConfig() (SolanaConfig, bool) { | |
return c.SolanaConfig, c.SolanaConfig != (SolanaConfig{}) | ||
} | ||
|
||
// String returns the string representation of the config | ||
func (c Config) String() string { | ||
s, err := json.MarshalIndent(c, "", "\t") | ||
// StringMasked returns the string representation of the config with sensitive fields masked. | ||
// Currently only the endpoints and bitcoin credentials are masked. | ||
func (c Config) StringMasked() string { | ||
// create a masker | ||
masker := mask.NewMasker() | ||
masker.RegisterMaskStringFunc(mask.MaskTypeFilled, masker.MaskFilledString) | ||
|
||
// mask the config | ||
masked, err := masker.Mask(c) | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
s, err := json.MarshalIndent(masked, "", "\t") | ||
if err != nil { | ||
return "" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Why do we need to mask the username and the host?