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

Transitive dependencies creating version conflicts & missing jar verification #4086

Closed
ghubstan opened this issue Mar 21, 2020 · 10 comments
Closed

Comments

@ghubstan
Copy link
Contributor

ghubstan commented Mar 21, 2020

Description

The gradle build needs to be more strict about excluding transitive dependencies that create version conflicts. (This implies some dependencies might need to be upgraded, and some even downgraded, to align versions of direct and transitive dependencies.)

Version

Commit 17bb7b4

Steps to reproduce

Build Bisq and see multiple versions of some jars in the lib dir.

Expected behaviour

There should not be any version conflicts, and every jar needs to be verified by the gradle-witness.gradle file.

Actual behaviour

There are several transitive dependencies downloaded during the build that conflict with direct dependencies specified in gradle.build, and in the case of the desktop build, they are not being verified by gradle-witness.

Here are duplicate jars with the letters 'grpc' in their name:

grpc-context-1.10.1.jar
grpc-context-1.25.0.jar
grpc-core-1.10.1.jar
grpc-core-1.25.0.jar
grpc-netty-shaded-1.10.1.jar
grpc-netty-shaded-1.25.0.jar
grpc-protobuf-1.10.1.jar
grpc-protobuf-1.25.0.jar
grpc-protobuf-lite-1.10.1.jar
grpc-protobuf-lite-1.25.0.jar
grpc-stub-1.10.1.jar
grpc-stub-1.25.0.jar
opencensus-contrib-grpc-metrics-0.11.0.jar
opencensus-contrib-grpc-metrics-0.21.0.jar

This may not be an urgent problem because the latest jar is loaded at run time. However, that also means that a transitive dependency with a larger version than is specified in the build file is loaded, not the jar which has passed gradle witness verification. For example: the build file specifies

slf4jVersion = '1.7.22'

but

lsof -Pan -p $(pgrep -f BisqAppMain)        ( on linux )

shows me that the transitive dependency slf4j-api-1.7.25.jar is being loaded instead.

Maybe building the shipped, shaded jar eliminates most of this problem, but I new devs like me may spend a lot of time trying to figure out why jar version conflicts like the grpc example I described above exist.

ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 21, 2020
Aligns Bisq's slf4j version requirement with that of other dependencies.

This removes a duplicated dependency, and corrects the gradle-witness.gradle
slf4-api entry, which verified slf4-api v1.7.22, not the transitive dependency
loaded at runtime.

Partial fix for bisq-network#4086
ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 21, 2020
The latest firebase-admin depends on grpc-api v1.24.1, which is as close
as we can get to the grpc v1.25.0 specified in build.gradle.  Currently,
the firebase-admin version requirement is causing the build to download
grpc v1.10.1 jars, but at runtime, grpc 1.25.0 jars are loaded.

Partial fix for bisq-network#4086
ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 21, 2020
The latest firebase-admin (v6.12.2) depends on grpc-api v1.24.1,
which is as close as we can get to the grpc v1.25.0 specified in
build.gradle.  Currently, the firebase-admin version requirement
is causing the build to download grpc v1.10.1 jars, but at runtime,
grpc 1.25.0 jars are loaded.

Eliminating the version conflict saves a dev time thinking about which
source jar to choose from while examining exception stack traces.

Partial fix for bisq-network#4086
ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 21, 2020
The latest firebase-admin (v6.12.2) depends on grpc-api v1.24.1,
which is as close as we can get to the grpc v1.25.0 specified in
build.gradle.  Currently, the firebase-admin version requirement
is causing the build to download grpc v1.10.1 jars, but at runtime,
grpc 1.25.0 jars are loaded.

Transitive dependency grpc-netty-shaded-1.23.0 is also excluded.

Eliminating version conflicts saves a dev time thinking about which
source jar to choose from while examining exception stack traces.

