Skip to content

Commit

Permalink
Refactor the Reports class
Browse files Browse the repository at this point in the history
  • Loading branch information
kasunkv committed Aug 26, 2017
1 parent 7a7ff86 commit a9f9266
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions buildtask/OwaspZapScan/classes/Reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ export class Report {
Task.debug(`Report Filename: ${fullFilePath}`);

if (type == ReportType.HTML) {
/* Get the Scan Result */
let xmlResult: string = await this.GetScanResults(ReportType.XML);
/* Sort and Count the Alerts */
let processedAlerts: AlertResult = this._helper.ProcessAlerts(xmlResult, this._targetUrl);
/* Generate the Custom HTML Report */
scanReport = this.createCustomHtmlReport(processedAlerts);

} else {
scanReport = await this.GetScanResults(type);
}

/* Write the File */
return new Promise<boolean>((resolve, reject) => {
fs.writeFile(fullFilePath, scanReport, (err: any) => {
if (err) {
Expand Down Expand Up @@ -194,19 +198,19 @@ export class Report {
</tr>
</thead>
<tr class="bg-danger legend">
<td><a href="#high">High</a></td>
<td><a href="#3">High</a></td>
<td>${alertResult.HighAlerts}</td>
</tr>
<tr class="bg-warning legend">
<td><a href="#medium">Medium</a></td>
<td><a href="#2">Medium</a></td>
<td>${alertResult.MediumAlerts}</td>
</tr>
<tr class="bg-info legend">
<td><a href="#low">Low</a></td>
<td><a href="#1">Low</a></td>
<td>${alertResult.LowAlerts}</td>
</tr>
<tr class="bg-success legend">
<td><a href="#info">Informational</a></td>
<td><a href="#0">Informational</a></td>
<td>${alertResult.InformationalAlerts}</td>
</tr>
</table>
Expand All @@ -216,6 +220,7 @@ export class Report {
<div class="row">
<div class="col-md-12">
<h2>Alert Detail</h2>
<p class="lead">Click on the risk type header to expand the details panel for the risk</p>
<hr>
${alertHtmlTables}
</div>
Expand Down Expand Up @@ -272,7 +277,7 @@ export class Report {
let htmlString: string = `
<table class="table">
<tr class="${cssClass}" height="24">
<td width="20%"><p class="alert-header"><a name="medium" class="alert-header-link" data-toggle="collapse" href="#collapseBlock${collapseId}" aria-expanded="false" aria-controls="collapseExample" >${alert.riskdesc}</a></p></td>
<td width="20%"><p class="alert-header"><a name="${alert.riskcode}" class="alert-header-link" data-toggle="collapse" href="#collapseBlock${collapseId}" aria-expanded="false" aria-controls="collapseExample" >${alert.riskdesc}</a></p></td>
<td width="80%"><p class="alert-header">${alert.name}</p></td>
</tr>
<tbody class="collapse" id="collapseBlock${collapseId}">
Expand Down
2 changes: 1 addition & 1 deletion buildtask/OwaspZapScan/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"author": "Kasun Kodagoda",
"version": {
"Major": 1,
"Minor": 50,
"Minor": 52,
"Patch": 0
},
"demands": [
Expand Down

0 comments on commit a9f9266

Please sign in to comment.