java.lang.Object
io.github.nscuro.versatile.VersUtils

public final class VersUtils extends Object
  • Method Details

    • versFromGhsaRange

      public static Vers versFromGhsaRange(String ecosystem, String rangeExpr)
      Convert an ecosystem and version range as used by GitHub Security Advisories to a Vers range.

      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 package
      rangeExpr - The affected version range expression
      Returns:
      The resulting Vers
      Throws:
      IllegalArgumentException - When the provided range expression is invalid
      VersException - When the produced Vers is invalid
      InvalidVersionException - 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 a Vers range.
      Parameters:
      type - The type of the range, must be either ECOSYSTEM or SEMVER
      ecosystem - The ecosystem of the affected package
      events - The events in the range
      Returns:
      The resulting Vers
      Throws:
      IllegalArgumentException - When the provided range type is not support supported, or the provided events contains an invalid event
      VersException - When the produced Vers is invalid
      InvalidVersionException - 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 a Vers range.
      Parameters:
      versionStartExcluding - The versionStartExcluding in the range
      versionStartIncluding - The versionStartIncluding in the range
      versionEndExcluding - The versionEndExcluding in the range
      versionEndIncluding - The versionEndIncluding in the range
      exactVersion - The exact version in CpeMatch
      Returns:
      An Optional containing the resulting Vers, or Optional.empty() when no constraints could be inferred from the given parameters
      Throws:
      IllegalArgumentException - When the provided cpe match is invalid, or the provided events contains an invalid event
      VersException - When the produced Vers is invalid
      InvalidVersionException - When any version in the range is invalid according to the inferred scheme
    • schemeFromGhsaEcosystem

      public static Optional<String> schemeFromGhsaEcosystem(String ecosystem)
    • schemeFromOsvEcosystem

      public static Optional<String> schemeFromOsvEcosystem(String ecosystem)