Skip to content

Commit

Permalink
Fix Jackson version for security (#32)
Browse files Browse the repository at this point in the history
Fixes the Jackson security alert found here: https://github.com/ripple/crypto-conditions/network/alert/pom.xml/com.fasterxml.jackson.core:jackson-databind/open

* Update Jackson version to address github security warning.
* Configure Checkstyle properly
* Fix checkstyle warns and errors.
* Update dependency versions.

Signed-off-by: sappenin <[email protected]>
  • Loading branch information
sappenin authored Nov 6, 2019
1 parent 0feea16 commit 4c1f71c
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 125 deletions.
60 changes: 41 additions & 19 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0"?>
<!--
========================LICENSE_START=================================
Hyperledger Quilt Dev-Ops Tools
%%
Copyright (C) 2017 - 2018 Hyperledger and its contributors
%%
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================LICENSE_END==================================
-->

<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
Expand Down Expand Up @@ -38,7 +58,7 @@
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format"
value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
Expand All @@ -65,17 +85,17 @@
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
Expand All @@ -98,49 +118,49 @@
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<property name="allowOneCharVarInForLoop" value="true"/>
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MethodTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="NoFinalizer"/>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="Indentation">
<property name="basicOffset" value="2"/>
Expand All @@ -160,13 +180,13 @@
<property name="specialImportsRegExp" value="org.interledger"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="customImportOrderRules"
value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
</module>
<module name="MethodParamPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens"
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
Expand All @@ -179,7 +199,7 @@
<module name="JavadocTagContinuationIndentation"/>
<module name="SummaryJavadocCheck">
<property name="forbiddenSummaryFragments"
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
<module name="JavadocParagraph"/>
<module name="AtclauseOrder">
Expand All @@ -198,7 +218,7 @@
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/>
value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc">
<property name="ignoreInlineTags" value="false"/>
Expand All @@ -207,5 +227,7 @@
<property name="exceptionVariableName" value="expected"/>
</module>
<module name="CommentsIndentation"/>
<module name="SuppressWarningsHolder"/>
</module>
<module name="SuppressWarningsFilter"/>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public final void testNullPreimage() {
*/
@Test
public final void testSmallToLargePreimage() {
for (int PREIMAGE_LENGTH = 0; PREIMAGE_LENGTH < 100; PREIMAGE_LENGTH++) {
// Fill the array with PREIMAGE_LENGTH bytes...
final byte[] preimageBytes = new byte[PREIMAGE_LENGTH];
for (int preimageLength = 0; preimageLength < 100; preimageLength++) {
// Fill the array with preimageLength bytes...
final byte[] preimageBytes = new byte[preimageLength];
new SecureRandom().nextBytes(preimageBytes);

final PreimageSha256Fulfillment fulfillment = PreimageSha256Fulfillment.from(preimageBytes);
assertThat(fulfillment.getDerivedCondition().getCost(), is(Long.valueOf(PREIMAGE_LENGTH)));
assertThat(fulfillment.getDerivedCondition().getCost(), is(Long.valueOf(preimageLength)));
assertTrue("Invalid condition", fulfillment.verify(fulfillment.getDerivedCondition(), new byte[]{}));
}
}
Expand All @@ -120,8 +120,7 @@ public final void testValidateWithDifferentConditionType() {
TestConditionFactory.constructPrefixSha256Condition("invalid"), new byte[]{})
);

final Fulfillment actual = narrowlyTypedActual;
assertFalse("Invalid condition", actual.verify(
assertFalse("Invalid condition", narrowlyTypedActual.verify(
TestConditionFactory.constructPrefixSha256Condition("invalid"), new byte[]{})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -147,7 +147,7 @@ public void twoOfTwoCondition() {
}

@Test(expected = NullPointerException.class)
public void mOfNWithNullSubConditionsList() {
public void mkeysOfnWithNullSubConditionsList() {
try {
ThresholdFactory.constructMOfNCondition(1, 2, null);
} catch (NullPointerException e) {
Expand All @@ -157,7 +157,7 @@ public void mOfNWithNullSubConditionsList() {
}

@Test(expected = IllegalArgumentException.class)
public void mOfNWithNegativeThreshold() {
public void mkeysOfnWithNegativeThreshold() {
try {
ThresholdFactory
.constructMOfNCondition(-1, 2, Lists.newArrayList(subcondition1, subcondition2));
Expand All @@ -168,7 +168,7 @@ public void mOfNWithNegativeThreshold() {
}

@Test
public void mOfNWithZeroThreshold() {
public void mkeysOfnWithZeroThreshold() {
// Create a control threshold fulfillment that has no fulfillments (0) to satisfy the
// threshold of a 0-of-3 condition.
final ThresholdSha256Fulfillment thresholdFulfillment = ThresholdSha256Fulfillment.from(
Expand All @@ -183,7 +183,7 @@ public void mOfNWithZeroThreshold() {
}

@Test(expected = IllegalArgumentException.class)
public void mOfNWithIncorrectNumSubConditions() {
public void mkeysOfnWithIncorrectNumSubConditions() {
try {
ThresholdFactory.constructMOfNCondition(0, 2, Lists.newArrayList(subcondition1));
} catch (IllegalArgumentException e) {
Expand All @@ -196,7 +196,7 @@ public void mOfNWithIncorrectNumSubConditions() {
* Test {@link ThresholdFactory#constructMOfNCondition(int, int, List)}.
*/
@Test
public void mOfNConditionTest() {
public void mkeysOfnConditionTest() {

// Create a control threshold fulfillment that has enough fulfillments (3) to satisfy the
// threshold of a 3-of-5 condition.
Expand Down Expand Up @@ -420,7 +420,7 @@ public void twoOfTwoFulfillment() {
}

@Test(expected = NullPointerException.class)
public void mOfNFulfillmentWithFirstNull() {
public void mkeysOfnFulfillmentWithFirstNull() {
try {
ThresholdFactory.constructMOfNFulfillment(1, 2, null, Lists.newArrayList());
} catch (NullPointerException e) {
Expand All @@ -430,7 +430,7 @@ public void mOfNFulfillmentWithFirstNull() {
}

@Test(expected = NullPointerException.class)
public void mOfNFulfillmentWithSecondNull() {
public void mkeysOfnFulfillmentWithSecondNull() {
try {
ThresholdFactory.constructMOfNFulfillment(1, 2, Lists.newArrayList(), null);
} catch (NullPointerException e) {
Expand All @@ -440,7 +440,7 @@ public void mOfNFulfillmentWithSecondNull() {
}

@Test(expected = IllegalArgumentException.class)
public void mOfNFulfillmenttsWithNegativeThreshold() {
public void mkeysOfnFulfillmenttsWithNegativeThreshold() {
try {
ThresholdFactory.constructMOfNFulfillment(-1, 2, Lists.newArrayList(),
Lists.newArrayList(subfulfillment1, subfulfillment2));
Expand All @@ -451,7 +451,7 @@ public void mOfNFulfillmenttsWithNegativeThreshold() {
}

@Test(expected = IllegalArgumentException.class)
public void mOfNFulfillmentWithIncorrectTotalN() {
public void mkeysOfnFulfillmentWithIncorrectTotalN() {
try {
ThresholdFactory.constructMOfNFulfillment(1, 2,
Lists.newArrayList(),
Expand All @@ -469,7 +469,7 @@ public void mOfNFulfillmentWithIncorrectTotalN() {
* pair.
*/
@Test
public void mOfNFulfillmentForOneOfTwo() {
public void mkeysOfnFulfillmentForOneOfTwo() {

// The condition to fulfill...
final ThresholdSha256Condition thresholdCondition = ThresholdSha256Condition.from(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public static PreimageSha256Fulfillment constructPreimageFulfillment(final Strin
*/
public static PrefixSha256Fulfillment constructPrefixSha256Fulfillment(final String prefix) {
return PrefixSha256Fulfillment
.from(prefix.getBytes(), 1000, constructPreimageFulfillment(PREIMAGE1));
.from(prefix.getBytes(), 1000, constructPreimageFulfillment(PREIMAGE1));
}

/**
* Helper to construct a {@link RsaSha256Fulfillment} with a known public key.
*/
public static RsaSha256Fulfillment constructRsaSha256Fulfillment(
final KeyPair rsaKeyPair
final KeyPair rsaKeyPair
) {
try {
final Signature rsaSigner = Signature.getInstance("SHA256withRSA/PSS");
Expand All @@ -85,8 +85,8 @@ public static RsaSha256Fulfillment constructRsaSha256Fulfillment(
* corresponding private key.
*/
public static RsaSha256Fulfillment constructRsaSha256Fulfillment(
final RSAPublicKey rsaPublicKey,
final byte[] signature
final RSAPublicKey rsaPublicKey,
final byte[] signature
) {
return RsaSha256Fulfillment.from(rsaPublicKey, signature);
}
Expand All @@ -103,8 +103,8 @@ public static Ed25519Sha256Fulfillment constructEd25519Sha256Fulfillment(final K
byte[] edDsaSignature = edDsaSigner.sign();

return constructEd25519Sha256Fulfillment(
(EdDSAPublicKey) ed25519KeyPair.getPublic(),
edDsaSignature
(EdDSAPublicKey) ed25519KeyPair.getPublic(),
edDsaSignature
);
} catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException e) {
throw new RuntimeException(e);
Expand All @@ -116,7 +116,7 @@ public static Ed25519Sha256Fulfillment constructEd25519Sha256Fulfillment(final K
* corresponding private key.
*/
public static Ed25519Sha256Fulfillment constructEd25519Sha256Fulfillment(
final EdDSAPublicKey edDsaPublicKey, final byte[] signature
final EdDSAPublicKey edDsaPublicKey, final byte[] signature
) {
return Ed25519Sha256Fulfillment.from(edDsaPublicKey, signature);
}
Expand All @@ -126,12 +126,12 @@ public static Ed25519Sha256Fulfillment constructEd25519Sha256Fulfillment(
*/
public static ThresholdSha256Fulfillment constructThresholdFulfillment() {
return ThresholdSha256Fulfillment.from(
Lists.newArrayList(TestConditionFactory
.constructRsaSha256Condition(TestKeyFactory.constructRsaPublicKey(RSA_MODULUS))),
Lists.newArrayList(
TestFulfillmentFactory.constructPreimageFulfillment(PREIMAGE1),
TestFulfillmentFactory.constructPrefixSha256Fulfillment(PREFIX1)
)
Lists.newArrayList(TestConditionFactory
.constructRsaSha256Condition(TestKeyFactory.constructRsaPublicKey(RSA_MODULUS))),
Lists.newArrayList(
TestFulfillmentFactory.constructPreimageFulfillment(PREIMAGE1),
TestFulfillmentFactory.constructPrefixSha256Fulfillment(PREFIX1)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
Loading

0 comments on commit 4c1f71c

Please sign in to comment.