Skip to content

Commit 1389057

Browse files
committed
devonfw#103: fixed bugs
- fixed pom bug - fixed bug in BuildSecurityJsonFiles due to moved method that was introduced in the merge of main into this branch
1 parent 9b28679 commit 1389057

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

cli/src/test/java/com/devonfw/tools/ide/tool/ToolCommandletTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public void testSecurityRiskInteractionAllVersionAffectedBySingleWarning() {
4242
// then save this also to stay
4343
// extract method that calcs next safe, latest save
4444
// and introduce var named latest and make it to *
45-
assertThat(tool.securityRiskInteraction(VersionIdentifier.of("1"))).isEqualTo(VersionIdentifier.of("1"));
45+
46+
// the current version is safe, so no interaction needed and no answer is consumed
47+
VersionIdentifier currentVersion = VersionIdentifier.of("1");
48+
assertThat(tool.securityRiskInteraction(currentVersion)).isEqualTo(currentVersion);
49+
4650
// answer to the interaction is 1
4751
assertThat(tool.securityRiskInteraction(VersionIdentifier.of("2"))).isEqualTo(VersionIdentifier.of("2"));
4852
// answer to the interaction is 2

security/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<dependency>
2626
<groupId>com.devonfw.tools.IDEasy</groupId>
2727
<artifactId>ide-cli</artifactId>
28-
<version>2024.01.001-SNAPSHOT</version>
28+
<version>2024.02.001-alpha-SNAPSHOT</version>
2929
<scope>compile</scope>
3030
</dependency>
3131
</dependencies>

security/src/main/java/com/devonfw/tools/security/BuildSecurityJsonFiles.java

+21-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.Set;
1414
import java.util.stream.Collectors;
1515

16+
import com.devonfw.tools.ide.version.BoundaryType;
1617
import org.owasp.dependencycheck.Engine;
1718
import org.owasp.dependencycheck.analyzer.AbstractAnalyzer;
1819
import org.owasp.dependencycheck.analyzer.AnalysisPhase;
@@ -295,16 +296,28 @@ public static VersionRange getVersionRangeFromInterval(String si, String se, Str
295296
throw new IllegalStateException(
296297
"Vulnerability has no interval of affected versions or single affected version.");
297298
}
298-
return VersionRange.of(s + VersionRange.getVersionSeparator() + s);
299+
VersionIdentifier singleAffectedVersion = VersionIdentifier.of(s);
300+
return new VersionRange(singleAffectedVersion, singleAffectedVersion, BoundaryType.OPEN);
299301
}
300302

301-
String leftBoundary = se == null ? VersionRange.getStartIncludingPrefix() + Objects.toString(si, "")
302-
: VersionRange.getStartExcludingPrefix() + se;
303+
boolean leftExclusive = si == null;
304+
boolean rightExclusive = ei == null;
303305

304-
String rightBoundary = ee == null ? Objects.toString(ei, "") + VersionRange.getEndIncludingSuffix()
305-
: ee + VersionRange.getEndExcludingSuffix();
306+
VersionIdentifier min = null;
307+
if (si != null) {
308+
min = VersionIdentifier.of(si);
309+
} else if (se != null) {
310+
min = VersionIdentifier.of(se);
311+
}
312+
313+
VersionIdentifier max = null;
314+
if (ei != null) {
315+
max = VersionIdentifier.of(ei);
316+
} else if (ee != null) {
317+
max = VersionIdentifier.of(ee);
318+
}
306319

307-
return VersionRange.of(leftBoundary + VersionRange.getVersionSeparator() + rightBoundary);
320+
return new VersionRange(min, max, BoundaryType.of(leftExclusive, rightExclusive));
308321
}
309322

310323
private static void printAffectedVersions(IdeContext context) {
@@ -333,14 +346,14 @@ private static void printAffectedVersions(IdeContext context) {
333346
} else {
334347
if (min != null) {
335348
System.out.println("Tool " + tool.getName() + " with edition " + edition.getName() + " and versions "
336-
+ new VersionRange(min, version, false, true) + " are affected by vulnerabilities.");
349+
+ new VersionRange(min, version, BoundaryType.of(false, true)) + " are affected by vulnerabilities.");
337350
min = null;
338351
}
339352
}
340353
}
341354
if (min != null) {
342355
System.out.println("Tool " + tool.getName() + " with edition " + edition.getName() + " and versions "
343-
+ new VersionRange(min, null, false, true) + " are affected by vulnerabilities.");
356+
+ new VersionRange(min, null, BoundaryType.of(false, true)) + " are affected by vulnerabilities.");
344357
}
345358
}
346359
}

0 commit comments

Comments
 (0)