mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-02-24 11:25:17 +01:00
On VulnerableSoftware changed implementation of compare to support
version in the format of 3b that is now splitted in 3 and b. Before the versions "5.0.3a", "5.0.9" and "5.0.30" were not correctly comparable. See VulnerableSoftwareTest.testVersionsWithLettersComparison. This issue can cause a runtime exception during sort
This commit is contained in:
@@ -174,4 +174,25 @@ public class VulnerableSoftwareTest extends BaseTest {
|
||||
assertFalse(VulnerableSoftware.isPositiveInteger("01"));
|
||||
assertFalse(VulnerableSoftware.isPositiveInteger("00"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVersionsWithLettersComparison() {
|
||||
VulnerableSoftware a = new VulnerableSoftware();
|
||||
a.setName("cpe:/a:mysql:mysql:5.0.3a");
|
||||
|
||||
VulnerableSoftware b = new VulnerableSoftware();
|
||||
b.setName("cpe:/a:mysql:mysql:5.0.9");
|
||||
|
||||
VulnerableSoftware c = new VulnerableSoftware();
|
||||
c.setName("cpe:/a:mysql:mysql:5.0.30");
|
||||
|
||||
assertTrue(a.compareTo(b) < 0);
|
||||
assertTrue(a.compareTo(c) < 0);
|
||||
|
||||
assertTrue(b.compareTo(a) > 0);
|
||||
assertTrue(b.compareTo(c) < 0);
|
||||
|
||||
assertTrue(c.compareTo(a) > 0);
|
||||
assertTrue(c.compareTo(b) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user