public override bool IsVulnerabilityVersionInPackageVersionRange(string vulnerability_version, string package_version) { string message = ""; bool r = NuGetv2.RangeIntersect(vulnerability_version, package_version, out message); if (!r && !string.IsNullOrEmpty(message)) { throw new Exception(message); } else { return(r); } }
public void CanRangeIntersect() { string e; Assert.True(NuGetv2.RangeIntersect("4.5.7", "(2.4, 6.1.3-alpha5]", out e)); Assert.False(NuGetv2.RangeIntersect("4.5.7", "(4.5.7, 6.1.3-alpha5]", out e)); Assert.True(NuGetv2.RangeIntersect("4.5.7", "[4.5.7, 6.1.3-alpha5]", out e)); Assert.True(NuGetv2.RangeIntersect("(5.5,]", "(2.4, 6.1.3-alpha5]", out e)); Assert.True(NuGetv2.RangeIntersect("(11, 11.9)", "(11, 11.3.0-beta7]", out e)); Assert.True(NuGetv2.RangeIntersect("(11, 13.3.0-beta7]", "12", out e)); Assert.False(NuGetv2.RangeIntersect("(11, 13.3.0-beta7]", "13.4", out e)); Assert.True(NuGetv2.RangeIntersect("3.4.0199", ">= 0.0.0", out e)); Assert.False(NuGetv2.RangeIntersect("1.3.0", ">=1.2.19 <1.2.24", out e)); Assert.False(NuGetv2.RangeIntersect("1.3.0", ">1.3.0-beta.1 <1.3.0-beta.14", out e)); Assert.True(NuGetv2.RangeIntersect("1.3.0", ">1.3.0-beta.14.4 <1.4.0-beta.2", out e)); Assert.True(NuGetv2.RangeIntersect("5.1", "4.4, 6.3,5.1", out e)); Assert.False(NuGetv2.RangeIntersect("5.1", "5.4,6.3, 5.0", out e)); }