You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(maven,gradle): look artifacts up on Maven Central only when no build file names another repository - #173
Fourth per-ecosystem fix from the registry audit, after Bundler (#168), Composer (#170) and NuGet (#171). Maven and Gradle looked every artifact up on Maven Central (or Google's repository for Android groups), so an artifact from a private repository could be looked up there.
Why the rule is coarse
Neither Maven nor Gradle records which repository served an artifact: no lockfile has it, and Gradle's lockfile and verification metadata hold versions and checksums only. Both try repositories in order and take the first hit, and Gradle adds content filters on top. Following that would mean re-implementing their resolution. So the Count over-counts: any repository besides Maven Central, Google's and the Gradle Plugin Portal anywhere in the build fails every lookup of that build system. Private Maven repositories aren't read yet anyway, as for the other ecosystems.
For comparison, Renovate merges the version lists of every repository it finds, which is the dependency-confusion pattern this avoids. It also drops repositories it can't parse.
Maven
Every pom.xml: repository, pluginRepository and snapshotRepository, in any profile. Ones under distributionManagement don't count, since that's where a project deploys, not where it resolves from.
Every file named *settings.xml whose root is <settings>: mirrors and repositories.
.mvn/maven.config naming -s/-gs settings the Count doesn't read fails.
A URL with a property such as ${repo.url}, or a POM the Count can't parse or read, fails.
Gradle
Files read: every script, the sources in buildSrc, build-logic, build-conventions and gradle/plugins, and the sources of every build the settings include.
Lexer: comments and the literal text of strings are blanked. Code inside ${ … } templates stays code, and Groovy slashy and dollar-slashy strings are handled. Kafka's real build needed both.
Allowed:mavenCentral(), google(), gradlePluginPortal() and jcenter().
Fails every lookup:
maven, ivy, flatDir, mavenLocal, exclusiveContent, or anything mentioning ArtifactRepository/RepositoryHandler, outside a publishing { } block;
apply from a URL;
an includeBuild whose folder has no files;
build logic that won't lex or whose braces don't balance.
Engine, two passes: included builds can live anywhere, so the engine reads their sources in a second pass after the settings are read, on both the GitHub and working-tree paths. A symlinked or non-text source there counts as unreadable.
Tests
Unit tests: Maven and Gradle cases for each rule, including a credential in a repository URL never reaching a report.
Engine: a test for the second pass.
Corpus: the real Kafka and Spring PetClinic builds read as public. Kafka's included api-checker build isn't in the corpus, so the Kafka check allows that one reason.
Docs: sources.md (package registries), compatibility.md, and departures.md (new #maven-repositories).
Policy: visible evidence
Decided with the maintainer. Lookups fail when committed build files show another repository. Repositories added only by Gradle plugins (e.g. JFrog Artifactory), Maven build extensions, init scripts or a CI machine's own settings aren't in the repository's files, so the Count doesn't see them. Maven Central and the Gradle Plugin Portal verify namespace ownership, which keeps someone else from publishing a private group's coordinates there. A private coordinate's name can still reach Central in a lookup.
Follow-ups
Repositories in remote parent POMs or imported BOMs aren't read.
mavenCentral { url = … } or mavenCentral().setUrl(…), which retarget a public repository, aren't detected.
An included build's sources are fetched one blob per file on the GitHub path, which is costly for a large included build.
Regex extractors with source = maven skip this check, as for the other ecosystems.
Further ways Gradle build logic can name a repository that the scan does not recognise, e.g. multi-line apply calls or repositories named through variables in plugin code. Under the visible-evidence policy these are accepted as unseen.
…ild file names another repository
Maven and Gradle looked every artifact up on Maven Central (or Google's
repository for Android groups), so an artifact from a private repository
could be looked up there. Neither tool records which repository served
an artifact, and both try repositories in order, so the Count does not
work out which one an artifact comes from: any repository other than
Central, Google's and the Gradle Plugin Portal anywhere in the build
fails every lookup of that build system.
- Maven: every pom.xml (any profile, not distributionManagement), every
*settings.xml in the repository (mirrors and repositories) and
.mvn/maven.config naming settings the Count does not read.
- Gradle: every script, the sources of buildSrc and other build-logic
folders, and of every build the settings include, read with a lexer
that keeps template code as code and knows slashy strings. maven, ivy,
flatDir, mavenLocal, exclusiveContent, custom ArtifactRepository use or
apply from a URL outside a publishing block, and build logic the Count
cannot read, fail every lookup.
- The engine reads included builds' sources in a second pass, since only
the settings say where they are; a symlinked or non-text one there is
unreadable.
We reviewed changes in 00a6c99...0fb8ff1 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
The reason will be displayed to describe this comment to others. Learn more.
Use of `unwrap_or` followed by function call, prefer `unwrap_or_else` instead
Calls to unwrap_or followed by a function call should be replaced with unwrap_or_else or unwrap_or_default, to increase laziness. The argument to unwrap_or is evaluated eagerly and unconditionally. unwrap_or_else or unwrap_or_default are evaluated lazily and only if required, sometimes
leading to lower overhead and fewer allocations.
…ed builds
From review of the first version:
- Maven: POMs a module or a parent's relativePath names, and settings or
a POM .mvn/maven.config names (-s, -gs, -f in every form commons-cli
takes), are fetched and scanned; a required one that is missing fails.
A *settings.xml that looks like Maven's but does not parse fails rather
than being skipped.
- Gradle: build logic is read as a worklist from the scripts and
build-logic folders through every build included and script applied.
apply from takes a plain string, file(...), rootProject.file(...), or
a path under $rootDir or $projectDir; anything else, and includeBuild
outside a settings script or with a computed name, fails. Kotlin raw
strings take no escapes, backtick names (`maven-publish`) are names,
and templates mark a string as computed.
- A symlinked .mvn or build-logic folder is unreadable.
- The engine reads what the files name until they name nothing new.
The reason will be displayed to describe this comment to others. Learn more.
Called `.chars().filter(..)` when `.matches(..)` would suffice
Using .chars().filter(..) requires additional logic and complexity compared to using .matches(..)
Using matches(..) allows for much greater flexibility such as using Pattern trait bound types,
and matching string expressions directly.
- Gradle scripts anywhere are build logic, except fixtures in a source
set's test or resource folder, so a project under a folder named src is
read.
- A backticked plain name (`maven`) stays code; a quoted repository call
('maven' { … }) fails; Java sources take no templates or slashy strings.
- An apply that names from any other way (apply(mapOf("from" to …)),
apply to: p, from: …) fails. A plain apply-from path resolves against
the project's folder, and $rootDir in buildSrc is buildSrc.
- Maven: a module or parent named without .xml can be a file or a folder;
text split by comments is read whole; flags run together before -s, -gs
or -f are read; Maven 4 subprojects are followed.
- No panic on a non-ASCII character before from.
- A source set is a test fixture by its name (test, testFixtures,
functionalTest), not by containing "test" (latest, contest).
- buildSrc's own scripts use buildSrc as $rootDir; its plugins run in
the main build and use the main root.
- A .apply { … } on an object, or a method named apply, is not Gradle's
apply.
- Maven: only repository, pluginRepository and mirror elements in their
lists count, not a plugin setting named repository.
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
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.
Fourth per-ecosystem fix from the registry audit, after Bundler (#168), Composer (#170) and NuGet (#171). Maven and Gradle looked every artifact up on Maven Central (or Google's repository for Android groups), so an artifact from a private repository could be looked up there.
Why the rule is coarse
Neither Maven nor Gradle records which repository served an artifact: no lockfile has it, and Gradle's lockfile and verification metadata hold versions and checksums only. Both try repositories in order and take the first hit, and Gradle adds content filters on top. Following that would mean re-implementing their resolution. So the Count over-counts: any repository besides Maven Central, Google's and the Gradle Plugin Portal anywhere in the build fails every lookup of that build system. Private Maven repositories aren't read yet anyway, as for the other ecosystems.
For comparison, Renovate merges the version lists of every repository it finds, which is the dependency-confusion pattern this avoids. It also drops repositories it can't parse.
Maven
pom.xml:repository,pluginRepositoryandsnapshotRepository, in any profile. Ones underdistributionManagementdon't count, since that's where a project deploys, not where it resolves from.*settings.xmlwhose root is<settings>:mirrors and repositories..mvn/maven.confignaming-s/-gssettings the Count doesn't read fails.${repo.url}, or a POM the Count can't parse or read, fails.Gradle
buildSrc,build-logic,build-conventionsandgradle/plugins, and the sources of every build the settings include.${ … }templates stays code, and Groovy slashy and dollar-slashy strings are handled. Kafka's real build needed both.mavenCentral(),google(),gradlePluginPortal()andjcenter().maven,ivy,flatDir,mavenLocal,exclusiveContent, or anything mentioningArtifactRepository/RepositoryHandler, outside apublishing { }block;apply froma URL;includeBuildwhose folder has no files;Tests
api-checkerbuild isn't in the corpus, so the Kafka check allows that one reason.Docs: sources.md (package registries), compatibility.md, and departures.md (new
#maven-repositories).Policy: visible evidence
Decided with the maintainer. Lookups fail when committed build files show another repository. Repositories added only by Gradle plugins (e.g. JFrog Artifactory), Maven build extensions, init scripts or a CI machine's own settings aren't in the repository's files, so the Count doesn't see them. Maven Central and the Gradle Plugin Portal verify namespace ownership, which keeps someone else from publishing a private group's coordinates there. A private coordinate's name can still reach Central in a lookup.
Follow-ups
Repositories in remote parent POMs or imported BOMs aren't read.
mavenCentral { url = … }ormavenCentral().setUrl(…), which retarget a public repository, aren't detected.An included build's sources are fetched one blob per file on the GitHub path, which is costly for a large included build.
Regex extractors with
source = mavenskip this check, as for the other ecosystems.Further ways Gradle build logic can name a repository that the scan does not recognise, e.g. multi-line
applycalls or repositories named through variables in plugin code. Under the visible-evidence policy these are accepted as unseen.