java.lang.Object
io.github.nscuro.versatile.VersUtils
-
Method Summary
Modifier and TypeMethodDescriptionschemeFromGhsaEcosystem(String ecosystem) schemeFromOsvEcosystem(String ecosystem) static VersversFromGhsaRange(String ecosystem, String rangeExpr) Convert an ecosystem and version range as used by GitHub Security Advisories to aVersrange.versFromNvdRange(String versionStartExcluding, String versionStartIncluding, String versionEndExcluding, String versionEndIncluding, String exactVersion) Convert ranges or exact version as used by NVD to aVersrange.static VersversFromOsvRange(String type, String ecosystem, List<Map.Entry<String, String>> events, Map<String, Object> databaseSpecific) Convert a range type, ecosystem, and range events as used by OSV to aVersrange.
-
Method Details
-
versFromGhsaRange
Convert an ecosystem and version range as used by GitHub Security Advisories to aVersrange.Ranges are composed of one or more constraints, separated by commas. Valid comparators for constraints are
=,>=,>,<, and<=. For example, a valid range is>= 1.2.3, < 5.0.1.- Parameters:
ecosystem- The ecosystem of the affected packagerangeExpr- The affected version range expression- Returns:
- The resulting
Vers - Throws:
IllegalArgumentException- When the provided range expression is invalidVersException- When the producedVersis invalidInvalidVersionException- When any version in the range is invalid according to the inferred scheme- See Also:
-
versFromOsvRange
public static Vers versFromOsvRange(String type, String ecosystem, List<Map.Entry<String, String>> events, Map<String, Object> databaseSpecific) Convert a range type, ecosystem, and range events as used by OSV to aVersrange.- Parameters:
type- The type of the range, must be eitherECOSYSTEMorSEMVERecosystem- The ecosystem of the affected packageevents- The events in the range- Returns:
- The resulting
Vers - Throws:
IllegalArgumentException- When the provided range type is not support supported, or the providedeventscontains an invalid eventVersException- When the producedVersis invalidInvalidVersionException- When any version in the range is invalid according to the inferred scheme
-
versFromNvdRange
public static Optional<Vers> versFromNvdRange(String versionStartExcluding, String versionStartIncluding, String versionEndExcluding, String versionEndIncluding, String exactVersion) Convert ranges or exact version as used by NVD to aVersrange.- Parameters:
versionStartExcluding- The versionStartExcluding in the rangeversionStartIncluding- The versionStartIncluding in the rangeversionEndExcluding- The versionEndExcluding in the rangeversionEndIncluding- The versionEndIncluding in the rangeexactVersion- The exact version in CpeMatch- Returns:
- An
Optionalcontaining the resultingVers, orOptional.empty()when no constraints could be inferred from the given parameters - Throws:
IllegalArgumentException- When the provided cpe match is invalid, or the providedeventscontains an invalid eventVersException- When the producedVersis invalidInvalidVersionException- When any version in the range is invalid according to the inferred scheme
-
schemeFromGhsaEcosystem
-
schemeFromOsvEcosystem
-