All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.snyk.snyk_maven_plugin.download.CLIVersions Maven / Gradle / Ivy

Go to download

Tests and monitors your Maven dependencies for vulnerabilities. This plugin is officially maintained by Snyk.io

The newest version!
package io.snyk.snyk_maven_plugin.download;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CLIVersions {
    public static final String STABLE_VERSION_KEYWORD = "stable";

    static final Pattern versionRegex = Pattern.compile("^(?:\\d+\\.){2}\\d+$");

    private static boolean isValidCLIVersion(String versionToCheck) {
        Matcher versionMatcher = CLIVersions.versionRegex.matcher(versionToCheck);
        return versionMatcher.matches();
    }

    public static String sanitize(String version) {
        if (!isValidCLIVersion(version)) {
            throw new IllegalArgumentException("Invalid Snyk CLI version. It should be a valid semver e.g. 1.489.0");
        }
        return getCDNVersion(version);
    }

    public static String getCDNVersion(String version) {
        return "v" + version;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy