Skip to content

Commit

Permalink
Merge branch 'main' into check_pipline
Browse files Browse the repository at this point in the history
  • Loading branch information
elchananarb authored Dec 4, 2024
2 parents fd6eb34 + 257cff5 commit cd014a0
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ast-cli-java-wrapper.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.3
2.1.4
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public static void beforeClass() throws Exception {
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";

// Used to decrease tests velocity
SWTBotPreferences.PLAYBACK_DELAY = 100;
SWTBotPreferences.PLAYBACK_DELAY = 500;

SWTBotPreferences.TIMEOUT = 8000;
SWTBotPreferences.TIMEOUT = 20000;

_bot = new SWTWorkbenchBot();

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

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

if (retryIdx == 10) {
if (retryIdx == 20) {
break;
}

_bot.sleep(1000);
_bot.sleep(1500);

retryIdx++;
}
Expand Down Expand Up @@ -238,7 +238,7 @@ protected static void waitUntilBranchComboIsEnabled() throws TimeoutException {

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

if (retryIdx == 10) {
if (retryIdx == 15) {
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,33 +366,95 @@ private List<DisplayModel> addResults(String scanId, Map<String, List<DisplayMod
return returnList;
}


/**
* Creates a clean Result object with decoded HTML entities
*
* @param resultItem Original result object
* @return New Result object with cleaned values
*/
private Result createCleanResult(Result resultItem) {
String cleanDescription = resultItem.getDescription() != null ?
cleanHtmlEntities(resultItem.getDescription()) : null;

String cleanDescriptionHTML = resultItem.getDescriptionHTML() != null ?
cleanHtmlEntities(resultItem.getDescriptionHTML()) : null;

return new Result(
resultItem.getType(),
resultItem.getLabel(),
resultItem.getId(),
resultItem.getSimilarityId(),
resultItem.getStatus(),
resultItem.getState(),
resultItem.getSeverity(),
resultItem.getCreated(),
resultItem.getFirstFoundAt(),
resultItem.getFoundAt(),
resultItem.getFirstScan(),
resultItem.getFirstScanId(),
resultItem.getPublishedAt(),
resultItem.getRecommendations(),
cleanDescription,
cleanDescriptionHTML,
resultItem.getData(),
resultItem.getComments(),
resultItem.getVulnerabilityDetails(),
resultItem.getScaType()
);
}

/**
* Helper method to clean HTML entities from text
*
* @param input String containing HTML entities
* @return Cleaned string with decoded HTML entities
*/
private String cleanHtmlEntities(String input) {
if (input == null) return null;
return input
.replace("&#34;", "\"")
.replace("&quot;", "\"")
.replace("&#39;", "'")
.replace("&#35;", "#")
.replace("&#38;", "&")
.replace("&lt;", "<")
.replace("&gt;", ">");
}

/**
* Creates a Display Model which represents each result
*
* @param resultItem
* @return
*
* @param resultItem Result object to transform
* @return DisplayModel representing the result
*/
private DisplayModel transform(Result resultItem) {
List<Node> nodes = Optional.ofNullable(resultItem.getData().getNodes()).orElse(Collections.emptyList());
String queryName = resultItem.getData().getQueryName() != null ? resultItem.getData().getQueryName() : resultItem.getSimilarityId();
String displayName = queryName;
if (nodes.size() > 0) {
Node node = nodes.get(0);
displayName += String.format(" (%s:%d)", new File(node.getFileName()).getName(), node.getLine());
}

return new DisplayModel.DisplayModelBuilder(displayName)
.setSeverity(resultItem.getSeverity())
.setType(resultItem.getType())
.setResult(resultItem)
.setSate(resultItem.getState())
.setQueryName(queryName)
.build();
List<Node> nodes = Optional.ofNullable(resultItem.getData().getNodes()).orElse(Collections.emptyList());

Result cleanResult = createCleanResult(resultItem);

String queryName = cleanResult.getData().getQueryName() != null ?
cleanResult.getData().getQueryName() :
cleanResult.getSimilarityId();

String displayName = queryName;
if (nodes.size() > 0) {
Node node = nodes.get(0);
displayName += String.format(" (%s:%d)", new File(node.getFileName()).getName(), node.getLine());
}

return new DisplayModel.DisplayModelBuilder(displayName)
.setSeverity(cleanResult.getSeverity())
.setType(cleanResult.getType())
.setResult(cleanResult)
.setSate(cleanResult.getState())
.setQueryName(queryName)
.build();
}

/**
* Group results by scanner type
*
*
* @param allResultsTransformed
* @return
*/
Expand Down

0 comments on commit cd014a0

Please sign in to comment.