Skip to content

Commit

Permalink
feat(vulnerability form): updated confirmation message for jira export
Browse files Browse the repository at this point in the history
Updated confirmation message for jira export to include vulnerability name and associated jira host

feat #179
  • Loading branch information
alejandrosaenz117 committed Aug 15, 2020
1 parent 6a864d0 commit 8012a9a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const routes: Routes = [
path:
'organization/:orgId/asset/:assetId/assessment/:assessmentId/vuln-form/:vulnId',
component: VulnFormComponent,
resolve: { vulnerability: VulnerabilityResolver },
resolve: { vulnInfo: VulnerabilityResolver },
canActivate: [AuthGuard],
},
{
Expand Down
22 changes: 14 additions & 8 deletions frontend/src/app/vuln-form/vuln-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class VulnFormComponent implements OnChanges, OnInit {
assessmentId: string;
vulnId: number;
vulnFormData: FormData;
jiraHost: string;
tempScreenshots: Screenshot[] = [];
screenshotsToDelete: number[] = [];
faTrash = faTrash;
Expand Down Expand Up @@ -102,10 +103,13 @@ export class VulnFormComponent implements OnChanges, OnInit {
this.updateRisk();
}
});
this.activatedRoute.data.subscribe(({ vulnerability }) => {
if (vulnerability) {
this.vulnModel = vulnerability;
for (const probLoc of vulnerability.problemLocations) {
this.activatedRoute.data.subscribe(({ vulnInfo }) => {
if (vulnInfo.jiraHost) {
this.jiraHost = vulnInfo.jiraHost;
}
if (vulnInfo.vulnerability) {
this.vulnModel = vulnInfo.vulnerability;
for (const probLoc of vulnInfo.vulnerability.problemLocations) {
this.probLocArr.push(
this.fb.group({
id: probLoc.id,
Expand All @@ -114,7 +118,7 @@ export class VulnFormComponent implements OnChanges, OnInit {
})
);
}
for (const resource of vulnerability.resources) {
for (const resource of vulnInfo.vulnerability.resources) {
this.resourceArr.push(
this.fb.group({
id: resource.id,
Expand All @@ -123,14 +127,14 @@ export class VulnFormComponent implements OnChanges, OnInit {
})
);
}
for (const file of vulnerability.screenshots) {
for (const file of vulnInfo.vulnerability.screenshots) {
const existFile: AppFile = file;
this.appService.getImageById(existFile).then((url) => {
existFile.imgUrl = url;
this.previewScreenshot(null, existFile);
});
}
this.vulnForm.patchValue(vulnerability);
this.vulnForm.patchValue(vulnInfo.vulnerability);
}
});
this.activatedRoute.params.subscribe((params) => {
Expand Down Expand Up @@ -461,7 +465,9 @@ export class VulnFormComponent implements OnChanges, OnInit {
}

exportToJira() {
const r = confirm(`Export vulnerability ${this.vulnModel.name} to Jira?`);
const r = confirm(
`Export vulnerability "${this.vulnModel.name}" to Jira host: ${this.jiraHost}?`
);
if (r) {
if (this.vulnForm.dirty) {
this.alertService.warn(
Expand Down
10 changes: 8 additions & 2 deletions src/routes/vulnerability.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ export const getVulnById = async (req: UserRequest, res: Response) => {
const vuln = await getConnection()
.getRepository(Vulnerability)
.findOne(req.params.vulnId, {
relations: ['screenshots', 'problemLocations', 'resources']
relations: ['screenshots', 'problemLocations', 'resources', 'assessment']
});
const assessment = await getConnection()
.getRepository(Assessment)
.findOne(vuln.assessment.id, { relations: ['asset'] });
const jira = await getConnection()
.getRepository(Jira)
.findOne({ where: { asset: assessment.asset } });
if (!vuln) {
return res.status(404).send('Vulnerability does not exist.');
}
res.status(200).json(vuln);
res.status(200).json({ vulnerability: vuln, jiraHost: jira.host });
};
/**
* @description Delete vulnerability by ID
Expand Down

0 comments on commit 8012a9a

Please sign in to comment.