Partial fix for bisq-network#4086
ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 22, 2020
The latest firebase-admin (v6.12.2) depends on grpc-api v1.24.1,
which is as close as we can get to the grpc v1.25.0 specified in
build.gradle.  Currently, the firebase-admin version requirement
is causing the build to download grpc v1.10.1 jars, but at runtime,
grpc 1.25.0 jars are loaded.

Transitive dependencies grpc-netty-shaded, grpc-protobuf,
grpc-protobuf-lite, grpc-protobuf-stub, grpc-protobuf-grpclb
(v1.23.0) are also excluded.

Eliminating version conflicts saves a dev time thinking about which
source jar to choose from while examining exception stack traces.

Partial fix for bisq-network#4086
ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 22, 2020
The latest firebase-admin (v6.12.2) depends on grpc-api v1.24.1,
which is as close as we can get to the grpc v1.25.0 specified in
build.gradle.  Currently, the firebase-admin version requirement
is causing the build to download grpc v1.10.1 jars, but at runtime,
grpc 1.25.0 jars are loaded.

Transitive dependencies grpc-netty-shaded, grpc-protobuf,
grpc-protobuf-lite, grpc-protobuf-stub, grpc-protobuf-grpclb
(v1.23.0) are also excluded.

Upgraded slf4j version requirement to match that of other
dependencies.  This removes a duplicated dependency, and corrects
the gradle-witness.gradle slf4-api entry, which verified slf4-api
v1.7.22, not the transitive dependency loaded at runtime.

Beyond avoiding general version hell issues, eliminating version
conflicts saves a dev time thinking about which source jar to
choose from while examining exception stack traces.

Partial fix for bisq-network#4086
@ghubstan
Copy link
Contributor Author

I don't think it will be possible to resolve all version conflicts because too many transitive dependencies have too many of their own version conflict problems in their own dependency graphs. But it would be good to minimize them in Bisq as much as practicable.

ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 22, 2020
Some apache & logback dependency versions were bumped up, some
transitive dependencies declared as direct dependencies, and some
new exclusions were added to reduced the number of duplicated
dependencies in the build.
Also updated gradle-witness.gradle.

Here are some of the duplicated apache dependencies in the current build:

	commons-codec-1.10.jar
	commons-codec-1.9.jar
	commons-io-2.4.jar
	commons-io-2.6.jar
	commons-logging-1.1.1.jar
	commons-logging-1.2.jar

	httpclient-4.0.1.jar
	httpclient-4.5.3.jar
	httpclient-4.5.5.jar
	httpcore-4.0.1.jar
	httpcore-4.4.6.jar
	httpcore-4.4.9.jar

	logback-classic-1.1.10.jar
	logback-classic-1.1.11.jar
	logback-core-1.1.10.jar
	logback-core-1.1.11.jar

Upgraded:

	codecVersion '1.9 -> 1.13
	ioVersion  2.4 -> 2.6
	langVersion 3.4 -> 3.8
	httpclientVersion 4.5.3 -> 4.5.12
	slf4jVersion 1.7.22 -> 1.7.25

New dependency declarations:

	loggingVersion 1.2
	httpcoreVersion 4.4.13

This commit reduces the number of build dependencies by 10.

Partial fix for bisq-network#4086
ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 22, 2020
Some apache & logback dependency versions were bumped up, some
transitive dependencies declared as direct dependencies, and some
new exclusions were added to reduce the number of duplicated
dependencies in the build.
Also updated gradle-witness.gradle.

Here are some of the duplicated apache dependencies in the current build:

	commons-codec-1.10.jar
	commons-codec-1.9.jar
	commons-io-2.4.jar
	commons-io-2.6.jar
	commons-logging-1.1.1.jar
	commons-logging-1.2.jar

	httpclient-4.0.1.jar
	httpclient-4.5.3.jar
	httpclient-4.5.5.jar
	httpcore-4.0.1.jar
	httpcore-4.4.6.jar
	httpcore-4.4.9.jar

	logback-classic-1.1.10.jar
	logback-classic-1.1.11.jar
	logback-core-1.1.10.jar
	logback-core-1.1.11.jar

