-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Feature: sui keystore #17618
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
base: ccip-aptos-codec
Are you sure you want to change the base?
Feature: sui keystore #17618
Conversation
I see you added a changeset file but it does not contain a tag. Please edit the text include at least one of the following tags:
|
ff72943
to
2515808
Compare
Flakeguard SummaryRan new or updated tests between View Flaky Detector Details | Compare Changes Found Flaky Tests ❌12 Results
ArtifactsFor detailed logs of the failed tests, please refer to the artifact failed-test-results-with-logs.json. |
2515808
to
48a5dfd
Compare
|
||
// newFrom creates a new Account from a provided random reader | ||
func newFrom(reader io.Reader) (Key, error) { | ||
pub, priv, err := ed25519.GenerateKey(reader) |
Check failure
Code scanning / CodeQL
Use of insufficient randomness as the key of a cryptographic algorithm High
random number
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
To address the issue, we need to ensure that cryptographic key generation always uses a cryptographically secure random number generator, even in testing scenarios. The MustNewInsecure
function should be modified to reject insecure random number generators or be clearly restricted to testing environments. Additionally, the keystest.NewRandReaderFromSeed
function should be updated to make its insecure nature explicit and prevent its accidental use in production.
- Modify
MustNewInsecure
to enforce the use of a secure random number generator or restrict its usage to testing environments by adding a build tag or runtime check. - Update
keystest.NewRandReaderFromSeed
to include a warning or runtime check to ensure it is only used in test builds. - Ensure that all cryptographic key generation paths use
crypto/rand.Reader
or an equivalent secure source of randomness.
-
Copy modified line R42 -
Copy modified lines R44-R46 -
Copy modified lines R53-R57
@@ -41,4 +41,7 @@ | ||
|
||
// MustNewInsecure returns an Account if no error | ||
// MustNewInsecure returns an Account if no error. This function is intended for testing only. | ||
func MustNewInsecure(reader io.Reader) Key { | ||
if !isTestEnvironment() { | ||
panic("MustNewInsecure is intended for testing only and cannot be used in production") | ||
} | ||
key, err := newFrom(reader) | ||
@@ -49,2 +52,7 @@ | ||
} | ||
|
||
// isTestEnvironment checks if the code is running in a test environment. | ||
func isTestEnvironment() bool { | ||
return os.Getenv("GO_ENV") == "test" | ||
} | ||
|
-
Copy modified lines R12-R14 -
Copy modified lines R17-R21
@@ -11,3 +11,11 @@ | ||
func NewRandReaderFromSeed(seed int64) io.Reader { | ||
if !isTestEnvironment() { | ||
panic("NewRandReaderFromSeed is intended for testing only and cannot be used in production") | ||
} | ||
return rand.New(rand.NewSource(seed)) | ||
} | ||
|
||
// isTestEnvironment checks if the code is running in a test environment. | ||
func isTestEnvironment() bool { | ||
return os.Getenv("GO_ENV") == "test" | ||
} |
|
Adds the Sui keystore to core
Requires