Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update parser #362

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/checkmarx/ast/scan/Scan.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Scan extends CxBaseObject {
String branch;

@JsonCreator
public Scan(@JsonProperty("ID") String id, @JsonProperty("ProjectID") String projectId,
public Scan(@JsonProperty(value = "ID", required = true) String id, @JsonProperty(value = "ProjectID", required = true) String projectId,
@JsonProperty("Status") String status, @JsonProperty("CreatedAt") String createdAt,
@JsonProperty("UpdatedAt") String updatedAt, @JsonProperty("Tags") Map<String, String> tags,
@JsonProperty("Initiator") String initiator, @JsonProperty("Origin") String origin,
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/checkmarx/ast/wrapper/CxBaseObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.json.JsonMapper;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -39,9 +42,12 @@ public static <T> T parse(String line, JavaType type) {
T result = null;
if (!StringUtils.isBlank(line) && isValidJSON(line)) {
try {
result = new ObjectMapper().readValue(line, type);
ObjectMapper mapper = JsonMapper.builder()
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
.build();
result = mapper.readValue(line, type);
} catch (JsonProcessingException e) {
e.printStackTrace();
//e.printStackTrace();
}
}
return result;
Expand Down
17 changes: 1 addition & 16 deletions src/main/java/com/checkmarx/ast/wrapper/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ static <T> T executeCommand(List<String> arguments,
stringBuilder.append(line).append(LINE_SEPARATOR);
T parsedLine = lineParser.apply(line);
if (parsedLine != null) {
if (areAllFieldsNotNull(parsedLine)) {
executionResult = parsedLine;
}
executionResult = parsedLine;
}
}
process.waitFor();
Expand All @@ -62,19 +60,6 @@ static <T> T executeCommand(List<String> arguments,
}
}

private static boolean areAllFieldsNotNull(Object obj) {
for (Field field : obj.getClass().getDeclaredFields()) {
field.setAccessible(true);
try {
if (field.get(obj) == null) {
return false;
}
} catch (IllegalAccessException e) {
return false;
}
}
return true;
}
static String executeCommand(List<String> arguments,
Logger logger,
String directory,
Expand Down
Loading