apache / apache/maven-shared-jar

pickSmallest/pickLargest heuristics in JarIdentificationAnalysis may select wrong values

Open
#145 0 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
4
Forks
9
Avg merge
2h 46m
Merged PRs (30d)
3

Description

In `JarIdentificationAnalysis.java:78-105`, the `normalize()` method uses `pickSmallest()` to select the version and `pickLargest()` to select artifactId/name/vendor:

```java
private String pickSmallest(List values) {
String result = null;
for (String value : values) {
if (result == null || value.length() < result.length()) {
result = value;
}
}
return result;
}

private String pickLargest(List values) {
String result = null;
for (String value : values) {
if (result == null || value.length() > result.length()) {
result = value;
}
}
return result;
}
```

These are arbitrary string-length-based heuristics:
- **For version**: `pickSmallest()` selects the shortest string. For example, `"1.0"` (3 chars) would be chosen over `"1.0.3"` (5 chars) or `"20030519"` (8 chars), potentially discarding the actual version.
- **For artifactId**: `pickLargest()` selects the longest match, which may pick the most qualified but potentially incorrect name.

These heuristics can produce wrong results when multiple candidate values are identified from different sources. A more robust approach would be needed for reliable identification.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading JarIdentificationAnalysis.java:78-105, focusing on normalize(), pickSmallest(), and pickLargest(). Trace how candidate values from different sources are selected, then define and verify a reliable selection strategy that preserves the correct version, artifactId, name, and vendor values.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.