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

Bug #30

Merged
merged 4 commits into from
Oct 1, 2024
Merged

Bug #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ public static boolean recordCurrentIP(Player player) {
Long exitTime = playerExitTimes.get(playerName);

try {
InetAddress localHost = InetAddress.getByName("localhost");
if (InetAddress.getByName(currentIP).equals(localHost)) {
if (InetAddress.getByName(currentIP).isLoopbackAddress()) {
return false;
}
} catch (UnknownHostException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

static {
try {
messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest = MessageDigest.getInstance("MD5");

Check failure

Code scanning / CodeQL

Use of a broken or risky cryptographic algorithm High

Cryptographic algorithm
MD5
is weak and should not be used.

Copilot Autofix AI about 2 months ago

To fix the problem, we should replace the use of the MD5 algorithm with a stronger, modern cryptographic algorithm. A good choice would be SHA-256, which is part of the SHA-2 family and is widely regarded as secure for most purposes.

  • Replace MessageDigest.getInstance("MD5") with MessageDigest.getInstance("SHA-256").
  • Ensure that the rest of the code remains unchanged to maintain existing functionality.
  • No additional imports are needed as MessageDigest already supports SHA-256.
Suggested changeset 1
src/main/java/cc/baka9/catseedlogin/util/CommunicationAuth.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/main/java/cc/baka9/catseedlogin/util/CommunicationAuth.java b/src/main/java/cc/baka9/catseedlogin/util/CommunicationAuth.java
--- a/src/main/java/cc/baka9/catseedlogin/util/CommunicationAuth.java
+++ b/src/main/java/cc/baka9/catseedlogin/util/CommunicationAuth.java
@@ -11,3 +11,3 @@
         try {
-            messageDigest = MessageDigest.getInstance("MD5");
+            messageDigest = MessageDigest.getInstance("SHA-256");
         } catch (NoSuchAlgorithmException e) {
EOF
@@ -11,3 +11,3 @@
try {
messageDigest = MessageDigest.getInstance("MD5");
messageDigest = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
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
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/cc/baka9/catseedlogin/util/Mail.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static void sendMail(String receiveMailAccount, String subject, String co
email.setAuthenticator(new DefaultAuthenticator(Config.EmailVerify.EmailAccount, Config.EmailVerify.EmailPassword));
if (Config.EmailVerify.SSLAuthVerify) {
email.setSSLOnConnect(true);
email.setSSLCheckServerIdentity(true);
} else {
email.setStartTLSEnabled(true);
}
Expand Down
Loading