@@ -173,16 +173,6 @@ public boolean install(boolean silent) {
173
173
return doInstall (silent );
174
174
}
175
175
176
- protected String securityRiskInteractionQuestion (String question , String ... options ) {
177
-
178
- question += "Do you want to" ;
179
- for (int i = 0 ; i < options .length - 1 ; i ++) {
180
- options [i ] += " or" ;
181
- }
182
- options [options .length - 1 ] += "?" ;
183
- return this .context .question (question , options );
184
- }
185
-
186
176
/**
187
177
* Checks if the given {@link VersionIdentifier} has a matching security warning in the {@link UrlSecurityJsonFile}.
188
178
*
@@ -193,16 +183,10 @@ protected String securityRiskInteractionQuestion(String question, String... opti
193
183
*/
194
184
protected VersionIdentifier securityRiskInteraction (VersionIdentifier configuredVersion ) {
195
185
196
- // TODO maybe instead of returning current return configuredVersion if the users chooses "stay"
197
-
198
- // TODO webpage:\nhttps://github.com/devonfw/ide/blob/master/documentation/vulnerabilities.asciidoc\n\n";
199
-
200
186
UrlSecurityJsonFile securityFile = this .context .getUrls ().getEdition (this .tool , this .getEdition ())
201
187
.getSecurityJsonFile ();
202
188
203
189
VersionIdentifier current = this .context .getUrls ().getVersion (this .tool , this .getEdition (), configuredVersion );
204
- // TODO oder doch eher sowas wie VersionIdentifier resolvedVersion = toolRepository.resolveVersion(this.tool,
205
- // edition, selectedVersion); sollte immer das selbe ergeben
206
190
207
191
if (!securityFile .contains (current , true , this .context )) {
208
192
return configuredVersion ;
@@ -212,7 +196,6 @@ protected VersionIdentifier securityRiskInteraction(VersionIdentifier configured
212
196
VersionIdentifier latest = allVersions .get (0 );
213
197
214
198
int currentVersionIndex = allVersions .indexOf (current );
215
-
216
199
VersionIdentifier nextSafe = null ;
217
200
for (int i = currentVersionIndex - 1 ; i >= 0 ; i --) {
218
201
if (!securityFile .contains (allVersions .get (i ), true , this .context )) {
@@ -232,10 +215,12 @@ protected VersionIdentifier securityRiskInteraction(VersionIdentifier configured
232
215
String currentIsUnsafe = "Currently, version " + current + " of " + this .getName () + " is selected, "
233
216
+ "which is has one or more vulnerabilities:\n \n " + cves + "\n \n (See also " + securityFile .getPath () + ")\n \n " ;
234
217
235
- String stay = "stay with the current unsafe version (" + current + ")" ;
236
- String installLatestSafe = "install the latest safe version (" + latestSafe + ")" ;
237
- String installSafeLatest = "install the (safe) latest version (" + latest + ")" ;
238
- String installNextSafe = "install the next safe version (" + nextSafe + ")" ;
218
+ String ask = "Which version do you want to install?" ;
219
+
220
+ String stay = "Stay with the current unsafe version (" + current + ")." ;
221
+ String installLatestSafe = "Install the latest safe version (" + latestSafe + ")." ;
222
+ String installSafeLatest = "Install the (safe) latest version (" + latest + ")." ;
223
+ String installNextSafe = "Install the next safe version (" + nextSafe + ")." ;
239
224
// I don't need to offer "install latest which is unsafe" as option since the user can set to the latest and choose
240
225
// "stay"
241
226
@@ -245,38 +230,38 @@ protected VersionIdentifier securityRiskInteraction(VersionIdentifier configured
245
230
}
246
231
247
232
if (current .equals (latest )) {
248
- String answer = securityRiskInteractionQuestion (currentIsUnsafe + "There are no updates available." , stay ,
233
+ String answer = this . context . question (currentIsUnsafe + "There are no updates available. " + ask , stay ,
249
234
installLatestSafe );
250
- return answer .startsWith (stay ) ? current : latestSafe ;
235
+ return answer .equals (stay ) ? configuredVersion : latestSafe ;
251
236
252
- } else if (nextSafe == null ) {
253
- String answer = securityRiskInteractionQuestion (currentIsUnsafe + " All newer versions are also not safe." , stay ,
237
+ } else if (nextSafe == null ) { // install an older version that is safe or stay with the current unsafe version
238
+ String answer = this . context . question (currentIsUnsafe + " All newer versions are also not safe. " + ask , stay ,
254
239
installLatestSafe );
255
- return answer .startsWith (stay ) ? current : latestSafe ;
240
+ return answer .equals (stay ) ? configuredVersion : latestSafe ;
256
241
257
242
} else if (nextSafe .equals (latest )) {
258
- String answer = securityRiskInteractionQuestion (
259
- currentIsUnsafe + " Of the newer versions, only the latest is safe." , stay , installSafeLatest );
260
- return answer .startsWith (stay ) ? current : latestSafe ;
243
+ String answer = this . context . question ( currentIsUnsafe + " Of the newer versions, only the latest is safe. " + ask ,
244
+ stay , installSafeLatest );
245
+ return answer .equals (stay ) ? configuredVersion : VersionIdentifier . LATEST ;
261
246
262
247
} else if (nextSafe .equals (latestSafe )) {
263
- String answer = securityRiskInteractionQuestion (currentIsUnsafe + " Of the newer versions, only the version "
264
- + nextSafe + " is safe, Which is not the latest." , stay , "Install the safe version (" + nextSafe + ")" );
265
- return answer .startsWith (stay ) ? current : nextSafe ;
248
+ String answer = this .context .question (
249
+ currentIsUnsafe + " Of the newer versions, only the version " + nextSafe
250
+ + " is safe, which is however not the latest." + ask ,
251
+ stay , "Install the safe version (" + nextSafe + ")" );
252
+ return answer .equals (stay ) ? configuredVersion : nextSafe ;
266
253
267
254
} else {
268
255
if (latestSafe .equals (latest )) {
269
- String answer = securityRiskInteractionQuestion (currentIsUnsafe , stay , installNextSafe , installSafeLatest );
270
- return answer .startsWith (stay ) ? current : answer .startsWith (installNextSafe ) ? nextSafe : latestSafe ;
256
+ String answer = this .context .question (currentIsUnsafe + ask , stay , installNextSafe , installSafeLatest );
257
+ return answer .equals (stay ) ? configuredVersion
258
+ : answer .equals (installNextSafe ) ? nextSafe : VersionIdentifier .LATEST ;
271
259
272
260
} else {
273
- String answer = securityRiskInteractionQuestion (currentIsUnsafe , stay , installNextSafe , installLatestSafe );
274
- return answer .startsWith (stay ) ? current : answer .startsWith (installNextSafe ) ? nextSafe : latestSafe ;
261
+ String answer = this . context . question (currentIsUnsafe + ask , stay , installNextSafe , installLatestSafe );
262
+ return answer .equals (stay ) ? configuredVersion : answer .equals (installNextSafe ) ? nextSafe : latestSafe ;
275
263
}
276
264
}
277
-
278
- // VersionIdentifier chosenVersion = securityRiskInteraction(configuredVersion);
279
- // setVersion(chosenVersion, silent);
280
265
}
281
266
282
267
/**
0 commit comments