Attempt to fix security warnings

This commit is contained in:
Telesphoreo 2022-03-26 23:25:45 -05:00
parent c2447a2967
commit 83cbb45e49
3 changed files with 72 additions and 9 deletions

View File

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 26 Mar 2022 23:03:39 -0500
Subject: [PATCH] Add getCommit() method to Bukkit
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index c551010f84ac5d3ebc626c253a8f8282924152c4..80f19df4262958315d50df5104a8fea6d0b33094 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -108,6 +108,13 @@ public final class Bukkit {
// Paper end
}
+ // Scissors start - Allow getting git commit
+ public static String getCommit() {
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
+ return attributes.get("Git-Commit");
+ }
+ // Scissors end
+
/**
* Gets the name of this server implementation.
*

View File

@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 26 Mar 2022 23:23:25 -0500
Subject: [PATCH] Revert "Add getCommit() method to Bukkit"
This reverts commit 328e6237e80dce4ee1b3918f794615f253577981.
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 80f19df4262958315d50df5104a8fea6d0b33094..c551010f84ac5d3ebc626c253a8f8282924152c4 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -108,13 +108,6 @@ public final class Bukkit {
// Paper end
}
- // Scissors start - Allow getting git commit
- public static String getCommit() {
- Map<String, String> attributes = JarManifests.MANIFEST_MAP;
- return attributes.get("Git-Commit");
- }
- // Scissors end
-
/**
* Gets the name of this server implementation.
*

View File

@ -5,14 +5,19 @@ Subject: [PATCH] Change version fetcher to AMG
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
index ece77f5ea4b14bbed7c070131b3251ea86764538..eabe002dcd1aeacf04b694da2185770f20672d2b 100644
index ece77f5ea4b14bbed7c070131b3251ea86764538..a2897c410ace49d93ff4f7794e6f1472d60d1031 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -16,10 +16,11 @@ import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.stream.StreamSupport;
+import org.bukkit.Bukkit;
@@ -4,6 +4,8 @@ import com.destroystokyo.paper.util.VersionFetcher;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.google.gson.*;
+import io.papermc.paper.util.JarManifests;
+import java.util.Map;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -19,7 +21,7 @@ import java.util.stream.StreamSupport;
public class PaperVersionFetcher implements VersionFetcher {
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
@ -21,7 +26,7 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..eabe002dcd1aeacf04b694da2185770f
private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
private static @Nullable String mcVer;
@@ -31,8 +32,8 @@ public class PaperVersionFetcher implements VersionFetcher {
@@ -31,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher {
@Nonnull
@Override
public Component getVersionMessage(@Nonnull String serverVersion) {
@ -32,8 +37,17 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..eabe002dcd1aeacf04b694da2185770f
final Component history = getHistory();
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
@@ -56,13 +57,10 @@ public class PaperVersionFetcher implements VersionFetcher {
@@ -54,15 +56,19 @@ public class PaperVersionFetcher implements VersionFetcher {
return mcVer;
}
+ // Scissors start - Allow getting git commit
+ public static String getCommit() {
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
+ return attributes.get("Git-Commit");
+ }
+ // Scissors end
+
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
int distance;
- try {
@ -44,7 +58,7 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..eabe002dcd1aeacf04b694da2185770f
- distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
- }
+ // Scissors start - always use Git for version checking
+ versionInfo = Bukkit.getCommit();
+ versionInfo = getCommit();
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
+ // Scissors end