Skip to content

Commit 29e21c4

Browse files
Merge pull request #164 from Checkmarx/fix/elchanan/quotes-display
Clean html description (AST-40454)
2 parents 8c37751 + 1572ac0 commit 29e21c4

2 files changed

Lines changed: 86 additions & 24 deletions

File tree

  • checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui
  • checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views

checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BaseUITest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public static void beforeClass() throws Exception {
5858
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
5959

6060
// Used to decrease tests velocity
61-
SWTBotPreferences.PLAYBACK_DELAY = 100;
61+
SWTBotPreferences.PLAYBACK_DELAY = 500;
6262

63-
SWTBotPreferences.TIMEOUT = 8000;
63+
SWTBotPreferences.TIMEOUT = 20000;
6464

6565
_bot = new SWTWorkbenchBot();
6666

@@ -205,11 +205,11 @@ protected static void waitWhileTreeNodeEqualsTo(String nodeText) throws TimeoutE
205205

206206
while (_bot.tree().getAllItems()[0].getText().equals(nodeText)) {
207207

208-
if (retryIdx == 10) {
208+
if (retryIdx == 20) {
209209
break;
210210
}
211211

212-
_bot.sleep(1000);
212+
_bot.sleep(1500);
213213

214214
retryIdx++;
215215
}
@@ -238,7 +238,7 @@ protected static void waitUntilBranchComboIsEnabled() throws TimeoutException {
238238

239239
while (!_bot.comboBox(1).isEnabled()) {
240240

241-
if (retryIdx == 10) {
241+
if (retryIdx == 15) {
242242
break;
243243
}
244244

checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/DataProvider.java

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -366,33 +366,95 @@ private List<DisplayModel> addResults(String scanId, Map<String, List<DisplayMod
366366
return returnList;
367367
}
368368

369+
370+
/**
371+
* Creates a clean Result object with decoded HTML entities
372+
*
373+
* @param resultItem Original result object
374+
* @return New Result object with cleaned values
375+
*/
376+
private Result createCleanResult(Result resultItem) {
377+
String cleanDescription = resultItem.getDescription() != null ?
378+
cleanHtmlEntities(resultItem.getDescription()) : null;
379+
380+
String cleanDescriptionHTML = resultItem.getDescriptionHTML() != null ?
381+
cleanHtmlEntities(resultItem.getDescriptionHTML()) : null;
382+
383+
return new Result(
384+
resultItem.getType(),
385+
resultItem.getLabel(),
386+
resultItem.getId(),
387+
resultItem.getSimilarityId(),
388+
resultItem.getStatus(),
389+
resultItem.getState(),
390+
resultItem.getSeverity(),
391+
resultItem.getCreated(),
392+
resultItem.getFirstFoundAt(),
393+
resultItem.getFoundAt(),
394+
resultItem.getFirstScan(),
395+
resultItem.getFirstScanId(),
396+
resultItem.getPublishedAt(),
397+
resultItem.getRecommendations(),
398+
cleanDescription,
399+
cleanDescriptionHTML,
400+
resultItem.getData(),
401+
resultItem.getComments(),
402+
resultItem.getVulnerabilityDetails(),
403+
resultItem.getScaType()
404+
);
405+
}
406+
407+
/**
408+
* Helper method to clean HTML entities from text
409+
*
410+
* @param input String containing HTML entities
411+
* @return Cleaned string with decoded HTML entities
412+
*/
413+
private String cleanHtmlEntities(String input) {
414+
if (input == null) return null;
415+
return input
416+
.replace("&#34;", "\"")
417+
.replace("&quot;", "\"")
418+
.replace("&#39;", "'")
419+
.replace("&#35;", "#")
420+
.replace("&#38;", "&")
421+
.replace("&lt;", "<")
422+
.replace("&gt;", ">");
423+
}
424+
369425
/**
370426
* Creates a Display Model which represents each result
371-
*
372-
* @param resultItem
373-
* @return
427+
*
428+
* @param resultItem Result object to transform
429+
* @return DisplayModel representing the result
374430
*/
375431
private DisplayModel transform(Result resultItem) {
376-
List<Node> nodes = Optional.ofNullable(resultItem.getData().getNodes()).orElse(Collections.emptyList());
377-
String queryName = resultItem.getData().getQueryName() != null ? resultItem.getData().getQueryName() : resultItem.getSimilarityId();
378-
String displayName = queryName;
379-
if (nodes.size() > 0) {
380-
Node node = nodes.get(0);
381-
displayName += String.format(" (%s:%d)", new File(node.getFileName()).getName(), node.getLine());
382-
}
383-
384-
return new DisplayModel.DisplayModelBuilder(displayName)
385-
.setSeverity(resultItem.getSeverity())
386-
.setType(resultItem.getType())
387-
.setResult(resultItem)
388-
.setSate(resultItem.getState())
389-
.setQueryName(queryName)
390-
.build();
432+
List<Node> nodes = Optional.ofNullable(resultItem.getData().getNodes()).orElse(Collections.emptyList());
433+
434+
Result cleanResult = createCleanResult(resultItem);
435+
436+
String queryName = cleanResult.getData().getQueryName() != null ?
437+
cleanResult.getData().getQueryName() :
438+
cleanResult.getSimilarityId();
439+
440+
String displayName = queryName;
441+
if (nodes.size() > 0) {
442+
Node node = nodes.get(0);
443+
displayName += String.format(" (%s:%d)", new File(node.getFileName()).getName(), node.getLine());
444+
}
445+
446+
return new DisplayModel.DisplayModelBuilder(displayName)
447+
.setSeverity(cleanResult.getSeverity())
448+
.setType(cleanResult.getType())
449+
.setResult(cleanResult)
450+
.setSate(cleanResult.getState())
451+
.setQueryName(queryName)
452+
.build();
391453
}
392454

393455
/**
394456
* Group results by scanner type
395-
*
457+
*
396458
* @param allResultsTransformed
397459
* @return
398460
*/

0 commit comments

Comments
 (0)