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

Please exclude -alpha, -beta, -rc, -preview, -SNAPSHOT from possibly latest versions of a component #3579

Open
2 tasks done
markusmuellerusi opened this issue Mar 25, 2024 · 0 comments
Labels
defect Something isn't working in triage

Comments

@markusmuellerusi
Copy link

Current Behavior

-alpha, -beta, -rc, -preview, -SNAPSHOT should never be displayed or handled as latest version. They are not stable.

Sample:
image

Steps to Reproduce

  1. Upload and analyse an SBoM, where the latest available version in repository is a alpha, beta, rc, preview or snapshot
  2. Analyse the project component (done in step 1)
  3. Verify my succested code snippet.

Expected Behavior

Please skip these versions in function findLatestVersion.

Sample code:

private String findLatestVersion(JSONArray versions) {
    if (versions.length() < 1) {
        return null;
    }

    ComparableVersion latestVersion = null;
    for (int i = 0; i < versions.length(); i++) {

        String version = versions.getString(i);
        if (version == null || version.trim().length() == 0 ||
                version.trim().toLowerCase().contains("-alfa") ||
                version.trim().toLowerCase().contains("-alpha") ||
                version.trim().toLowerCase().contains("-beta") ||
                version.trim().toLowerCase().contains("-snapshot") ||
                version.trim().toLowerCase().contains("-rc") ||
                version.trim().toLowerCase().contains("-preview")) {
            continue;
        }

        ComparableVersion comparableVersion = new ComparableVersion(version);
        if (latestVersion == null) {
            latestVersion = comparableVersion;
        }
        else if (comparableVersion.compareTo(latestVersion) > 0) {
            latestVersion = comparableVersion;
        }
    }

    if (latestVersion == null) {
        return null;
    }

    return latestVersion.toString();
}

Dependency-Track Version

4.10.1

Dependency-Track Distribution

Executable WAR

Database Server

Microsoft SQL Server

Database Server Version

No response

Browser

Microsoft Edge

Checklist

@markusmuellerusi markusmuellerusi added defect Something isn't working in triage labels Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something isn't working in triage
Projects
None yet
Development

No branches or pull requests

1 participant