-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCxIac.ts
More file actions
52 lines (50 loc) · 2.09 KB
/
CxIac.ts
File metadata and controls
52 lines (50 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {CxRealtimeEngineStatus} from "../oss/CxRealtimeEngineStatus";
export default class CxIacResult {
title: string;
description: string;
similarityID: string;
filepath: string;
severity: CxRealtimeEngineStatus;
expectedValue: string;
actualValue: string;
locations: { line: number, startIndex: number, endIndex: number }[];
static parseResult(resultObject: any): CxIacResult[] {
let iacResults: CxIacResult[] = [];
if (resultObject instanceof Array) {
iacResults = resultObject.map((member: any) => {
const iacResult = new CxIacResult();
iacResult.title = member.Title;
iacResult.description = member.Description;
iacResult.similarityID = member.SimilarityID;
iacResult.filepath = member.FilePath;
iacResult.severity = member.Severity as CxRealtimeEngineStatus;
iacResult.expectedValue = member.ExpectedValue;
iacResult.actualValue = member.ActualValue;
iacResult.locations = Array.isArray(member.Locations)
? member.Locations.map((l: any) => ({
line: l.Line,
startIndex: l.StartIndex,
endIndex: l.EndIndex,
}))
: [];
return iacResult;
});
} else {
const iacResult = new CxIacResult();
iacResult.title = resultObject.Title;
iacResult.description = resultObject.Description;
iacResult.severity = resultObject.Severity;
iacResult.filepath = resultObject.FilePath;
iacResult.filepath = resultObject.FilePath;
iacResult.locations = Array.isArray(resultObject.Locations)
? resultObject.Locations.map((l: any) => ({
line: l.Line,
startIndex: l.StartIndex,
endIndex: l.EndIndex,
}))
: [];
iacResults.push(iacResult);
}
return iacResults;
}
}