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

Issue-281: Updates dependencies version to fix CVE-2023-2976 #282

Merged
merged 11 commits into from
Sep 27, 2023

Conversation

a6dulaleem
Copy link
Contributor

@a6dulaleem a6dulaleem commented Sep 21, 2023

Problem description
Upgrade dependencies in Schema registry which could have possible CVEs

Library CVE Version
checkstyleToolVersion 10.12.3
protobufUtilVersion 3.24.3
guavaVersion 32.0.1-jre
swaggerJersey2JaxrsVersion 1.6.11

Problem location
gradle.properties

Suggestions for an improvement
upgrade lib versions to suggested versions to mitigate the CVEs.

Purpose of the change Fix #281

Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
@a6dulaleem a6dulaleem marked this pull request as ready for review September 21, 2023 07:29
@a6dulaleem
Copy link
Contributor Author

ran schema registry build 171 and it ran successful
ran flink connector and it got succeed build number is 420 all test passed.

@shshashwat
Copy link
Contributor

ran schema registry build 171 and it ran successful ran flink connector and it got succeed build number is 420 all test passed.

Please create an issue and tag the PR with that

@@ -86,7 +86,7 @@ public CompletableFuture<Void> updateEntries(List<Entry<Integer>> updates) {
TableKey key = update.getKey();
Integer version = update.getVersion();
Value<TableValue, Integer> val = table.get(key);
return version == null || (val != null && version.equals(val.getVersion()));
return version == null || val != null && version.equals(val.getVersion());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't get the reason behind this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are changing the Checkstyle version it was claimed by that, it was claiming that redundant Pair of parenthesis

*/
public static StoreExceptions create(final Type type, final Throwable cause, final String errorMessage) {
Preconditions.checkArgument(cause != null || (errorMessage != null && !errorMessage.isEmpty()),
Preconditions.checkArgument(cause != null || errorMessage != null && !errorMessage.isEmpty(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this change required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are changing the Checkstyle version it was claimed by that, it was claiming that redundant Pair of parenthesis

@@ -153,6 +153,7 @@ public static <T extends GeneratedMessageV3> ProtobufSchema<GeneratedMessageV3>
*
* @param schemaInfo Schema Info
* @return {@link ProtobufSchema} with generic type {@link DynamicMessage} that captures protobuf schema.
* @throws IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method signature needs to be changed too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this method is throwing this exception, claimed by checkstylel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this method is throwing the exception, this should be added to the method signature as well. And how are we handling that exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this method was already throwing IllegalArgumentException as this is a unchecked so it was not added in method signature.

Check style was claiming if we are not showing this in Doc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a unchecked exception so doesn't require a throws clause, so why are we mentioning it in docs? Why check style is mandating to place this exception in docs ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkstyle is mandating it because InvalidProtocolBufferException this exception is raising its throwing null pointer exception.
other I there is a way we can hide this from documentation by using hyphen after the exception, what it will do while generating doc it will remove this exception from the doc.

but i am not getting a way in which i just remove this throws from the method doc.

either checked or unchecked its being thrown by the method.

@@ -74,7 +74,8 @@ private JSONSchema(SchemaInfo schemaInfo, String schemaString, Class<T> derived)
*
* @param tClass Class whose object's schema is used.
* @param <T> Type of the Java class.
* @return {@link JSONSchema} with generic type T that extracts and captures the json schema.
* @return {@link JSONSchema} with generic type T that extracts and captures the json schema.
* @throws IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method signature needs to be changed too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this method is throwing this exception, claimed by checkstylel.

@@ -96,7 +97,8 @@ public static <T> JSONSchema<T> of(Class<T> tClass) {
* @param schema Schema to use.
* @param tClass class for the type of object
* @param <T> Type of object
* @return Returns an JSONSchema with {@link Object} type.
* @return Returns an JSONSchema with {@link Object} type.
* @throws IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claimed by checkstyle

* @return Returns an JsonSchema of type T.
* @param <T> Type of base class.
* @return Returns an JsonSchema of type T.
* @throws IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claimed by checkstyle

Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
@@ -39,10 +39,10 @@ nettyBoringSSLVersion=2.0.54.Final
jacocoVersion=0.8.5
protobufGradlePlugin=0.8.15
protobufProtocVersion=3.21.7
protobufUtilVersion=3.19.4
protobufUtilVersion=3.24.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there is a PR on Pravega too for similar issue. Can we check the versions and try to keep them in sync just in order to avoid backward-forward incompatibility issue at a later stage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protobufUtilVersion is not being used in pravega.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protobufGradlePlugin=0.8.15
protobufProtocVersion=3.21.7

already syncing

<property name="allowMissingJavadoc" value="true"/> <!--TODO: this should be enabled at one point. -->
<property name="ignoreMethodNamesRegex" value="^get.*$"/> <!--It would be nice if we could allow checking that the doc exists without also verifying the @returns is there also, but checkstyle does not allow that. -->
<property name="ignoreMethodNamesRegex" value="^has.*$"/> <!-- accessor for boolean e.g. hasVersion -->
<property name="suppressLoadErrors" value="false"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these javaDocsMethod checkstyle properties removed?

Copy link
Contributor Author

@a6dulaleem a6dulaleem Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all are deprecated in new checkStyle version

Comment on lines 47 to 50
<Match> <!-- fromBytes was not reporting this warning in earlier version of checkstyle -->
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
<Method name="fromBytes" />
</Match>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do new version force us to add this suppression ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fromBytes method is returning some value from some map and that map we are already building on the top of the class you can see here

now there is no way that it could get NULL from the map

but The bugs still reported by newer version of the checkstyle.

and becuases of that we are suppressing this.

Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
val versionSerializer = SERIALIZERS_BY_KEY_TYPE.get(keyClass);
if ( versionSerializer == null ) {
throw new SerializationException(String.format("No serializer found for the class %s", keyClass.toGenericString()));
}
return (T) SERIALIZERS_BY_KEY_TYPE.get(keyClass).deserialize(bytes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a6dulaleem Can we use versionSerializer at line 430

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Signed-off-by: a6dulaleem <abdul.aleem1@dell.com>
Copy link
Contributor

@anishakj anishakj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -74,7 +74,7 @@ private JSONSchema(SchemaInfo schemaInfo, String schemaString, Class<T> derived)
*
* @param tClass Class whose object's schema is used.
* @param <T> Type of the Java class.
* @return {@link JSONSchema} with generic type T that extracts and captures the json schema.
* @return {@link JSONSchema} with generic type T that extracts and captures the json schema.
Copy link
Contributor Author

@a6dulaleem a6dulaleem Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please Ignore these spaces are automatically removed by IntelliJ.

Copy link
Contributor

@shshashwat shshashwat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@Bhupender-Y Bhupender-Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@a6dulaleem a6dulaleem changed the title Issue-281: Updates guava version to fix CVE-2023-2976 Issue-281: Updates dependencies version to fix CVE-2023-2976 Sep 27, 2023
@shshashwat shshashwat merged commit c4b6a43 into pravega:master Sep 27, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade dependencies with vulnerabilities
5 participants