|
|
1e67f5 |
commit 09bcd3ebb639af6cfd83ff2203ffeb80a59cc0eb
|
|
|
1e67f5 |
Author: Jiri Vanek <jvanek@redhat.com>
|
|
|
1e67f5 |
Date: Fri Jun 28 16:05:35 2019 +0200
|
|
|
1e67f5 |
|
|
|
1e67f5 |
All files, except signaturre files, are now checked for signatures
|
|
|
1e67f5 |
|
|
|
1e67f5 |
diff --git a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
|
|
|
1e67f5 |
index 759bedfb..cabfb3c5 100644
|
|
|
1e67f5 |
--- a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
|
|
|
1e67f5 |
+++ b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
|
|
|
1e67f5 |
@@ -41,6 +41,7 @@
|
|
|
1e67f5 |
import java.util.Map;
|
|
|
1e67f5 |
import java.util.Vector;
|
|
|
1e67f5 |
import java.util.jar.JarEntry;
|
|
|
1e67f5 |
+import java.util.regex.Pattern;
|
|
|
1e67f5 |
|
|
|
1e67f5 |
import net.sourceforge.jnlp.JARDesc;
|
|
|
1e67f5 |
import net.sourceforge.jnlp.JNLPFile;
|
|
|
1e67f5 |
@@ -67,6 +68,7 @@
|
|
|
1e67f5 |
public class JarCertVerifier implements CertVerifier {
|
|
|
1e67f5 |
|
|
|
1e67f5 |
private static final String META_INF = "META-INF/";
|
|
|
1e67f5 |
+ private static final Pattern SIG = Pattern.compile(".*" + META_INF + "SIG-.*");
|
|
|
1e67f5 |
|
|
|
1e67f5 |
// prefix for new signature-related files in META-INF directory
|
|
|
1e67f5 |
private static final String SIG_PREFIX = META_INF + "SIG-";
|
|
|
1e67f5 |
@@ -500,12 +502,20 @@
|
|
|
1e67f5 |
|
|
|
1e67f5 |
/**
|
|
|
1e67f5 |
* Returns whether a file is in META-INF, and thus does not require signing.
|
|
|
1e67f5 |
- *
|
|
|
1e67f5 |
+ *
|
|
|
1e67f5 |
* Signature-related files under META-INF include: . META-INF/MANIFEST.MF . META-INF/SIG-* . META-INF/*.SF . META-INF/*.DSA . META-INF/*.RSA
|
|
|
1e67f5 |
*/
|
|
|
1e67f5 |
static boolean isMetaInfFile(String name) {
|
|
|
1e67f5 |
- String ucName = name.toUpperCase();
|
|
|
1e67f5 |
- return ucName.startsWith(META_INF);
|
|
|
1e67f5 |
+ if (name.endsWith("class")) {
|
|
|
1e67f5 |
+ return false;
|
|
|
1e67f5 |
+ }
|
|
|
1e67f5 |
+ return name.startsWith(META_INF) && (
|
|
|
1e67f5 |
+ name.endsWith(".MF") ||
|
|
|
1e67f5 |
+ name.endsWith(".SF") ||
|
|
|
1e67f5 |
+ name.endsWith(".DSA") ||
|
|
|
1e67f5 |
+ name.endsWith(".RSA") ||
|
|
|
1e67f5 |
+ SIG.matcher(name).matches()
|
|
|
1e67f5 |
+ );
|
|
|
1e67f5 |
}
|
|
|
1e67f5 |
|
|
|
1e67f5 |
/**
|
|
|
1e67f5 |
diff --git a/tests/netx/unit/net/sourceforge/jnlp/tools/JarCertVerifierTest.java b/tests/netx/unit/net/sourceforge/jnlp/tools/JarCertVerifierTest.java
|
|
|
1e67f5 |
index 4661fb87..44253e08 100644
|
|
|
1e67f5 |
--- a/tests/netx/unit/net/sourceforge/jnlp/tools/JarCertVerifierTest.java
|
|
|
1e67f5 |
+++ b/tests/netx/unit/net/sourceforge/jnlp/tools/JarCertVerifierTest.java
|
|
|
1e67f5 |
@@ -58,9 +58,22 @@ public class JarCertVerifierTest {
|
|
|
1e67f5 |
@Test
|
|
|
1e67f5 |
public void testIsMetaInfFile() {
|
|
|
1e67f5 |
final String METAINF = "META-INF";
|
|
|
1e67f5 |
+ assertTrue(JarCertVerifier.isMetaInfFile(METAINF + "/file.MF"));
|
|
|
1e67f5 |
+ assertTrue(JarCertVerifier.isMetaInfFile(METAINF + "/file.SF"));
|
|
|
1e67f5 |
+ assertTrue(JarCertVerifier.isMetaInfFile(METAINF + "/file.DSA"));
|
|
|
1e67f5 |
+ assertTrue(JarCertVerifier.isMetaInfFile(METAINF + "/file.RSA"));
|
|
|
1e67f5 |
+ assertTrue(JarCertVerifier.isMetaInfFile(METAINF + "/SIG-blah.blah"));
|
|
|
1e67f5 |
+
|
|
|
1e67f5 |
+ assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "/file.MF.class"));
|
|
|
1e67f5 |
+ assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "/file.SF.class"));
|
|
|
1e67f5 |
+ assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "/file.DSA.class"));
|
|
|
1e67f5 |
+ assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "/file.RSA.class"));
|
|
|
1e67f5 |
+ assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "/SIG-blah.blah.class"));
|
|
|
1e67f5 |
+
|
|
|
1e67f5 |
assertFalse(JarCertVerifier.isMetaInfFile("some_dir/" + METAINF + "/filename"));
|
|
|
1e67f5 |
assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "filename"));
|
|
|
1e67f5 |
- assertTrue(JarCertVerifier.isMetaInfFile(METAINF + "/filename"));
|
|
|
1e67f5 |
+ assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "/filename"));
|
|
|
1e67f5 |
+ assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "/filename"));
|
|
|
1e67f5 |
}
|
|
|
1e67f5 |
|
|
|
1e67f5 |
class JarCertVerifierEntry extends JarEntry {
|