Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/app/@core/service/ShowProjectService.ts
  • Loading branch information
bnBart committed Feb 1, 2024
2 parents 70f712c + 6bd42cf commit 809fc61
Show file tree
Hide file tree
Showing 25 changed files with 619 additions and 207 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 1.8.2 (2023-11-08)

#### New Features
* Additional statistics such as average time to fix, percent of solved critical vulnerabilities
* New widgets in show-project tabs replacing bugable gauge chart

#### Bug Fixes
* removing trend area in configuration of the project space

## 1.8.1 (2023-09-21)

#### New Features
* Grouping vulnerabilities via branch (affect only vulnerabilities in code)

## 1.8.0 (2023-08-08)

#### New Features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mixeway-frontend",
"version": "1.8.0",
"version": "1.8.2",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down
6 changes: 6 additions & 0 deletions src/app/@core/Model/DetailStats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class DetailStats {
detectedVulnerabilities: number;
resolvedVulnerabilities: number;
avgTimeToFix: number;
resolvedCriticals: number;
}
8 changes: 8 additions & 0 deletions src/app/@core/Model/Vulnerability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class Vulnerability {
vulnerability: Vuln;
cisRequirement: CisRequirement;
project: Project;
codeProjectBranch: CodeProjectBranch;
}
export class VulnerabilitySource {
name: string;
Expand All @@ -45,3 +46,10 @@ export class CisRequirement {
type: string;
severity: string;
}
export class CodeProjectBranch {
name: string;
}

export class ExtendedVulnerability extends Vulnerability {
codeProjectBranches: CodeProjectBranch[];
}
9 changes: 9 additions & 0 deletions src/app/@core/service/ShowProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {ProjectStats} from '../Model/ProjectStats';
import {ProjectAudit} from '../Model/ProjectAudit';
import {ProjectDetailsAudit} from '../Model/ProjectDetailsAudit';
import {ProjectUser} from '../Model/ProjectUser';
import {DetailStats} from '../Model/DetailStats';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -509,6 +510,14 @@ export class ShowProjectService {
);
}

getDetailStats(projectid): Observable<DetailStats> {
return this.http.get<DetailStats>(environment.backend + '/show/project/' + projectid + '/detailstats' )
.pipe(
retry(1),
catchError(this.errorHandl),
);
}

