1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <unload unload_date =" 2023-06-27 13:49:35 " >
2
+ <unload unload_date =" 2023-09-05 08:40:21 " >
3
3
<sys_script_include action =" INSERT_OR_UPDATE" >
4
4
<access >public</access >
5
5
<active >true</active >
@@ -17,9 +17,32 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
17
17
retrieveData: function() {
18
18
var params = this._getParameters(this.PROCESS.getValue('parameters'));
19
19
var response = "<null/>";
20
+ if (Object.keys(params.run)[0]) {
21
+ var appname = '';
22
+ var lastscandate = '';
23
+ var branch = '';
24
+ var appId = '';
25
+ var applicationIds = [];
26
+ var applicationIdsStr = '';
27
+ var responseLastScanSummary = this.UTIL.getScanDetails(this.IMPLEMENTATION, Object.keys(params.run)[0]);
28
+ var jsonLastScanSummResp = JSON.parse(responseLastScanSummary.getBody());
29
+ //to map value of last_scan_date, project name and project Id in XML
30
+ for (var value in jsonLastScanSummResp.scans) {
31
+ var projectResponse = this.UTIL.getProjectById(this.IMPLEMENTATION, jsonLastScanSummResp.scans[value].projectId);
32
+ if (null != projectResponse.applicationIds && projectResponse.applicationIds.length > 0)
33
+ applicationIds = applicationIds.concat(projectResponse.applicationIds);
34
+ lastscandate += this.UTIL.parseDate(jsonLastScanSummResp.scans[value].updatedAt);
35
+ appname += jsonLastScanSummResp.scans[value].projectName;
36
+ branch += jsonLastScanSummResp.scans[value].branch;
37
+ appId += jsonLastScanSummResp.scans[value].projectId;
38
+ }
39
+ if (applicationIds.length > 0)
40
+ applicationIdsStr = applicationIds.toString();
41
+ }
42
+
20
43
if (params.run) {
21
44
// scanId, offset
22
- response = this.getDetailedReport(Object.keys(params.run)[0], params.run[Object.keys(params.run)[0]]);
45
+ response = this.getDetailedReport(Object.keys(params.run)[0], params.run[Object.keys(params.run)[0]], lastscandate, appname, branch, appId, applicationIdsStr );
23
46
gs.debug(this.MSG + ' getDetailedReport response:' + response);
24
47
25
48
}
@@ -45,7 +68,7 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
45
68
};
46
69
},
47
70
48
- getDetailedReport: function(scanId, offset) {
71
+ getDetailedReport: function(scanId, offset, lastscandate, appname, branch, appId, applicationIdsStr ) {
49
72
try {
50
73
var includesca = this.UTIL.importScaFlaw(this.IMPLEMENTATION);
51
74
var includesast = this.UTIL.importSastFlaw(this.IMPLEMENTATION);
@@ -56,13 +79,9 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
56
79
var SCAscanDetailedAll = '';
57
80
var SASTscanDetailedAll = '';
58
81
var scanDetailedAll = '';
59
- var lastscandate = '';
60
82
var sca = 'sca';
61
83
var sast = 'sast';
62
84
var description = '';
63
- var appname = '';
64
- var branch = '';
65
- var appId = '';
66
85
var line = '';
67
86
var ref = '';
68
87
var reference = '';
@@ -76,20 +95,11 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
76
95
var cvssScore = " ";
77
96
var cvssVector = " ";
78
97
var newoffset = offset - 1;
79
- var responseLastScanSummary = this.UTIL.getScanDetails(this.IMPLEMENTATION, scanId);
80
- var jsonLastScanSummResp = JSON.parse(responseLastScanSummary.getBody());
81
- gs.debug(this.MSG + " getSummaryReport : parsed scanInfoResponse " + JSON.stringify(jsonLastScanSummResp));
82
- //to map value of last_scan_date, project name and project Id in XML
83
- for (var value in jsonLastScanSummResp.scans) {
84
- lastscandate += this.UTIL.parseDate(jsonLastScanSummResp.scans[value].updatedAt);
85
- appId += jsonLastScanSummResp.scans[value].projectId;
86
- }
87
98
var responseLastScanReport = this.UTIL.getVulInfo(this.IMPLEMENTATION, scanId, newoffset);
88
99
gs.debug(this.MSG + " getDetailedReport : scanInfoResponse " + responseLastScanReport);
89
100
var jsonLastScanReportResp = JSON.parse(responseLastScanReport.getBody());
90
101
var scan_type = "static";
91
102
var vulnerabilityCountThresholdLevel = config.vulnerability_threshold_level;
92
-
93
103
for (var item in jsonLastScanReportResp.results) {
94
104
if (jsonLastScanReportResp.results[item].type == "sast") {
95
105
for (var j in jsonLastScanReportResp.results[item].data.nodes) {
@@ -100,6 +110,8 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
100
110
if ((vulnerabilityCountThresholdLevel == 'LOW') ||
101
111
(severity.toUpperCase() == 'HIGH') ||
102
112
(severity.toUpperCase() == vulnerabilityCountThresholdLevel)) {
113
+ var owasp = this._getOWASPTop10(jsonLastScanReportResp.results[item].vulnerabilityDetails.compliances);
114
+ var sans = this._getSANSTop25(jsonLastScanReportResp.results[item].vulnerabilityDetails.compliances);
103
115
SASTscanDetailedAll += '<result id="' + jsonLastScanReportResp.results[item].similarityId + '" scan_type="' + scan_type +
104
116
'" cweId="' + jsonLastScanReportResp.results[item].vulnerabilityDetails.cweId +
105
117
'" cweName="' + jsonLastScanReportResp.results[item].data.queryName +
@@ -120,25 +132,28 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
120
132
'" app_id="' + appId +
121
133
'" branch="' + branch +
122
134
'" last_scan_date="' + lastscandate +
135
+ '" OWASPTop10="' + owasp +
136
+ '" SANSTop25="' + sans +
137
+ '" application_ids="' + applicationIdsStr +
123
138
'" scan_id="' + 'sast' + scanId + '">' +
124
139
'<references><' + '![CDATA[' + reference + ']]' + '></references>' +
125
140
'<description><' + '![CDATA[' + jsonLastScanReportResp.results[item].description + ']]' + '></description></result>';
126
141
}
127
142
128
143
}
129
- if (jsonLastScanReportResp.results[item].type == "sca") {
144
+ if (jsonLastScanReportResp.results[item].type == "sca" || jsonLastScanReportResp.results[item].type == "sca-container" ) {
130
145
131
146
for (var k in jsonLastScanReportResp.results[item].data.packageData) {
132
147
var url = jsonLastScanReportResp.results[item].data.packageData[k].url;
133
148
ref += url + ', ';
134
149
}
135
-
136
150
var scaseverity = jsonLastScanReportResp.results[item].severity;
137
151
138
152
if ((vulnerabilityCountThresholdLevel == 'LOW') ||
139
153
(scaseverity.toUpperCase() == 'HIGH') ||
140
154
(scaseverity.toUpperCase() == vulnerabilityCountThresholdLevel)) {
141
- SCAscanDetailedAll += '<result id="' + jsonLastScanReportResp.results[item].id + '" scan_type="' + jsonLastScanReportResp.results[item].type +
155
+ SCAscanDetailedAll += '<result id="' + jsonLastScanReportResp.results[item].id +
156
+ '" scan_type="' + 'sca' +
142
157
'" cweId="' + jsonLastScanReportResp.results[item].vulnerabilityDetails.cweId +
143
158
'" cweName="' + jsonLastScanReportResp.results[item].vulnerabilityDetails.cveName +
144
159
'" cvssScore="' + jsonLastScanReportResp.results[item].vulnerabilityDetails.cvssScore +
@@ -159,12 +174,13 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
159
174
'" app_id="' + appId +
160
175
'" branch="' + branch +
161
176
'" last_scan_date="' + lastscandate +
177
+ '" application_ids="' + applicationIdsStr +
162
178
'" scan_id="' + 'sca' + scanId + '">' +
163
179
'<references><' + '![CDATA[' + ref + ']]' + '></references>' +
164
180
'<description><' + '![CDATA[' + jsonLastScanReportResp.results[item].description + ']]' + '></description></result>';
165
181
}
166
182
}
167
-
183
+ // '" references="' + ref.replace(/</g, " ") +
168
184
}
169
185
if (includesca) {
170
186
scanDetailedAll += SCAscanDetailedAll;
@@ -181,6 +197,44 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
181
197
return reportContent;
182
198
},
183
199
200
+ // Get all the OWASP Top 10 compliances as a concatenated string with comma.
201
+ _getOWASPTop10: function(compliances) {
202
+ var owasp = '';
203
+ if (compliances != null) {
204
+ for (var value in compliances) {
205
+ var compliance = compliances[value].toString();
206
+ var tempStr = compliance.toLowerCase();
207
+ var containsStr = tempStr.indexOf('owasp top 10');
208
+ if (containsStr != -1) {
209
+ if (owasp == '')
210
+ owasp += compliance;
211
+ else
212
+ owasp += ',' + compliance;
213
+ }
214
+ }
215
+ }
216
+ return owasp;
217
+ },
218
+
219
+ // Get all the SANS Top 25 compliances as a concatenated string with comma.
220
+ _getSANSTop25: function(compliances) {
221
+ var sans = '';
222
+ if (compliances != null) {
223
+ for (var value in compliances) {
224
+ var compliance = compliances[value].toString();
225
+ var tempStr = compliance.toLowerCase();
226
+ var containsStr = tempStr.indexOf('sans top 25');
227
+ if (containsStr != -1) {
228
+ if (sans == '')
229
+ sans += compliance;
230
+ else
231
+ sans += ',' + compliance;
232
+ }
233
+ }
234
+ }
235
+ return sans;
236
+ },
237
+
184
238
// Gets the integration parameters as a map
185
239
_getParameters: function(parameters) {
186
240
var params = {
@@ -275,6 +329,7 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
275
329
var offsets = [];
276
330
var offset = 0;
277
331
var ReportLength = this.UTIL.getTotalVulcount(this.IMPLEMENTATION, scanId);
332
+ //gs.info("Report Length" + ReportLength);
278
333
var loopLength = ReportLength / 50;
279
334
//in result api offset value start from 0 and increment by 1, here it acts like page instead of number of item like other api
280
335
for (var i = 0; i <= parseInt(loopLength); i++) {
@@ -336,10 +391,13 @@ CheckmarxOneAppVulItemIntegration.prototype = Object.extendsObject(sn_vul.Applic
336
391
<sys_created_by >admin</sys_created_by >
337
392
<sys_created_on >2022-11-21 12:06:20</sys_created_on >
338
393
<sys_id >891d8fed471f1110328ca368436d4334</sys_id >
394
+ <sys_mod_count >163</sys_mod_count >
339
395
<sys_name >CheckmarxOneAppVulItemIntegration</sys_name >
340
396
<sys_package display_value =" Checkmarx One Vulnerability Integration" source =" x_chec3_chexone" >3d20e92d47471110328ca368436d436a</sys_package >
341
397
<sys_policy />
342
398
<sys_scope display_value =" Checkmarx One Vulnerability Integration" >3d20e92d47471110328ca368436d436a</sys_scope >
343
399
<sys_update_name >sys_script_include_891d8fed471f1110328ca368436d4334</sys_update_name >
400
+ <
sys_updated_by >
[email protected] </
sys_updated_by >
401
+ <sys_updated_on >2023-08-29 05:30:33</sys_updated_on >
344
402
</sys_script_include >
345
403
</unload >
0 commit comments