Repository navigation
fix(java): mark Android test configurations as dev in gradle.lockfile - #11768
Open
Sun-Wukhan wants to merge 1 commit into
Open
Sun-Wukhan wants to merge 1 commit into
Sun-Wukhan wants to merge 1 commit into
Conversation
The gradle.lockfile parser marked a dependency as dev only when all of its configurations started with "test". The Android Gradle Plugin names test configurations after the build variant instead (e.g. debugUnitTestRuntimeClasspath, debugAndroidTestCompileClasspath), so Android test-only dependencies were reported as production dependencies and their vulnerabilities surfaced without --include-dev-deps. Treat a configuration as a test configuration when its whole name matches <variant>(UnitTest|AndroidTest)(CompileClasspath| RuntimeClasspath|AnnotationProcessorClasspath), in addition to the existing "test" prefix rule. Refs aquasecurity#11728 Signed-off-by: Navid Khan (Ali) <60997541+Sun-Wukhan@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The gradle.lockfile parser marked a dependency as dev only when all of its configurations started with
test(the JVM naming, e.g.testCompileClasspath). The Android Gradle Plugin names test configurations after the build variant instead, e.g.debugUnitTestRuntimeClasspathordebugAndroidTestCompileClasspath, so Android test-only dependencies (such as junit ondebugUnitTest*/releaseUnitTest*classpaths) were reported as production dependencies and their vulnerabilities surfaced without--include-dev-deps.This change treats a configuration as a test configuration when its whole name matches
<variant>(UnitTest|AndroidTest)(CompileClasspath|RuntimeClasspath|AnnotationProcessorClasspath), in addition to the existingtestprefix rule. The match is anchored and requires a non-empty variant prefix, so production configurations are never marked dev. The existing rule that a dependency is dev only when all of its configurations are test configurations is unchanged.Tests: a new
android.lockfilefixture covers Android-test-only dependencies (marked dev) and a mixed case with one production configuration (not dev), and a unit test covers the configuration matcher including near-miss names. Before this change the new fixture case failed with the Android test dependencies reported asDev: false; after the changego test ./pkg/dependency/parser/gradle/lockfile/...passes.Related issues
Checklist