saveProjectUser(id, settings) {
return this.http.post<ProjectUser[]>(environment.backend + '/show/project/' + id + '/user/add', settings)
.pipe(
Expand Down
27 changes: 20 additions & 7 deletions src/app/pages/extra-components/details-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ interface EventItem {

@Component({
template: `
<ng-template #vulnerability style="display: flex;flex-direction: column;width: 60%">
<div class="modal-body px-0" >
<ng-template #vulnerability style="display: flex;flex-direction: column;">
<div class="modal-body px-0">
<div style="overflow-y: hidden; height: calc(100vh - 15rem);">
<div class="px-2" style="overflow-y: auto; height: 100%;">
<div class="row" *ngIf="grade === 1">
Expand Down Expand Up @@ -57,6 +57,20 @@ can be marked by Mixeway Vuln Auditor or manualy by a user, read docs to get mor
</nb-card>
</div>
</div>
<div class="row" *ngIf="rowData.codeProjectBranches">
<div class="col-md-12">
<nb-card>
<nb-card-header>
Branches in which vulnerability was found
</nb-card-header>
<nb-card-body>
<div *ngFor="let branch of rowData.codeProjectBranches">
{{ branch?.name }}
</div>
</nb-card-body>
</nb-card>
</div>
</div>
<div class="row">
<div class="col-md-12">
<nb-card>
Expand Down Expand Up @@ -125,16 +139,15 @@ can be marked by Mixeway Vuln Auditor or manualy by a user, read docs to get mor
</div>
</div>
<div class="row" class="align-content-center">
<div class="row align-content-center">
<div class="col-md-12">
<nb-card>
<nb-card-header>
Manually set the grade for given vulnerability
</nb-card-header>
<nb-card-body >
<button class="align-content-center" nbButton outline status="success" [disabled]="grade==0" (click)="setGradeForVuln(0)">Mark as not relevant</button>
<br/><br/>
<button class="align-content-center" nbButton outline status="danger" [disabled]="grade==1" (click)="setGradeForVuln(1)">Confirm as Must be fixed</button>
<nb-card-body class="d-flex flex-wrap">
<button nbButton outline status="success" [disabled]="grade==0" (click)="setGradeForVuln(0)" class="mr-2 mb-2">Mark as not relevant</button>
<button nbButton outline status="danger" [disabled]="grade==1" (click)="setGradeForVuln(1)" class="mb-2">Confirm as Must be fixed</button>
</nb-card-body>
</nb-card>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Detected Vulnerabilities
</nb-card-header>
<nb-card-body>
{{details?.createdVulnerabilities}}
{{details?.detectedVulnerabilities}}
</nb-card-body>
</nb-card>
</div>
Expand All @@ -27,18 +27,19 @@
Avg. Time to Fix [days]
</nb-card-header>
<nb-card-body>
{{details?.averageTimeToResolve}}
{{details?.avgTimeToFix == 0 ? 'n/a' : details?.avgTimeToFix}}
</nb-card-body>
</nb-card>
</div>
<div class="col-md-5">
<nb-card>
<nb-card-header>
Resolved Criticals
Resolved Criticals [%]
</nb-card-header>
<nb-card-body>
{{details?.percentCriticalsSolved}}
{{details?.resolvedCriticals}} %
</nb-card-body>
</nb-card>
</div>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

@import '../../../@theme/styles/themes';

@include nb-install-component() {
div{
margin-top:0px;
padding-top:0;
}
nb-card-body {
font-size: 1.3rem;
font-weight: bold;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { Component, OnInit } from '@angular/core';
import {ShowProjectService} from '../../../@core/service/ShowProjectService';
import {ActivatedRoute, Router} from '@angular/router';
import {ProjectDetailsAudit} from '../../../@core/Model/ProjectDetailsAudit';
import {DetailStats} from '../../../@core/Model/DetailStats';

@Component({
selector: 'ngx-details-carts',
templateUrl: './details-carts.component.html',
styleUrls: ['./details-carts.component.scss'],
})
export class DetailsCartsComponent implements OnInit {
details: ProjectDetailsAudit;
details: DetailStats;
_entityId: any;

constructor(private showProjectService: ShowProjectService, private _route: ActivatedRoute,
Expand All @@ -21,20 +22,14 @@ export class DetailsCartsComponent implements OnInit {
}

ngOnInit(): void {
this.loadTrendChartData();
this.loadDetails();
}

loadTrendChartData() {
return this.showProjectService.getProjectVulnDetailsAudit(this._entityId).subscribe(data => {
loadDetails() {
return this.showProjectService.getDetailStats(this._entityId).subscribe(data => {
this.details = data;
if (Number(this.details.averageTimeToResolve) > 0) {
const originalNumber: number = Number(this.details.averageTimeToResolve);
const dividedNumber: number = originalNumber / 24;
const roundedNumber: number = parseFloat(dividedNumber.toFixed(1));
this.details.averageTimeToResolve = roundedNumber + '';
} else {
this.details.averageTimeToResolve = 'n/a';
}
});
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {AnalysisColorComponent} from '../../extra-components/analysis-color.comp
import {Angular5Csv} from 'angular5-csv/dist/Angular5-csv';
import {ProjectConstants} from '../../../@core/constants/ProjectConstants';
import {BugComponent} from '../../extra-components/bug-component';
import {Vulnerability} from '../../../@core/Model/Vulnerability';
import {ExtendedVulnerability, Vulnerability} from '../../../@core/Model/Vulnerability';
import {LocalDataSource} from 'ng2-smart-table';
import {VulnerabilitySourceComponent} from '../../extra-components/vulnerability-source-component';
import {StatusComponent} from '../../extra-components/status-component';
Expand Down Expand Up @@ -78,7 +78,7 @@ export class DetailsTablesComponent implements OnInit {
} else {
location = vulnerability.location;
}
const vuln = {
const vuln1 = {
projectId: this._entityId,
id: vulnerability.id,
name: vulnerability.vulnerability ? vulnerability.vulnerability.name : vulnerability.cisRequirement.name,
Expand All @@ -95,9 +95,30 @@ export class DetailsTablesComponent implements OnInit {
codeBug: this.codeBugTracker,
networkBug: this.networkBugTracker,
codeProject: vulnerability.codeProject?.name,
codeProjectBranch: vulnerability.codeProjectBranch,
};
this.vulnerabilitiesPojo.push(vuln);
this.source = new LocalDataSource(this.vulnerabilitiesPojo);
this.vulnerabilitiesPojo.push(vuln1);
const groupedVulnerabilities: { [key: string]: ExtendedVulnerability } = {};

this.vulnerabilitiesPojo.forEach((vuln) => {
// Tworzenie klucza na podstawie wybranych atrybutów
const key = `${vuln.name}-${vuln.description}-${vuln.location}`;

if (!groupedVulnerabilities[key]) {
// Jeżeli nie ma jeszcze takiego klucza, tworzymy nowy obiekt ExtendedVulnerability
const extendedVuln = new ExtendedVulnerability();
Object.assign(extendedVuln, vuln);
extendedVuln.codeProjectBranches = [vuln.codeProjectBranch];
groupedVulnerabilities[key] = extendedVuln;
} else {
// Jeżeli klucz już istnieje, dodajemy tylko codeProjectBranch do listy
groupedVulnerabilities[key].codeProjectBranches.push(vuln.codeProjectBranch);
}
});

// Konwersja do tablicy
const extendedVulnerabilities: ExtendedVulnerability[] = Object.values(groupedVulnerabilities);
this.source = new LocalDataSource(extendedVulnerabilities);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
<nb-card size="tiny" xmlns="http://www.w3.org/1999/html">
<nb-card-header>Project summary</nb-card-header>
<nb-card-body >
<div class="col-md-4" >
<div echarts [options]="option" class="echart" style="width: 100%; height: 100%"></div>
</div>
<div class="col-md-4 centrize">
<p class="p_name">Assets:</p> <p class="p_value">{{projectStats?.assets}}</p> <br/>
<p class="p_name">Code Repos:</p> <p class="p_value">{{projectStats?.repos}}</p> <br/>
<p class="p_name">WebApps:</p> <p class="p_value">{{projectStats?.webApps}}</p> <br/>
<p class="p_name">Dependencies:</p> <p class="p_value">{{projectStats?.libs}}</p> <br/>
</div>
<div class="col-md-4">
<div class="centrize">
<h6>Vulnerabilities detected</h6> <br/>
<nb-alert status="danger" nbTooltip="Critical or High Severity">{{projectStats?.vulnCrit}}</nb-alert>&nbsp;&nbsp;
<nb-alert status="warning" nbTooltip="Medium Severity">{{projectStats?.vulnMedium}}</nb-alert>&nbsp;&nbsp;
<nb-alert status="primary" nbTooltip="Low Severity">{{projectStats?.vulnLow}}</nb-alert>&nbsp;&nbsp;<br/><br/>
<a pageScroll href="#detailsTables">View more info</a>
</div>
<!--<nb-card size="tiny" xmlns="http://www.w3.org/1999/html">-->
<!-- <nb-card-header>Project summary</nb-card-header>-->
<!-- <nb-card-body >-->
<!-- <div class="col-md-4" >-->
<!-- <div echarts [options]="option" class="echart" style="width: 100%; height: 100%"></div>-->
<!-- </div>-->
<!-- <div class="col-md-4 centrize">-->
<!-- <p class="p_name">Assets:</p> <p class="p_value">{{projectStats?.assets}}</p> <br/>-->
<!-- <p class="p_name">Code Repos:</p> <p class="p_value">{{projectStats?.repos}}</p> <br/>-->
<!-- <p class="p_name">WebApps:</p> <p class="p_value">{{projectStats?.webApps}}</p> <br/>-->
<!-- <p class="p_name">Dependencies:</p> <p class="p_value">{{projectStats?.libs}}</p> <br/>-->
<!-- </div>-->
<!-- <div class="col-md-4">-->
<!-- <div class="centrize">-->
<!-- <h6>Vulnerabilities detected</h6> <br/>-->
<!-- <nb-alert status="danger" nbTooltip="Critical or High Severity">{{projectStats?.vulnCrit}}</nb-alert>&nbsp;&nbsp;-->
<!-- <nb-alert status="warning" nbTooltip="Medium Severity">{{projectStats?.vulnMedium}}</nb-alert>&nbsp;&nbsp;-->
<!-- <nb-alert status="primary" nbTooltip="Low Severity">{{projectStats?.vulnLow}}</nb-alert>&nbsp;&nbsp;<br/><br/>-->
<!-- <a pageScroll href="#detailsTables">View more info</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- </nb-card-body>-->
<!--</nb-card>-->

<nb-card >
<div class="icon-container">
<div class="icon status-danger">
<ng-content></ng-content>
</div>
</nb-card-body>
</div>

<div class="details">
<div class="title h5">LIGHT</div>
<div class="status paragraph-2">ON</div>
</div>
</nb-card>

<!-- <nb-card size="medium">-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('ProjectDetailsComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProjectDetailsComponent ]
declarations: [ ProjectDetailsComponent ],
})
.compileComponents();
});
Expand Down
Loading

0 comments on commit 809fc61

Please sign in to comment.