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

WIP:リファクタとAWSへの対応 #16

Draft
wants to merge 376 commits into
base: master
Choose a base branch
from
Draft

WIP:リファクタとAWSへの対応 #16

wants to merge 376 commits into from

Conversation

hijiki51
Copy link
Member

2021年度のPISCONで開発しているものです

  • mainのconohaとの結合をはがしています
  • まだかなり地獄の様相を呈しています
  • conohaとAWSを切り替えられるようにしたい

@hijiki51 hijiki51 marked this pull request as draft June 21, 2021 17:23
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

pass := ""
gen := "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
for i := 0; i < 12; i++ {
pass += string(gen[rand.Intn(len(gen))])

Check failure

Code scanning / CodeQL

Use of insufficient randomness as the key of a cryptographic algorithm High

A password-related function depends on a
random number
generated with a cryptographically weak RNG.

Copilot Autofix AI 20 days ago

To fix the problem, we need to replace the use of math/rand with crypto/rand to ensure that the password generation is cryptographically secure. This involves importing the crypto/rand package and using it to generate random indices for selecting characters from the character set. Specifically, we will replace the rand.Intn function with rand.Int from the crypto/rand package, which provides a cryptographically secure random number generator.

Suggested changeset 1
router/handlers.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/router/handlers.go b/router/handlers.go
--- a/router/handlers.go
+++ b/router/handlers.go
@@ -6,3 +6,4 @@
 	"log"
-	"math/rand"
+	"crypto/rand"
+	"math/big"
 	"net/http"
@@ -42,3 +43,7 @@
 	for i := 0; i < 12; i++ {
-		pass += string(gen[rand.Intn(len(gen))])
+		idx, err := rand.Int(rand.Reader, big.NewInt(int64(len(gen))))
+		if err != nil {
+			log.Fatal(err)
+		}
+		pass += string(gen[idx.Int64()])
 	}
EOF
@@ -6,3 +6,4 @@
"log"
"math/rand"
"crypto/rand"
"math/big"
"net/http"
@@ -42,3 +43,7 @@
for i := 0; i < 12; i++ {
pass += string(gen[rand.Intn(len(gen))])
idx, err := rand.Int(rand.Reader, big.NewInt(int64(len(gen))))
if err != nil {
log.Fatal(err)
}
pass += string(gen[idx.Int64()])
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants