From 70f712cb51a7787411418dc47bed7d965ef528d1 Mon Sep 17 00:00:00 2001 From: bnBart Date: Thu, 1 Feb 2024 13:38:37 +0100 Subject: [PATCH] Project User --- angular.json | 3 + package-lock.json | 151 ++++++++++++++---- src/app/@core/Model/ProjectUser.ts | 3 + src/app/@core/constants/AdminConstants.ts | 5 + src/app/@core/service/ShowProjectService.ts | 9 ++ src/app/pages/admin/user/user.component.html | 2 +- src/app/pages/admin/user/user.component.ts | 2 +- .../show-project/show-project.component.html | 11 ++ .../show-project/show-project.component.ts | 24 +++ 9 files changed, 174 insertions(+), 36 deletions(-) create mode 100644 src/app/@core/Model/ProjectUser.ts diff --git a/angular.json b/angular.json index 966c446..5a9508a 100644 --- a/angular.json +++ b/angular.json @@ -198,5 +198,8 @@ "@schematics/angular:directive": { "prefix": "ngx" } + }, + "cli": { + "analytics": false } } diff --git a/package-lock.json b/package-lock.json index 6864914..390d2f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2984,6 +2984,15 @@ "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, "emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -3001,6 +3010,40 @@ "strip-ansi": "^7.0.1" } }, + "string-width-cjs": { + "version": "npm:string-width@4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", @@ -3010,6 +3053,23 @@ "ansi-regex": "^6.0.1" } }, + "strip-ansi-cjs": { + "version": "npm:strip-ansi@6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + } + } + }, "wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -3020,6 +3080,60 @@ "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } + }, + "wrap-ansi-cjs": { + "version": "npm:wrap-ansi@7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } } } }, @@ -3846,9 +3960,9 @@ "dev": true }, "@types/jasminewd2": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/@types/jasminewd2/-/jasminewd2-2.0.10.tgz", - "integrity": "sha512-J7mDz7ovjwjc+Y9rR9rY53hFWKATcIkrr9DwQWmOas4/pnIPJTXawnzjwpHm3RSxz/e3ZVUvQ7cRbd5UQLo10g==", + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/@types/jasminewd2/-/jasminewd2-2.0.13.tgz", + "integrity": "sha512-aJ3wj8tXMpBrzQ5ghIaqMisD8C3FIrcO6sDKHqFbuqAsI7yOxj0fA7MrRCPLZHIVUjERIwsMmGn/vB0UQ9u0Hg==", "dev": true, "requires": { "@types/jasmine": "*" @@ -15439,17 +15553,6 @@ "strip-ansi": "^6.0.1" } }, - "string-width-cjs": { - "version": "npm:string-width@4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "string.prototype.padend": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.4.tgz", @@ -15510,15 +15613,6 @@ "ansi-regex": "^5.0.1" } }, - "strip-ansi-cjs": { - "version": "npm:strip-ansi@6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -17701,17 +17795,6 @@ "strip-ansi": "^6.0.0" } }, - "wrap-ansi-cjs": { - "version": "npm:wrap-ansi@7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/src/app/@core/Model/ProjectUser.ts b/src/app/@core/Model/ProjectUser.ts new file mode 100644 index 0000000..b669ae1 --- /dev/null +++ b/src/app/@core/Model/ProjectUser.ts @@ -0,0 +1,3 @@ +export class ProjectUser { + user: string; +} diff --git a/src/app/@core/constants/AdminConstants.ts b/src/app/@core/constants/AdminConstants.ts index 206b82f..d50fbae 100644 --- a/src/app/@core/constants/AdminConstants.ts +++ b/src/app/@core/constants/AdminConstants.ts @@ -44,6 +44,10 @@ export class AdminConstants { 'name': 'Viewer', 'id': 'ROLE_USER', }, + { + 'name': 'Project Owner', + 'id': 'ROLE_PROJECT_OWNER', + }, { 'name': 'Editor', 'id': 'ROLE_EDITOR_RUNNER', @@ -152,6 +156,7 @@ export class AdminConstants { ADMIN_FORM_PROJECTS = 'Permissions for projects'; ADMIN_FORM_PROJECTS2 = 'Select projects...'; ADMIN_ROLE_USER = 'ROLE_USER'; + ADMIN_ROLE_PROJECT_OWNER = 'ROLE_PROJECT_OWNER'; ADMIN_ROLE_USER2 = 'ROLE_EDITOR_RUNNER'; ADMIN_FORM_EDIT = 'Edit'; ADMIN_EDIT_USER = 'Editing user'; diff --git a/src/app/@core/service/ShowProjectService.ts b/src/app/@core/service/ShowProjectService.ts index 78b7172..b7b6d48 100644 --- a/src/app/@core/service/ShowProjectService.ts +++ b/src/app/@core/service/ShowProjectService.ts @@ -28,6 +28,7 @@ import {IaasApiType} from '../Model/IaasApiType'; import {ProjectStats} from '../Model/ProjectStats'; import {ProjectAudit} from '../Model/ProjectAudit'; import {ProjectDetailsAudit} from '../Model/ProjectDetailsAudit'; +import {ProjectUser} from '../Model/ProjectUser'; @Injectable({ providedIn: 'root', @@ -507,4 +508,12 @@ export class ShowProjectService { catchError(this.errorHandl), ); } + + saveProjectUser(id, settings) { + return this.http.post(environment.backend + '/show/project/' + id + '/user/add', settings) + .pipe( + retry(1), + catchError(this.errorHandl), + ); + } } diff --git a/src/app/pages/admin/user/user.component.html b/src/app/pages/admin/user/user.component.html index 880daa2..0310a5a 100644 --- a/src/app/pages/admin/user/user.component.html +++ b/src/app/pages/admin/user/user.component.html @@ -59,7 +59,7 @@ -
+
diff --git a/src/app/pages/admin/user/user.component.ts b/src/app/pages/admin/user/user.component.ts index 2750723..f9db2dc 100644 --- a/src/app/pages/admin/user/user.component.ts +++ b/src/app/pages/admin/user/user.component.ts @@ -167,7 +167,7 @@ export class UserComponent implements OnInit { } changedRole($event: any) { - if ($event === 'ROLE_USER' || $event === 'ROLE_ADMIN' || $event === 'ROLE_AUDITOR' || $event === 'ROLE_EDITOR_RUNNER') { + if ($event === 'ROLE_USER' || $event === 'ROLE_ADMIN' || $event === 'ROLE_AUDITOR' || $event === 'ROLE_EDITOR_RUNNER' || $event === 'ROLE_PROJECT_OWNER') { this.showUsername = true; this.showOptions = true; } else if ($event === 'ROLE_API') { diff --git a/src/app/pages/show-project/show-project.component.html b/src/app/pages/show-project/show-project.component.html index 628610b..e224c3f 100644 --- a/src/app/pages/show-project/show-project.component.html +++ b/src/app/pages/show-project/show-project.component.html @@ -139,8 +139,19 @@

{{ risk?.projectName }} + +
+ + +
+ + +
+ +
+ diff --git a/src/app/pages/show-project/show-project.component.ts b/src/app/pages/show-project/show-project.component.ts index 6e61141..62f7e64 100644 --- a/src/app/pages/show-project/show-project.component.ts +++ b/src/app/pages/show-project/show-project.component.ts @@ -13,6 +13,8 @@ import {ProjectInfo} from '../../@core/Model/ProjectInfo'; import {VulnTrendChart} from '../../@core/Model/VulnTrendChart'; import {Severities} from '../../@core/Model/Severities'; import {ProjectStats} from '../../@core/Model/ProjectStats'; +import {ProjectUser} from '../../@core/Model/ProjectUser'; + @Component({ selector: 'ngx-show-project', @@ -45,7 +47,10 @@ export class ShowProjectComponent implements OnInit { severities: Severities; severitiesChartData: any = []; projectStats: ProjectStats; + private vulnAuditorForm: any; + private projectUserForm: any; + projectUser: ProjectUser = new ProjectUser; constructor(private showProjectService: ShowProjectService, private _route: ActivatedRoute, private router: Router, private cookieService: CookieService, private dialogService: NbDialogService, private formBuilder: FormBuilder, private toast: Toast, private windowService: NbWindowService) { @@ -64,6 +69,9 @@ export class ShowProjectComponent implements OnInit { dclocation: this.projectInfo.networkdc, appClient: this.projectInfo.appClient, }); + this.projectUserForm = this.formBuilder.group({ + user: this.projectUser.user, + }); this.updateShowDockerInfo(); } loadTrendChartData() { @@ -193,6 +201,22 @@ export class ShowProjectComponent implements OnInit { }); } + + saveProjectUser(ref) { + return this.showProjectService.saveProjectUser(this._entityId, this.projectUserForm.value).subscribe(() => { + this.toast.showToast('success', this.constants.PROJECT_OPERATION_SUCCESS, + 'Project Settings saved successfully.'); + this.loadProjectInfo(); + ref.close(); + }, + () => { + this.toast.showToast('danger', this.constants.PROJECT_OPERATION_FAILURE, + this.constants.PROJECT_OPERATION_FAILURES); + }); + } + + + flipped = false; toggleView() {