|
9 | 9 | import java.util.List;
|
10 | 10 | import java.util.Locale;
|
11 | 11 | import java.util.Map;
|
12 |
| -import java.util.Optional; |
| 12 | +import java.util.Objects; |
13 | 13 | import java.util.Set;
|
14 | 14 | import java.util.stream.Collectors;
|
15 | 15 |
|
|
59 | 59 | import com.devonfw.tools.ide.version.VersionRange;
|
60 | 60 |
|
61 | 61 | // TODO Doesn't yet work with versions defined like this /<tool>/<edition>/latest
|
| 62 | +// TODO Sometimes when running this class is takes a long time to finish. Maybe this is because of the OWASP package, which |
| 63 | +// is updating the vulnerabilities. A dirty fix is to stop the program and restart it. |
62 | 64 |
|
63 | 65 | /**
|
64 | 66 | * This class is used to build the {@link UrlSecurityJsonFile} files for IDEasy. It scans the
|
@@ -133,7 +135,7 @@ private static void run() {
|
133 | 135 | .map(VersionIdentifier::toString).toList();
|
134 | 136 | List<String> sortedCpeVersions = sortedVersions.stream().map(urlUpdater::mapUrlVersionToCpeVersion)
|
135 | 137 | .collect(Collectors.toList());
|
136 |
| - Map<String, String> cpeToUrlVersion = MapUtil.createMapWithLists(sortedCpeVersions, sortedVersions); |
| 138 | + Map<String, String> cpeToUrlVersion = MapUtil.createMapfromLists(sortedCpeVersions, sortedVersions); |
137 | 139 |
|
138 | 140 | Set<Vulnerability> vulnerabilities = dependency.getVulnerabilities(true);
|
139 | 141 | for (Vulnerability vulnerability : vulnerabilities) {
|
@@ -174,7 +176,8 @@ private static void addVulnerabilityToSecurityFile(Vulnerability vulnerability,
|
174 | 176 |
|
175 | 177 | if (vulnerability.getCvssV2() == null && vulnerability.getCvssV3() == null) {
|
176 | 178 | // TODO if this ever happens, add a case that handles this
|
177 |
| - throw new RuntimeException("Vulnerability without severity found: " + vulnerability.getName()); |
| 179 | + throw new RuntimeException("Vulnerability without severity found: " + vulnerability.getName() + "\\n" |
| 180 | + + " Please contact https://github.com/devonfw/IDEasy and make a request to get this feature implemented."); |
178 | 181 | }
|
179 | 182 | boolean hasV3Severity = vulnerability.getCvssV3() != null;
|
180 | 183 | double severityDouble = hasV3Severity ? vulnerability.getCvssV3().getBaseScore()
|
@@ -287,15 +290,11 @@ public static VersionRange getVersionRangeFromInterval(String si, String se, Str
|
287 | 290 | }
|
288 | 291 | return VersionRange.of(s + VersionRange.getVersionSeparator() + s);
|
289 | 292 | }
|
290 |
| - se = Optional.ofNullable(se).orElse(""); |
291 |
| - si = Optional.ofNullable(si).orElse(""); |
292 |
| - ee = Optional.ofNullable(ee).orElse(""); |
293 |
| - ei = Optional.ofNullable(ei).orElse(""); |
294 | 293 |
|
295 |
| - String leftBoundary = se.isEmpty() ? VersionRange.getStartIncludingPrefix() + si |
| 294 | + String leftBoundary = se == null ? VersionRange.getStartIncludingPrefix() + Objects.toString(si, "") |
296 | 295 | : VersionRange.getStartExcludingPrefix() + se;
|
297 | 296 |
|
298 |
| - String rightBoundary = ee.isEmpty() ? ei + VersionRange.getEndIncludingSuffix() |
| 297 | + String rightBoundary = ee == null ? Objects.toString(ei, "") + VersionRange.getEndIncludingSuffix() |
299 | 298 | : ee + VersionRange.getEndExcludingSuffix();
|
300 | 299 |
|
301 | 300 | return VersionRange.of(leftBoundary + VersionRange.getVersionSeparator() + rightBoundary);
|
|
0 commit comments