diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bdfcf1d1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM maven:3.8.6-eclipse-temurin-11-alpine + +# if work dir changed, the RUN sed line needs changes also +WORKDIR /root + +# add needing packages +RUN apk add --no-cache git sed patch graphviz + +RUN mkdir -p -m 700 artifact/ +RUN mkdir -p -m 700 git/ + +# copy java-callgraph and repos +COPY git/java-callgraph artifact/ +COPY git/mph-table/ git/mph-table/ + +# custom prompt +RUN echo PS1=\"[\\u@artifact-java-callgraph \\W]\\$ \" > .bashrc + +# alter artifact files to point git locally instead +RUN sed -i 's/https:\/\/github.com\/indeedeng\/mph-table.git/\/root\/git\/mph-table/g' "artifact/artifacts/configs/mph-table/mph-table.yaml" + + +ENTRYPOINT ["/bin/bash"] diff --git a/artifacts/configs/jflex-fixed/jflex-fixed.patch b/artifacts/configs/jflex-fixed/jflex-fixed.patch index 91e11ac4..9355b6d6 100644 --- a/artifacts/configs/jflex-fixed/jflex-fixed.patch +++ b/artifacts/configs/jflex-fixed/jflex-fixed.patch @@ -94,48 +94,31 @@ index 109146e2..4af8ce29 100644 "//third_party/com/google/truth", "//third_party/com/pholser/quickcheck", diff --git a/jflex/src/test/java/jflex/core/unicode/CharClassesQuickcheck.java b/jflex/src/test/java/jflex/core/unicode/CharClassesQuickcheck.java -index 876f0387..22be04d6 100644 +index 876f0387..5c80c0dc 100644 --- a/jflex/src/test/java/jflex/core/unicode/CharClassesQuickcheck.java +++ b/jflex/src/test/java/jflex/core/unicode/CharClassesQuickcheck.java @@ -12,6 +12,7 @@ package jflex.core.unicode; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assume.assumeTrue; - + +import com.pholser.junit.quickcheck.From; import com.pholser.junit.quickcheck.Property; import com.pholser.junit.quickcheck.generator.InRange; import com.pholser.junit.quickcheck.generator.Size; -@@ -31,6 +32,7 @@ import org.junit.runner.RunWith; - */ - @RunWith(JUnitQuickcheck.class) - public class CharClassesQuickcheck { -+ UnicodeProperties unicodeProperties; - - // TODO(lsf): add testing for caseless; needs UnicodeProperties - -@@ -48,17 +50,24 @@ public class CharClassesQuickcheck { +@@ -47,9 +48,7 @@ public class CharClassesQuickcheck { + @Property public void addSingle( - CharClasses classes, +- CharClasses classes, - @InRange(minInt = 0, maxInt = CharClasses.maxChar) int c1, - @InRange(minInt = 0, maxInt = CharClasses.maxChar) int c2) { -+ @From(IntCharGen.class) int c1, -+ @From(IntCharGen.class) int c2, -+ boolean caseless) -+ throws UnicodeProperties.UnsupportedUnicodeVersionException { -+ ++ CharClasses classes, @From(IntCharGen.class) int c1, @From(IntCharGen.class) int c2) { assumeTrue(c1 != c2); -- classes.makeClass(c1, false); -+ -+ if (caseless) { -+ classesInit(classes); -+ } -+ -+ classes.makeClass(c1, caseless); + classes.makeClass(c1, false); assertThat(classes.invariants()).isTrue(); - assertThat(classes.getClassCode(c1)).isNotEqualTo(classes.getClassCode(c2)); +@@ -57,8 +56,7 @@ public class CharClassesQuickcheck { } - + @Property - public void addSingleSingleton( - CharClasses classes, @InRange(minInt = 0, maxInt = CharClasses.maxChar) int c) { @@ -143,100 +126,25 @@ index 876f0387..22be04d6 100644 classes.makeClass(c, false); IntCharSet set = classes.getCharClass(classes.getClassCode(c)); assertThat(set).isEqualTo(IntCharSet.ofCharacter(c)); -@@ -68,11 +77,17 @@ public class CharClassesQuickcheck { +@@ -68,7 +66,7 @@ public class CharClassesQuickcheck { public void addSet( CharClasses classes, @InRange(maxInt = CharClasses.maxChar) IntCharSet set, - @InRange(minInt = 0, maxInt = CharClasses.maxChar) int c) { -+ @From(IntCharGen.class) int c, -+ boolean caseless) -+ throws UnicodeProperties.UnsupportedUnicodeVersionException { - ++ @From(IntCharGen.class) int c) { + assumeTrue(!set.contains(c)); - -- classes.makeClass(set, false); -+ if (caseless) { -+ classesInit(classes); -+ } -+ -+ classes.makeClass(set, caseless); - assertThat(classes.invariants()).isTrue(); - - int[] classCodes = classes.getClassCodes(set, false); -@@ -84,9 +99,15 @@ public class CharClassesQuickcheck { - - @Property - public void addSetParts( -- CharClasses classes, @InRange(maxInt = CharClasses.maxChar) IntCharSet set) { -+ CharClasses classes, @InRange(maxInt = CharClasses.maxChar) IntCharSet set, boolean caseless) -+ throws UnicodeProperties.UnsupportedUnicodeVersionException { - -- classes.makeClass(set, false); -+ if (caseless) { -+ classesInit(classes); -+ set = set.getCaseless(unicodeProperties); -+ } -+ -+ classes.makeClass(set, caseless); - - int[] classCodes = classes.getClassCodes(set, false); - IntCharSet allParts = new IntCharSet(); -@@ -98,9 +119,15 @@ public class CharClassesQuickcheck { - - @Property - public void addSetComplement( -- CharClasses classes, @InRange(maxInt = CharClasses.maxChar) IntCharSet set) { -+ CharClasses classes, @InRange(maxInt = CharClasses.maxChar) IntCharSet set, boolean caseless) -+ throws UnicodeProperties.UnsupportedUnicodeVersionException { -+ -+ if (caseless) { -+ classesInit(classes); -+ set = set.getCaseless(unicodeProperties); -+ } - -- classes.makeClass(set, false); -+ classes.makeClass(set, caseless); - - int[] notCodes = classes.getClassCodes(set, true); - IntCharSet others = new IntCharSet(); -@@ -112,11 +139,16 @@ public class CharClassesQuickcheck { - + +@@ -111,8 +109,7 @@ public class CharClassesQuickcheck { + } + @Property - public void addString( +- public void addString( - CharClasses classes, String s, @InRange(minInt = 0, maxInt = CharClasses.maxChar) int c) { -+ CharClasses classes, String s, @From(IntCharGen.class) int c, boolean caseless) -+ throws UnicodeProperties.UnsupportedUnicodeVersionException { - ++ public void addString(CharClasses classes, String s, @From(IntCharGen.class) int c) { + assumeTrue(s.indexOf(c) < 0); - -- classes.makeClass(s, false); -+ if (caseless) { -+ classesInit(classes); -+ } -+ -+ classes.makeClass(s, caseless); - assertThat(classes.invariants()).isTrue(); - - int cCode = classes.getClassCode(c); -@@ -203,4 +235,18 @@ public class CharClassesQuickcheck { - assertThat(intervals[i].end + 1).isEqualTo(intervals[i + 1].start); - } - } -+ -+ private void classesInit(CharClasses classes) -+ throws UnicodeProperties.UnsupportedUnicodeVersionException { -+ // init classes -+ unicodeProperties = new UnicodeProperties(); -+ classes.init( -+ CharClasses.maxChar, -+ new ILexScan() { -+ @Override -+ public UnicodeProperties getUnicodeProperties() { -+ return unicodeProperties; -+ } -+ }); -+ } - } + diff --git a/jflex/src/test/java/jflex/core/unicode/IntCharGen.java b/jflex/src/test/java/jflex/core/unicode/IntCharGen.java new file mode 100644 index 00000000..45e47ee8 @@ -299,13 +207,13 @@ index 7ff19e45..9d80976a 100644 import com.pholser.junit.quickcheck.random.SourceOfRandomness; import jflex.chars.IntervalGen; +import jflex.logging.Out; - + /** * Generator for random {@link IntCharSet} instances. @@ -48,6 +49,15 @@ public class IntCharSetGen extends Generator { result.add(intervals.generate(r, status)); } - + + // randomly add possible additional cased character + if (numIntervals < maxSize && r.nextBoolean()) { + try { @@ -317,7 +225,7 @@ index 7ff19e45..9d80976a 100644 + return result; } - + diff --git a/jflex/src/test/java/jflex/state/BUILD.bazel b/jflex/src/test/java/jflex/state/BUILD.bazel index 936249c8..7481ca43 100644 --- a/jflex/src/test/java/jflex/state/BUILD.bazel @@ -388,7 +296,7 @@ index e9962397..1f4d2443 100644 @@ -50,6 +50,11 @@ public class StateSetGen extends Generator { result.addState(r.nextInt(minRange, maxRange)); } - + + // add large value 20% of the time + if (r.nextInt(1, 5) == 5) { + result.addState(r.nextInt(minRange + 100_000, maxRange + 100_000)); @@ -396,19 +304,19 @@ index e9962397..1f4d2443 100644 + return result; } - + diff --git a/jflex/src/test/java/jflex/state/StateSetQuickcheck.java b/jflex/src/test/java/jflex/state/StateSetQuickcheck.java index 2537700d..0ac0e12c 100644 --- a/jflex/src/test/java/jflex/state/StateSetQuickcheck.java +++ b/jflex/src/test/java/jflex/state/StateSetQuickcheck.java @@ -11,9 +11,13 @@ package jflex.state; - + import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; - + +import com.pholser.junit.quickcheck.From; import com.pholser.junit.quickcheck.Property; +import com.pholser.junit.quickcheck.generator.Also; @@ -441,11 +349,11 @@ index 2537700d..0ac0e12c 100644 + s.remove(largerState); + assertThat(s).isEqualTo(sPre); } - + @Property @@ -181,10 +197,27 @@ public class StateSetQuickcheck { } - + @Property - public void addStateDoesNotRemove(StateSet set, @InRange(minInt = 0, maxInt = 34) int e) { + public void addStateDoesNotRemove( @@ -470,7 +378,7 @@ index 2537700d..0ac0e12c 100644 + assertThat(set.hasElement(newValue)).isTrue(); + assertThat(setPre.contains(set)).isFalse(); } - + @Property @@ -208,6 +241,12 @@ public class StateSetQuickcheck { StateSet comp = s1.complement(s2); @@ -483,7 +391,7 @@ index 2537700d..0ac0e12c 100644 + assertThat(comp.contains(s1)).isFalse(); + } } - + @Property @@ -228,6 +267,13 @@ public class StateSetQuickcheck { public void containsElements(StateSet s, @InRange(minInt = 0, maxInt = 34) int e) { @@ -497,5 +405,5 @@ index 2537700d..0ac0e12c 100644 + } + assertThat(s.containsElements()).isFalse(); } - - @Property \ No newline at end of file + + @Property diff --git a/artifacts/configs/jflex-fixed/jflex-fixed.yaml b/artifacts/configs/jflex-fixed/jflex-fixed.yaml index 0abdafb0..b6d52a00 100644 --- a/artifacts/configs/jflex-fixed/jflex-fixed.yaml +++ b/artifacts/configs/jflex-fixed/jflex-fixed.yaml @@ -75,15 +75,15 @@ properties: - name: CharClassesQuickcheck#maxCharCode entryPoint: "jflex.core.unicode.CharClassesQuickcheck.maxCharCode(Ljflex/core/unicode/CharClasses;)V" - name: CharClassesQuickcheck#addSingle - entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSingle(Ljflex/core/unicode/CharClasses;IIZ)V" + entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSingle(Ljflex/core/unicode/CharClasses;II)V" - name: CharClassesQuickcheck#addSingleSingleton entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSingleSingleton(Ljflex/core/unicode/CharClasses;I)V" - name: CharClassesQuickcheck#addSet - entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSet(Ljflex/core/unicode/CharClasses;Ljflex/core/unicode/IntCharSet;IZ)V" + entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSet(Ljflex/core/unicode/CharClasses;Ljflex/core/unicode/IntCharSet;I)V" - name: CharClassesQuickcheck#addSetParts - entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSetParts(Ljflex/core/unicode/CharClasses;Ljflex/core/unicode/IntCharSet;Z)V" + entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSetParts(Ljflex/core/unicode/CharClasses;Ljflex/core/unicode/IntCharSet;)V" - name: CharClassesQuickcheck#addSetComplement - entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSetComplement(Ljflex/core/unicode/CharClasses;Ljflex/core/unicode/IntCharSet;Z)V" + entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addSetComplement(Ljflex/core/unicode/CharClasses;Ljflex/core/unicode/IntCharSet;)V" - name: CharClassesQuickcheck#addString entryPoint: "jflex.core.unicode.CharClassesQuickcheck.addString(Ljflex/core/unicode/CharClasses;Ljava/lang/String;IZ)V" - name: CharClassesQuickcheck#normaliseSingle diff --git a/artifacts/configs/rpki-commons-fixed/rpki-commons-fixed.patch b/artifacts/configs/rpki-commons-fixed/rpki-commons-fixed.patch new file mode 100644 index 00000000..267b1952 --- /dev/null +++ b/artifacts/configs/rpki-commons-fixed/rpki-commons-fixed.patch @@ -0,0 +1,382 @@ +diff --git a/pom.xml b/pom.xml +index 08ebb666..0157a994 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -373,6 +373,58 @@ + true + + ++ ++ ++ org.jacoco ++ jacoco-maven-plugin ++ 0.8.6 ++ ++ ++ default-prepare-agent ++ ++ prepare-agent ++ ++ ++ ++ jacoco-report ++ test ++ ++ report ++ ++ ++ ++ ++ ++ org.apache.maven.plugins ++ maven-jar-plugin ++ 3.2.0 ++ ++ ++ ++ test-jar ++ ++ ++ ++ ++ ++ org.apache.maven.plugins ++ maven-assembly-plugin ++ 3.3.0 ++ ++ ++ jar-with-dependencies ++ ++ ++ ++ ++ make-assembly ++ package ++ ++ single ++ ++ ++ ++ + + + +@@ -457,4 +509,20 @@ + + + ++ ++ ++ ++ ++ org.jacoco ++ jacoco-maven-plugin ++ ++ ++ ++ report ++ ++ ++ ++ ++ ++ + +diff --git a/src/test/java/net/ripe/rpki/commons/validation/X509ResourceCertificateParentChildValidatorTest.java b/src/test/java/net/ripe/rpki/commons/validation/X509ResourceCertificateParentChildValidatorTest.java +index cb8b7dd9..18f3d25a 100644 +--- a/src/test/java/net/ripe/rpki/commons/validation/X509ResourceCertificateParentChildValidatorTest.java ++++ b/src/test/java/net/ripe/rpki/commons/validation/X509ResourceCertificateParentChildValidatorTest.java +@@ -2,6 +2,9 @@ package net.ripe.rpki.commons.validation; + + import com.pholser.junit.quickcheck.From; + import com.pholser.junit.quickcheck.Property; ++import com.pholser.junit.quickcheck.generator.Also; ++import com.pholser.junit.quickcheck.generator.NullAllowed; ++import com.pholser.junit.quickcheck.generator.Size; + import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; + import net.ripe.ipresource.IpResource; + import net.ripe.ipresource.IpResourceSet; +@@ -18,6 +21,7 @@ import net.ripe.rpki.commons.validation.objectvalidators.X509ResourceCertificate + import net.ripe.rpki.commons.validation.objectvalidators.X509ResourceCertificateParentChildValidator; + import net.ripe.rpki.commons.validation.objectvalidators.X509ResourceCertificateValidator; + import net.ripe.rpki.commons.validation.properties.IpResourceGen; ++import net.ripe.rpki.commons.validation.properties.URIGen; + import org.bouncycastle.asn1.x509.KeyUsage; + import org.joda.time.DateTime; + import org.junit.Before; +@@ -27,9 +31,12 @@ import org.junit.runner.RunWith; + import javax.security.auth.x500.X500Principal; + import java.math.BigInteger; + import java.net.URI; ++import java.net.URISyntaxException; + import java.security.KeyPair; + import java.util.EnumSet; + import java.util.List; ++import java.util.Objects; ++import java.util.stream.Collectors; + + import static net.ripe.rpki.commons.crypto.x509cert.X509CertificateBuilderHelper.DEFAULT_SIGNATURE_PROVIDER; + import static org.hamcrest.Matchers.greaterThan; +@@ -223,7 +230,7 @@ public class X509ResourceCertificateParentChildValidatorTest { + } + + @Property +- public void validParentChildSubResources(List<@From(IpResourceGen.class) IpResource> parentResources, int childResourceCount) { ++ public void validParentChildSubResources(List<@From(IpResourceGen.class) IpResource> parentResources, int childResourceCount, @Size(min=0, max=1000) List<@From(URIGen.class) URI> crlUris) throws URISyntaxException { + assumeThat(parentResources.size(), greaterThan(0)); + assumeThat(childResourceCount, greaterThan(0)); + +@@ -236,7 +243,7 @@ public class X509ResourceCertificateParentChildValidatorTest { + return; + } + +- ValidationResult result = validateParentChildPair(parentResourceSet, childResourceSet); ++ ValidationResult result = validateParentChildPair(parentResourceSet, childResourceSet, crlUris); + assertFalse(result.hasFailures()); + } + +@@ -305,10 +312,30 @@ public class X509ResourceCertificateParentChildValidatorTest { + return validateParentChildPairImpl(parentResourceSet, childResourceSet, false); + } + ++ private ValidationResult validateParentChildPair(IpResourceSet parentResourceSet, IpResourceSet childResourceSet, List crlUris) { ++ return validateParentChildPairImpl(parentResourceSet, childResourceSet, false, crlUris); ++ } ++ + private ValidationResult validateParentChildPairImpl(IpResourceSet parentResourceSet, IpResourceSet childResourceSet, boolean reconsidered) { +- final X509ResourceCertificate parentCertificate = createRootCertificateBuilder() +- .withResources(parentResourceSet) +- .build(); ++ return validateParentChildPairImpl(parentResourceSet, childResourceSet, reconsidered, null); ++ } ++ ++ private ValidationResult validateParentChildPairImpl(IpResourceSet parentResourceSet, IpResourceSet childResourceSet, boolean reconsidered, List crlUris) { ++ final X509ResourceCertificate parentCertificate; ++ ++ if (crlUris == null) { ++ parentCertificate = createRootCertificateBuilder() ++ .withResources(parentResourceSet) ++ .build(); ++ } else { ++ URI[] arrayUris = new URI[crlUris.size()]; ++ arrayUris = crlUris.toArray(arrayUris); ++ ++ parentCertificate = createRootCertificateBuilder() ++ .withResources(parentResourceSet) ++ .withCrlDistributionPoints(arrayUris) ++ .build(); ++ } + + final X509ResourceCertificate childCertificate = createChildCertificateBuilder() + .withResources(childResourceSet) +diff --git a/src/test/java/net/ripe/rpki/commons/validation/properties/URIGen.java b/src/test/java/net/ripe/rpki/commons/validation/properties/URIGen.java +new file mode 100644 +index 00000000..7e43902c +--- /dev/null ++++ b/src/test/java/net/ripe/rpki/commons/validation/properties/URIGen.java +@@ -0,0 +1,172 @@ ++package net.ripe.rpki.commons.validation.properties; ++ ++import com.pholser.junit.quickcheck.generator.GenerationStatus; ++import com.pholser.junit.quickcheck.generator.Generator; ++import com.pholser.junit.quickcheck.random.SourceOfRandomness; ++import java.net.URI; ++ ++public class URIGen extends Generator { ++ public final int HIER_AUTHORITY_PATH = 0; ++ public final int HIER_PATH_ABSOLUTE = 1; ++ public final int HIER_PATH_ROOTLESS = 2; ++ public final int HIER_PATH_EMPTY = 3; ++ ++ public final int HOST_REG_NAME = 0; ++ public final int HOST_IPV4 = 1; ++ public final int HOST_IPV6 = 2; ++ ++ private final String UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; ++ private final String LOWERCASE = "abcdefghijklmnopqrstuvwxyz"; ++ private final String NUMERIC = "0123456789"; ++ ++ private SourceOfRandomness r; ++ ++ public URIGen() { ++ super(URI.class); ++ } ++ ++ @Override ++ public URI generate(SourceOfRandomness r, GenerationStatus generationStatus) { ++ this.r = r; ++ ++ try { ++ return buildURI(); ++ } catch (Exception exception) { ++ // bad uri, interesting but ok or invalid options for uri generation ++ System.err.println(exception.getMessage()); ++ exception.printStackTrace(); ++ } ++ ++ return null; ++ } ++ ++ private URI buildURI() throws Exception { ++ String uri = hierPart(scheme()) + query() + fragment(); ++ return new URI(uri); ++ } ++ ++ private String hierPart(String scheme) throws Exception { ++ switch (r.nextInt(0, 3)) { ++ case HIER_AUTHORITY_PATH: return scheme + authority() + path(); ++ case HIER_PATH_ABSOLUTE: return scheme + path(); ++ case HIER_PATH_ROOTLESS: return scheme + path(""); ++ case HIER_PATH_EMPTY: return ""; ++ default: throw new Exception("Invalid option for hierPart"); ++ } ++ } ++ ++ private String scheme() { ++ String[] commonScheme = { "http", "https", "ftp", "ftps", "mailto", "file", "data", "irc", "blob", "sftp" }; ++ int pickScheme = r.nextInt(0, commonScheme.length); ++ ++ if (pickScheme == commonScheme.length) { ++ String SCHEME = UPPERCASE + LOWERCASE + NUMERIC + "+.-"; ++ return randomString(1, 1, UPPERCASE + LOWERCASE, false) ++ + randomString(2, 100, SCHEME, false) + ":"; ++ } ++ ++ return commonScheme[pickScheme] + ":"; ++ } ++ ++ private String authority() throws Exception { ++ return "//" + userinfo() + host() + port(); ++ } ++ ++ private String userinfo() { ++ if (r.nextBoolean()) { ++ return ""; ++ } ++ ++ return randomString(1, 100) + ":" + randomString(0, 100) + "@"; ++ } ++ ++ private String host() throws Exception { ++ switch (r.nextInt(0,2)) { ++ case HOST_REG_NAME: return regName(); ++ case HOST_IPV4: return ip4(); ++ case HOST_IPV6: return ipv6(); ++ default: throw new Exception("Invalid option for host"); ++ } ++ } ++ ++ private String regName() { ++ String REG = UPPERCASE + LOWERCASE + NUMERIC + ".-"; ++ return randomString(1, 255, REG); ++ } ++ ++ private String ip4() { ++ return r.nextInt(0,255) + "." + r.nextInt(0,255) + "." + r.nextInt(0,255) + "." + r.nextInt(0,255); ++ } ++ ++ private String ipv6() { ++ return String.format("%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X", ++ r.nextInt(0, 65535), r.nextInt(0, 65535), r.nextInt(0, 65535), r.nextInt(0, 65535), ++ r.nextInt(0, 65535), r.nextInt(0, 65535), r.nextInt(0, 65535), r.nextInt(0, 65535)); ++ } ++ ++ private String port() { ++ if (r.nextBoolean()) { ++ return ""; ++ } ++ ++ return ":" + r.nextInt(0, 65535); ++ } ++ ++ private String path() { ++ return path("/"); ++ } ++ ++ private String path(String append) { ++ String PATH = LOWERCASE + UPPERCASE + NUMERIC + ".+;="; ++ return append + ++ randomString(1, 1, PATH) + ++ randomString(1, 255, PATH + "/"); ++ } ++ ++ private String query() { ++ if (r.nextBoolean()) { ++ return ""; ++ } ++ ++ String QUERY = LOWERCASE + UPPERCASE + NUMERIC + "/?="; ++ return "?" + randomString(1, 255, QUERY); ++ } ++ ++ private String fragment() { ++ if (r.nextBoolean()) { ++ return ""; ++ } ++ ++ String FRAGMENT = LOWERCASE + UPPERCASE + NUMERIC + "/?="; ++ return "#" + randomString(1, 255, FRAGMENT); ++ } ++ ++ private String randomString(int minLength, int maxLength) { ++ return randomString(minLength, maxLength, LOWERCASE + UPPERCASE + NUMERIC); ++ } ++ ++ private String randomString(int minLength, int maxLength, String possibleCharacters) { ++ return randomString(minLength, maxLength, possibleCharacters, true); ++ } ++ ++ private String randomString(int minLength, int maxLength, String possibleCharacters, boolean genEncodedChars) { ++ String HEX_DIGIT = "0123456789ABCDEF"; ++ StringBuilder sb = new StringBuilder(); ++ int len = r.nextInt(minLength, maxLength); ++ ++ for (int i = 0; i < len; i++) { ++ if (genEncodedChars) { ++ int charIdx = r.nextInt(0, possibleCharacters.length()); ++ if (charIdx == possibleCharacters.length()) { ++ sb.append("%").append(randomString(2, 2, HEX_DIGIT, false)); ++ } else { ++ sb.append(possibleCharacters.charAt(charIdx)); ++ } ++ } else { ++ sb.append(possibleCharacters.charAt(r.nextInt(0, possibleCharacters.length() - 1))); ++ } ++ } ++ ++ return sb.toString(); ++ } ++} +diff --git a/src/test/java/net/ripe/rpki/commons/validation/properties/URIGenTest.java b/src/test/java/net/ripe/rpki/commons/validation/properties/URIGenTest.java +new file mode 100644 +index 00000000..e9a88133 +--- /dev/null ++++ b/src/test/java/net/ripe/rpki/commons/validation/properties/URIGenTest.java +@@ -0,0 +1,26 @@ ++package net.ripe.rpki.commons.validation.properties; ++ ++import com.pholser.junit.quickcheck.generator.GenerationStatus; ++import com.pholser.junit.quickcheck.internal.generator.SimpleGenerationStatus; ++import com.pholser.junit.quickcheck.random.SourceOfRandomness; ++import org.junit.jupiter.api.Test; ++ ++import java.net.URI; ++import java.util.Random; ++ ++import static org.junit.jupiter.api.Assertions.*; ++ ++class URIGenTest { ++ ++ @Test ++ void generateTest() { ++ URIGen uriGen = new URIGen(); ++ Random random = new Random(); ++ SourceOfRandomness r = new SourceOfRandomness(random); ++ ++ for (int i = 0; i < 100_000; i++) { ++ URI uri = uriGen.generate(r, null); ++ assertNotNull(uri); ++ } ++ } ++} +\ No newline at end of file diff --git a/artifacts/configs/rpki-commons-fixed/rpki-commons-fixed.yaml b/artifacts/configs/rpki-commons-fixed/rpki-commons-fixed.yaml new file mode 100644 index 00000000..8e42e232 --- /dev/null +++ b/artifacts/configs/rpki-commons-fixed/rpki-commons-fixed.yaml @@ -0,0 +1,21 @@ +name: rpki-commons-fixed +URL: https://github.com/RIPE-NCC/rpki-commons.git +checkoutID: dd5af7c644d2cd9cc6b0b5f4f2480b6dfc1ef074 +patchName: artifacts/configs/rpki-commons-fixed/rpki-commons-fixed.patch +mainJar: rpki-commons-DEV.jar +testJar: rpki-commons-DEV-tests.jar +#mvnOptions: -DfailIfNoTests=false +#mvnOptions: -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" +properties: +# - name: RoaCMSBuilderPropertyTest#buildEncodedParseCheck +# entryPoint: net.ripe.rpki.commons.crypto.cms.roa.RoaCMSBuilderPropertyTest.buildEncodedParseCheck(JLjava/lang/Integer;)V +# - name: ManifestCMSBuilderPropertyTest#buildEncodedParseCheck +# entryPoint: net.ripe.rpki.commons.crypto.cms.manifest.ManifestCMSBuilderPropertyTest.buildEncodedParseCheck([BLjava/math/BigInteger;Ljava/lang/Integer;)V +# - name: AspaCmsTest#should_generate_aspa +# entryPoint: net.ripe.rpki.commons.crypto.cms.aspa.AspaCmsTest.should_generate_aspa(ILjava/util/List;)V + - name: X509ResourceCertificateParentChildValidatorTest#validParentChildSubResources + entryPoint: net.ripe.rpki.commons.validation.X509ResourceCertificateParentChildValidatorTest.validParentChildSubResources(Ljava/util/List;ILjava/util/List;)V +# - name: X509ResourceCertificateParentChildValidatorTest#validParentChildOverClaiming +# entryPoint: net.ripe.rpki.commons.validation.X509ResourceCertificateParentChildValidatorTest.validParentChildOverClaiming(Ljava/util/List;ILjava/util/List;)V +# - name: X509ResourceCertificateParentChildValidatorTest#validParentChildOverClaimingLooseValidation +# entryPoint: net.ripe.rpki.commons.validation.X509ResourceCertificateParentChildValidatorTest.validParentChildOverClaimingLooseValidation(Ljava/util/List;ILjava/util/List;)V diff --git a/artifacts/configs/rpki-commons/rpki-commons.patch b/artifacts/configs/rpki-commons/rpki-commons.patch new file mode 100644 index 00000000..1638a53a --- /dev/null +++ b/artifacts/configs/rpki-commons/rpki-commons.patch @@ -0,0 +1,84 @@ +diff --git a/pom.xml b/pom.xml +index 08ebb666..0157a994 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -373,6 +373,58 @@ + true + + ++ ++ ++ org.jacoco ++ jacoco-maven-plugin ++ 0.8.6 ++ ++ ++ default-prepare-agent ++ ++ prepare-agent ++ ++ ++ ++ jacoco-report ++ test ++ ++ report ++ ++ ++ ++ ++ ++ org.apache.maven.plugins ++ maven-jar-plugin ++ 3.2.0 ++ ++ ++ ++ test-jar ++ ++ ++ ++ ++ ++ org.apache.maven.plugins ++ maven-assembly-plugin ++ 3.3.0 ++ ++ ++ jar-with-dependencies ++ ++ ++ ++ ++ make-assembly ++ package ++ ++ single ++ ++ ++ ++ + + + +@@ -457,4 +509,20 @@ + + + ++ ++ ++ ++ ++ org.jacoco ++ jacoco-maven-plugin ++ ++ ++ ++ report ++ ++ ++ ++ ++ ++ + diff --git a/artifacts/configs/rpki-commons/rpki-commons.yaml b/artifacts/configs/rpki-commons/rpki-commons.yaml new file mode 100644 index 00000000..44139d36 --- /dev/null +++ b/artifacts/configs/rpki-commons/rpki-commons.yaml @@ -0,0 +1,21 @@ +name: rpki-commons +URL: https://github.com/RIPE-NCC/rpki-commons.git +checkoutID: dd5af7c644d2cd9cc6b0b5f4f2480b6dfc1ef074 +patchName: artifacts/configs/rpki-commons/rpki-commons.patch +mainJar: rpki-commons-DEV.jar +testJar: rpki-commons-DEV-tests.jar +#mvnOptions: -DfailIfNoTests=false +#mvnOptions: -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" +properties: + - name: RoaCMSBuilderPropertyTest#buildEncodedParseCheck + entryPoint: net.ripe.rpki.commons.crypto.cms.roa.RoaCMSBuilderPropertyTest.buildEncodedParseCheck(JLjava/lang/Integer;)V + - name: ManifestCMSBuilderPropertyTest#buildEncodedParseCheck + entryPoint: net.ripe.rpki.commons.crypto.cms.manifest.ManifestCMSBuilderPropertyTest.buildEncodedParseCheck([BLjava/math/BigInteger;Ljava/lang/Integer;)V + - name: AspaCmsTest#should_generate_aspa + entryPoint: net.ripe.rpki.commons.crypto.cms.aspa.AspaCmsTest.should_generate_aspa(ILjava/util/List;)V + - name: X509ResourceCertificateParentChildValidatorTest#validParentChildSubResources + entryPoint: net.ripe.rpki.commons.validation.X509ResourceCertificateParentChildValidatorTest.validParentChildSubResources(Ljava/util/List;I)V + - name: X509ResourceCertificateParentChildValidatorTest#validParentChildOverClaiming + entryPoint: net.ripe.rpki.commons.validation.X509ResourceCertificateParentChildValidatorTest.validParentChildOverClaiming(Ljava/util/List;ILjava/util/List;)V + - name: X509ResourceCertificateParentChildValidatorTest#validParentChildOverClaimingLooseValidation + entryPoint: net.ripe.rpki.commons.validation.X509ResourceCertificateParentChildValidatorTest.validParentChildOverClaimingLooseValidation(Ljava/util/List;ILjava/util/List;)V diff --git a/runone.sh b/runone.sh index 156e0cf4..b936b1ef 100755 --- a/runone.sh +++ b/runone.sh @@ -23,6 +23,9 @@ else rm -rf output mkdir output + # add results (if not exists) + mkdir -p "artifacts/results/$projectName" + # git project java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar git -c $projectName @@ -39,4 +42,4 @@ else cd output-$projectName || exit ../buildsvg.sh cd .. -fi \ No newline at end of file +fi diff --git a/src/main/java/edu/uic/bitslab/callgraph/GetBest.java b/src/main/java/edu/uic/bitslab/callgraph/GetBest.java index 1da83dd5..34fddea7 100644 --- a/src/main/java/edu/uic/bitslab/callgraph/GetBest.java +++ b/src/main/java/edu/uic/bitslab/callgraph/GetBest.java @@ -118,18 +118,21 @@ public void run() { iter.next(); } - // get all of the paths + // get all the paths in best order List pathWeights = new ArrayList<>(); BFSShortestPath bfsShortestPath = new BFSShortestPath<>(reachability); ShortestPathAlgorithm.SingleSourcePaths allPaths = bfsShortestPath.getPaths(entryPoint); HashSet sinkSet = reachability.vertexSet().stream().filter(vertex -> reachability.outDegreeOf(vertex) == 0).collect(Collectors.toCollection(HashSet::new)); sinkSet.forEach( sinkVertex -> { GraphPath executionPath = allPaths.getPath(sinkVertex); + double pathSum = executionPath.getEdgeList().stream().map(reachability::getEdgeTarget).filter(Objects::nonNull).mapToDouble(score::get).sum(); - double pathSum = executionPath.getEdgeList().stream().map(reachability::getEdgeTarget).mapToDouble(score::get).filter( (d) -> !Double.isNaN(d)).sum(); - pathWeights.add(new PathWeight(executionPath, pathSum)); + if (pathSum > 0.00 && score.getOrDefault(executionPath.getEndVertex(), 0.00d) > 0.00) { + pathWeights.add(new PathWeight(executionPath, pathSum)); + } }); + // output sorted paths Comparator comparator = Comparator.comparingDouble(p -> p.weight); pathWeights.sort(comparator.reversed()); @@ -188,7 +191,7 @@ public void run() { exporter.setVertexAttributeProvider( (v) -> { Map map = new LinkedHashMap<>(); - map.put("label", DefaultAttribute.createAttribute((Math.round(score.get(v) * 100) / 100.0d) + " - " + dotFormat(v.toString()))); + map.put("label", DefaultAttribute.createAttribute(score.get(v) + " - " + dotFormat(v.toString()))); map.put("style", DefaultAttribute.createAttribute("filled")); map.put("fillcolor", DefaultAttribute.createAttribute(v.getColor())); return map; @@ -289,16 +292,16 @@ private double vertexColorToInt(String color) { return 1.00; case LIGHT_GREEN: - return 0.80; + return 0.00; case MEDIUM_GREEN: - return 0.60; + return 0.00; case MEDIUM_DARK_GREEN: - return 0.40; + return 0.00; case DARK_GREEN: - return 0.20; + return 0.00; default: return 0.00; @@ -308,34 +311,19 @@ private double vertexColorToInt(String color) { private double Score(ColoredNode vertex) { final double weightParentScore = 1; final double weightChildrenScore = .5; - //final double weightUncoveredChildren = .5; // parent score (note: high score is better) double parentScore = vertexColorToInt(vertex.getColor()); -// double maxChildrenScore = graph.outgoingEdgesOf(vertex) -// .stream() -// .mapToDouble( e -> score.get(graph.getEdgeTarget(e)) ) -// .max() -// .orElse(0.00); - double totalChildrenScore = graph.outgoingEdgesOf(vertex) .stream() .mapToDouble( e -> score.getOrDefault(graph.getEdgeTarget(e), 0.00) ) .sum(); - return (weightParentScore * parentScore) + + double vertexScore = (weightParentScore * parentScore) + (weightChildrenScore * totalChildrenScore); - // get uncovered children -// long countUncoveredChildren = graph.outgoingEdgesOf(vertex) -// .stream() -// .map( e -> graph.getEdgeTarget(e).getColor() ) -// .filter( color -> color.equals(UNCOVERED_COLOR)) -// .count(); -// -// return (weightParentScore * parentScore) + -// (parentScore * (weightUncoveredChildren * countUncoveredChildren)); + return Math.round(vertexScore * 100) / 100.0d; } } } diff --git a/src/main/java/gr/gousiosg/javacg/stat/JCallGraph.java b/src/main/java/gr/gousiosg/javacg/stat/JCallGraph.java index e78279fb..9d8d39de 100644 --- a/src/main/java/gr/gousiosg/javacg/stat/JCallGraph.java +++ b/src/main/java/gr/gousiosg/javacg/stat/JCallGraph.java @@ -180,9 +180,14 @@ else if(s.second instanceof ArrayList){ maybeInspectAncestry(callgraph, arguments, jacocoCoverage, Optional.of(s.second), Optional.of(propertyName)); rt.cleanTarget(); - // write the best paths and annotated dot file - GetBest getBest = new GetBest(prunedReachability, propertyName); - getBest.run(); + try { + // write the best paths and annotated dot file + GetBest getBest = new GetBest(prunedReachability, propertyName); + getBest.run(); + } catch (NullPointerException e) { + // ok ... getbest blew up ... log it an continue + LOGGER.error("Get Best Null Pointer Exception: " + Arrays.stream(e.getStackTrace()).map(StackTraceElement::toString)); + } } break; }