Upgraded:

	codecVersion 1.9 -> 1.13
	ioVersion  2.4 -> 2.6
	langVersion 3.4 -> 3.8
	httpclientVersion 4.5.3 -> 4.5.12
	slf4jVersion 1.7.22 -> 1.7.25

New dependency declarations:

	loggingVersion 1.2
	httpcoreVersion 4.4.13

This commit reduces the number of build dependencies by 10.

Partial fix for bisq-network#4086
ghubstan added a commit to ghubstan/bisq that referenced this issue Mar 22, 2020
Some apache & logback dependency versions were bumped up, some
transitive dependencies declared as direct dependencies, and some
new exclusions were added to reduce the number of duplicated
dependencies in the build.
Also updated gradle-witness.gradle.

Here are some of the duplicated apache and logback dependencies
in the current build:

	commons-codec-1.10.jar
	commons-codec-1.9.jar
	commons-io-2.4.jar
	commons-io-2.6.jar
	commons-logging-1.1.1.jar
	commons-logging-1.2.jar

	httpclient-4.0.1.jar
	httpclient-4.5.3.jar
	httpclient-4.5.5.jar
	httpcore-4.0.1.jar
	httpcore-4.4.6.jar
	httpcore-4.4.9.jar

	logback-classic-1.1.10.jar
	logback-classic-1.1.11.jar
	logback-core-1.1.10.jar
	logback-core-1.1.11.jar

Upgraded:

	codecVersion 1.9 -> 1.13
	ioVersion  2.4 -> 2.6
	langVersion 3.4 -> 3.8
	httpclientVersion 4.5.3 -> 4.5.12
	slf4jVersion 1.7.22 -> 1.7.25

New dependency declarations:

	loggingVersion 1.2
	httpcoreVersion 4.4.13

This commit reduces the number of build dependencies by 10.

Partial fix for bisq-network#4086
@stale
Copy link

stale bot commented Jun 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the was:dropped label Jun 20, 2020
@cd2357
Copy link
Contributor

cd2357 commented May 17, 2021

@ghubstan is this still an issue?

@ghubstan
Copy link
Contributor Author

Yes, it is. I'm working on an idea to improve this situation in a misq poc.

@cd2357
Copy link
Contributor

cd2357 commented May 17, 2021

Same here, was also looking for alternatives.

Some of the issues with gradle-witness I found:

Seems to give a false sense of security

Related older thread: #1897 (comment)

Main solutions I came across so far:

cc @bisq-network/bisq-devs : If you have other ideas, add as comments below.

@ghubstan
Copy link
Contributor Author

The gradle-witness plugin is becoming obsolete (and possibly) incompatible with newer versions of gradle. There is a built in verification task in newer gradle versions: https://docs.gradle.org/6.6.1/userguide/dependency_verification.html
It will generate an xml file with checksums for almost all dependencies in a big project; you can verify those generated checksums and add missing checksums.

I don't know if it can verify plugin jars.

@cd2357
Copy link
Contributor

cd2357 commented May 17, 2021

@ghubstan that's probably the best way forward.

Looks like it can even do plugins:

This feature can be used for:

  • detecting compromised dependencies
  • detecting compromised plugins
  • detecting tampered dependencies in the local dependency caches

Let me know if I can help.

@ghubstan
Copy link
Contributor Author

Let me know if I can help.

I think it just works if you add verification-metadata.xml to the project root's gradle directory.

<?xml version="1.0" encoding="UTF-8"?>
<verification-metadata>
   <configuration>
      <verify-metadata>true</verify-metadata>
      <verify-signatures>false</verify-signatures>
    </configuration>
</verification-metadata>

@cd2357
Copy link
Contributor

cd2357 commented May 18, 2021

Thanks, I added a PR for the only Misq repo I am aware of: https://github.com/chimp1984/misq/pull/8

@ghubstan
Copy link
Contributor Author

We will always be dealing with the version conflicts, but I appreciate the issue house cleaning you're doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants