• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 19481956452

18 Nov 2025 10:06PM UTC coverage: 69.044% (+0.1%) from 68.905%
19481956452

Pull #1593

github

web-flow
Merge b71c405c9 into 553958662
Pull Request #1593: #1144: #1145: CVE warnings and suggestions

3570 of 5669 branches covered (62.97%)

Branch coverage included in aggregate %.

9308 of 12983 relevant lines covered (71.69%)

3.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
cli/src/main/java/com/devonfw/tools/ide/url/model/file/json/ToolSecurity.java
1
package com.devonfw.tools.ide.url.model.file.json;
2

3
import java.io.BufferedReader;
4
import java.nio.file.Files;
5
import java.nio.file.Path;
6
import java.util.ArrayList;
7
import java.util.Collection;
8
import java.util.Collections;
9
import java.util.List;
10
import java.util.function.Predicate;
11

12
import com.devonfw.tools.ide.json.JsonMapping;
13
import com.devonfw.tools.ide.variable.IdeVariables;
14
import com.devonfw.tools.ide.version.VersionIdentifier;
15
import com.devonfw.tools.ide.version.VersionRange;
16
import com.fasterxml.jackson.databind.ObjectMapper;
17

18
/**
19
 * Container representing data from the "security.json" file with all {@link Cve CVE}s of a specific tool.
20
 *
21
 * @see com.devonfw.tools.ide.url.model.file.UrlSecurityFile
22
 */
23
public class ToolSecurity {
24

25
  private static final ObjectMapper MAPPER = JsonMapping.create();
2✔
26

27
  private static final ToolSecurity EMPTY = new ToolSecurity(Collections.emptyList());
6✔
28

29
  private List<Cve> issues;
30

31
  /**
32
   * The constructor.
33
   */
34
  public ToolSecurity() {
35
    this(new ArrayList<>());
5✔
36
  }
1✔
37

38
  /**
39
   * The constructor.
40
   *
41
   * @param issues the {@link List} of {@link Cve CVE}s.
42
   */
43
  public ToolSecurity(List<Cve> issues) {
44

45
    super();
2✔
46
    this.issues = issues;
3✔
47
  }
1✔
48

49
  /**
50
   * @return the list of CVEs
51
   */
52
  public List<Cve> getIssues() {
53
    return issues;
3✔
54
  }
55

56
  /**
57
   * @param issues the list of CVEs
58
   */
59
  public void setIssues(List<Cve> issues) {
60
    this.issues = issues;
3✔
61
  }
1✔
62

63
  /**
64
   * Finds all {@link Cve}s for the given {@link VersionIdentifier} that also match the given {@link Predicate}.
65
   *
66
   * @param version the {@link VersionIdentifier} to check.
67
   * @param predicate the {@link Predicate} deciding which matching {@link Cve}s are {@link Predicate#test(Object) accepted}.
68
   * @return all {@link Cve}s for the given {@link VersionIdentifier}.
69
   */
70
  public Collection<Cve> findCves(VersionIdentifier version, Predicate<Cve> predicate) {
71
    List<Cve> cvesOfVersion = new ArrayList<>();
4✔
72
    for (Cve cve : this.issues) {
11✔
73
      for (VersionRange range : cve.versions()) {
11✔
74
        if (range.contains(version) && predicate.test(cve)) {
8!
75
          cvesOfVersion.add(cve);
4✔
76
        }
77
      }
1✔
78
    }
1✔
79
    return cvesOfVersion;
2✔
80
  }
81

82
  /**
83
   * Finds all {@link Cve}s for the given {@link VersionIdentifier} and {@code minSeverity}.
84
   *
85
   * @param version the {@link VersionIdentifier} to check.
86
   * @param minSeverity the {@link IdeVariables#CVE_MIN_SEVERITY minimum severity}.
87
   * @return all {@link Cve}s for the given {@link VersionIdentifier}.
88
   */
89
  public Collection<Cve> findCves(VersionIdentifier version, double minSeverity) {
90
    return findCves(version, cve -> cve.severity() >= minSeverity);
14!
91
  }
92

93
  /**
94
   * @param file the {@link Path} to the JSON file to load.
95
   * @return the loaded {@link ToolSecurity} or the {@link #getEmpty() empty instance} if given {@link Path} does not exist.
96
   */
97
  public static ToolSecurity of(Path file) {
98

99
    if (Files.exists(file)) {
5!
100
      try (BufferedReader reader = Files.newBufferedReader(file)) {
3✔
101
        return MAPPER.readValue(reader, ToolSecurity.class);
8✔
102
      } catch (Exception e) {
×
103
        throw new IllegalStateException("Failed to load " + file, e);
×
104
      }
105
    } else {
106
      return EMPTY;
×
107
    }
108
  }
109

110
  /**
111
   * @return the empty instance of {@link ToolSecurity}.
112
   */
113
  public static ToolSecurity getEmpty() {
114

115
    return EMPTY;
2✔
116
  }
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc