Compare commits

...

8 Commits

Author SHA1 Message Date
Marcel Haag 92dbf852ea fix: integration test and ascii documentation 2022-08-19 13:10:32 +02:00
mhg 9768a23690
Create THIRD-PARTY-LICENSES.md
This is only a template and should be updated before making the repository public.
2022-08-14 18:15:11 +02:00
mhg 15f0146bab
Updated LICENSE.md 2022-08-14 18:07:36 +02:00
mhg 2c7fe64259
Delete LICENSE.md 2022-08-14 18:06:36 +02:00
mhg 7d5d09e99f
Update CONTRIBUTING.md 2022-08-14 17:44:49 +02:00
mhg 1cfe864497
Create CONTRIBUTING.md 2022-08-14 17:37:43 +02:00
mhg 0bb4e15ba7
Create LICENSE.md 2022-08-14 17:04:18 +02:00
mhg 843ecdc3b7
feat: refactor project model in order to calculate progress 2022-08-10 18:22:46 +02:00
26 changed files with 478 additions and 108 deletions

57
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,57 @@
# Contributing to Security-C4PO
First off, thanks for taking the time to contribute! 👍
The following is a set of guidelines for contributing to this project and its packages, which are hosted on GitHub.
These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
## How Can I Contribute?
### Reporting Bugs
This section guides you through submitting a bug report. Following these guidelines helps maintainers and the community understand your report.
Explain the problem and include additional details to help maintainers reproduce the problem:
* **Use a clear and descriptive title** for the issue to identify the problem.
* **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining how you started the application, e.g. which command exactly you used in the terminal, or how you started the application otherwise. When listing steps, **don't just say what you did, but explain how you did it**.
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
* **Explain which behavior you expected to see instead and why.**
* **Include screenshots and animated GIFs** which show you following the described steps and clearly demonstrate the problem.
* **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened.
### Suggesting Enhancements
This section guides you through submitting an enhancement suggestion, including completely new features and minor improvements to existing functionality.
Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:.
* **Use a clear and descriptive title** for the issue to identify the suggestion.
* **Provide a step-by-step description of the suggested enhancement** in as many details as possible.
* **Include screenshots, mock-ups or animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to.
* **Explain why this enhancement would be useful**
## Code of Conduct
Use the following conventions:
* Branch: `<initial>_c4po_<issuenumber>`
* Commit: `feat: <What was implemented?>` or `fix: <What got fixed?>`
By participating, you are expected to uphold this code.
## Local development
Security-C4PO and all it's included micorservices can be developed locally.
Execute 'c4po.sh' and all services will run on a dev server.
#### Testuser Credentials:
* Username: ttt
* Password: Test1234!
#### Technical Environment Requirements
* Docker / Docker-compose
* OpenJDK 11
* Node 14.15.1 / npm 6.14.8
* MongoDB 4.4.6
#### Helpfull Tools
* mongoDB Compass
* Postman
## Additional Notes
lorem ipsum.

201
LICENSE.md Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2020] [Marcel Haag]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,16 +1,10 @@
# security-c4po
### Chief Innovator
> Daniel Mader
## Application Architecture
![alt architecture](./wiki/C4PO-Architecture.png)
### Project Leads
* Andreas Falk
* Christina Paule
### Developers
* Marcel Haag
* Norman Schmidt
* Stipe Knez
## Data Structure
![alt datastructure](./wiki/C4PO-Datastructure.png)
### Technical Requirements
* Docker / Docker-compose
@ -22,12 +16,6 @@
* mongoDB Compass
* Postman
## Application Architecture
![alt architecture](./wiki/C4PO-Architecture.png)
## Data Structure
![alt datastructure](./wiki/C4PO-Datastructure.png)
### Conventions
* Branch: `<initial>_c4po_<issuenumber>`
* Commit: `feat: <What was implemented?>` or `fix: <What got fixed?>`

13
THIRD-PARTY-LICENSES.md Normal file
View File

@ -0,0 +1,13 @@
## Dependency License Report for security-c4po SNAPSHOT
#### Example
1. Group: antlr Name: antlr Version: 2.7.7
POM Project URL: http://www.antlr.org/
POM License: BSD License - http://www.antlr.org/license.html
--------------------------------------------------------------------------------
This report was generated at Thu Oct 01 09:28:53 CEST 2020.

View File

@ -9,7 +9,7 @@
.export-button-container {
display: flex;
align-content: flex-end;
margin-right: 1rem;
margin-right: 0.5rem;
.export-element-icon {
}

View File

@ -20,17 +20,14 @@ import {RouterModule} from '@angular/router';
import {FormsModule} from '@angular/forms';
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
import {FlexLayoutModule} from '@angular/flex-layout';
import {LoadingSpinnerComponent} from '@shared/widgets/loading-spinner/loading-spinner.component';
@NgModule({
declarations: [
PentestHeaderComponent,
PentestCategoriesComponent,
PentestTableComponent
],
exports: [
PentestHeaderComponent,
PentestCategoriesComponent,
PentestTableComponent
PentestTableComponent,
// LoadingSpinnerComponent
],
imports: [
CommonModule,
@ -52,6 +49,12 @@ import {FlexLayoutModule} from '@angular/flex-layout';
FontAwesomeModule,
FlexLayoutModule,
NbActionsModule
],
exports: [
PentestHeaderComponent,
PentestCategoriesComponent,
PentestTableComponent,
// LoadingSpinnerComponent
]
})
export class PentestOverviewModule {

View File

@ -48,8 +48,11 @@
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let pentest">
<app-findig-widget [numberOfFindigs]="pentest.data['findings']"></app-findig-widget>
<!--{{pentest.data['findings'] || '-'}}-->
<!--ToDo: Add comments {{pentest.data['comments'] || '-'}}-->
</td>
</ng-container>
</table>
</nb-card>
<!--ToDo: Add loading spinner after routing fix to avoid circular dependency issues
<app-loading-spinner [isLoading$]="isLoading()" *ngIf="isLoading() | async"></app-loading-spinner>-->

View File

@ -5,8 +5,8 @@ import {PentestService} from '@shared/services/pentest.service';
import {Store} from '@ngxs/store';
import {PROJECT_STATE_NAME, ProjectState} from '@shared/stores/project-state/project-state';
import {UntilDestroy, untilDestroyed} from '@ngneat/until-destroy';
import {catchError, switchMap} from 'rxjs/operators';
import {of} from 'rxjs';
import {catchError, switchMap, tap} from 'rxjs/operators';
import {BehaviorSubject, Observable, of} from 'rxjs';
import {getTitleKeyForRefNumber} from '@shared/functions/categories/get-title-key-for-ref-number.function';
import {Route} from '@shared/models/route.enum';
import {Router} from '@angular/router';
@ -20,6 +20,7 @@ import {ChangePentest} from '@shared/stores/project-state/project-state.actions'
})
export class PentestTableComponent implements OnInit {
loading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
columns: Array<PentestColumns> = [PentestColumns.TEST_ID, PentestColumns.TITLE, PentestColumns.STATUS, PentestColumns.FINDINGS];
dataSource: NbTreeGridDataSource<PentestEntry>;
@ -47,14 +48,17 @@ export class PentestTableComponent implements OnInit {
loadPentestData(): void {
this.store.select(ProjectState.selectedCategory).pipe(
switchMap(category => this.pentestService.loadPentests(category)),
tap(() => this.loading$.next(true)),
catchError(_ => of(null)),
untilDestroyed(this)
).subscribe({
next: (pentests: Pentest[]) => {
this.data = transformPentestsToEntries(pentests);
this.dataSource.setData(this.data, this.getters);
this.loading$.next(false);
},
error: error => {
this.loading$.next(false);
console.error(error);
}
});
@ -78,6 +82,11 @@ export class PentestTableComponent implements OnInit {
getTitle(refNumber: string): string {
return getTitleKeyForRefNumber(refNumber);
}
// HTML only
isLoading(): Observable<boolean> {
return this.loading$.asObservable();
}
}
enum PentestColumns {

View File

@ -34,13 +34,20 @@
</span>
</nb-card-body>
<nb-card-footer>
<!--ToDo: Display correct progress of project-->
<div fxLayout="row" fxLayoutGap="1rem" fxLayoutAlign="start end">
<nb-progress-bar class="project-progress"
status="warning"
[value]="40"
[displayValue]="true">
</nb-progress-bar>
<div class="project-progress">
<nb-progress-bar *ngIf="project.testingProgress > 0; else altProgressBar"
status="warning"
[value]="project.testingProgress"
[displayValue]="true">
</nb-progress-bar>
<ng-template #altProgressBar>
{{'popup.info' | translate}} {{'global.no.progress' | translate}}
</ng-template>
</div>
<button nbButton
status="primary"
size="small"
@ -61,7 +68,7 @@
</div>
</div>
<div *ngIf="projects.getValue().length === 0 || !isLoading()" fxLayout="row" fxLayoutAlign="center center">
<div *ngIf="projects.getValue().length === 0 && loading$.getValue() === false" fxLayout="row" fxLayoutAlign="center center">
<p class="error-text">
{{'project.overview.no.projects' | translate}}
</p>

View File

@ -131,6 +131,7 @@ export class ProjectOverviewComponent implements OnInit {
});
}
// HTML only
isLoading(): Observable<boolean> {
return this.loading$.asObservable();
}

View File

@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ProjectOverviewComponent} from './project-overview.component';
import {ProjectOverviewRoutingModule} from './project-overview-routing.module';
import {NbButtonModule, NbCardModule, NbMenuModule, NbProgressBarModule, NbSidebarModule, NbSpinnerModule} from '@nebular/theme';
import {NbButtonModule, NbCardModule, NbProgressBarModule, NbSpinnerModule} from '@nebular/theme';
import {FlexLayoutModule} from '@angular/flex-layout';
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
import {TranslateModule} from '@ngx-translate/core';

View File

@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule} from '@angular/router';
import {ProjectComponent} from './project.component';
import {NbCardModule, NbLayoutModule, NbMenuModule, NbSidebarModule} from '@nebular/theme';
import {NbCardModule, NbLayoutModule} from '@nebular/theme';
import {FlexLayoutModule} from '@angular/flex-layout';
import {TranslateModule} from '@ngx-translate/core';
import {ProjectDialogModule} from '@shared/modules/project-dialog/project-dialog.module';
@ -13,9 +13,6 @@ import {PentestOverviewModule} from '../../pentest-overview';
declarations: [
ProjectComponent
],
exports: [
ProjectComponent
],
imports: [
CommonModule,
NbCardModule,
@ -29,6 +26,9 @@ import {PentestOverviewModule} from '../../pentest-overview';
FlexLayoutModule,
ProjectDialogModule,
PentestOverviewModule
],
exports: [
ProjectComponent
]
})
export class ProjectModule {

View File

@ -11,7 +11,8 @@
"action.yes": "Ja",
"action.no": "Nein",
"username": "Nutzername",
"password": "Passwort"
"password": "Passwort",
"no.progress": "Kein Fortschritt"
},
"languageKeys":{
"de-DE": "Deutsch",

View File

@ -11,7 +11,8 @@
"action.yes": "Yes",
"action.no": "No",
"username": "Username",
"password": "Password"
"password": "Password",
"no.progress": "No progress"
},
"languageKeys":{
"de-DE": "German",

View File

@ -4,19 +4,22 @@ export class Project {
title: string;
createdAt: Date;
tester: string;
testingProgress: number;
createdBy: string;
constructor(id: string,
client: string,
title: string,
createdAt: Date,
tester?: string,
tester: string,
testingProgress: number,
createdBy?: string) {
this.id = id;
this.client = client;
this.title = title;
this.createdAt = createdAt;
this.tester = tester;
this.testingProgress = testingProgress;
this.createdBy = createdBy;
}
}

View File

@ -70,7 +70,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"client\": \"Novatec\",\n \"title\": \"log4j pentest\",\n \"tester\" : \"Stipe\",\n \"createdBy\" : \"10e06d7a-8dd0-4ecd-8963-056b45079c4f\"\n}",
"raw": "{\n \"client\": \"Novatec\",\n \"title\": \"log4j pentest\",\n \"tester\" : \"Stipe\"\n}",
"options": {
"raw": {
"language": "json"
@ -142,7 +142,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"client\": \"updatedProject\",\n \"title\": \"log4j pentest\",\n \"tester\" : \"Stipe\"\n}",
"raw": "{\n \"client\": \"Dio Stonemask Inc.\",\n \"title\": \"log4jj bizarre adventure\",\n \"tester\" : \"Jojo\"\n}",
"options": {
"raw": {
"language": "json"
@ -150,7 +150,7 @@
}
},
"url": {
"raw": "http://localhost:8443/projects/f2738715-4005-4aca-8d34-27ce9b8efffe",
"raw": "http://localhost:8443/projects/5a4f126c-9471-43b8-80b9-6eb02b7c35d0",
"protocol": "http",
"host": [
"localhost"
@ -158,7 +158,7 @@
"port": "8443",
"path": [
"projects",
"f2738715-4005-4aca-8d34-27ce9b8efffe"
"5a4f126c-9471-43b8-80b9-6eb02b7c35d0"
]
}
},
@ -261,10 +261,24 @@
{
"name": "getPentestsByProjectIdAndCategory",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICItdG1lbEV0ZHhGTnRSMW9aNXlRdE5jaFFpX0RVN2VNeV9YcU44aXY0S3hzIn0.eyJleHAiOjE2NjAxNDI5NjMsImlhdCI6MTY2MDE0MjY2MywianRpIjoiNzk2YzY5NzYtZjBlYS00ZTM0LTk2MTItMjI5ZmE0ODgzOTM0IiwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo4ODg4L2F1dGgvcmVhbG1zL2M0cG9fcmVhbG1fbG9jYWwiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiMTBlMDZkN2EtOGRkMC00ZWNkLTg5NjMtMDU2YjQ1MDc5YzRmIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiYzRwb19sb2NhbCIsInNlc3Npb25fc3RhdGUiOiIyYWU1MmQyYy01MjA5LTQzMjEtOWY5OS0wMTQ2YjRkMmNkY2YiLCJhY3IiOiIxIiwiYWxsb3dlZC1vcmlnaW5zIjpbIioiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImM0cG9fdXNlciIsIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJjNHBvX2xvY2FsIjp7InJvbGVzIjpbInVzZXIiXX0sImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwibmFtZSI6InRlc3QgdXNlciIsInByZWZlcnJlZF91c2VybmFtZSI6InR0dCIsImdpdmVuX25hbWUiOiJ0ZXN0IiwiZmFtaWx5X25hbWUiOiJ1c2VyIn0.EO5CC1VXZzybIx-lndq3b61TZpWOnYDI4F2CUFuxj5ECxrlIfm_tlv0TbErDTX311YsA_nhzNHYSaffRzx0OkmmUKSyyH8k9aPRKXUTUmY7Y9PLv3UCKEmAFHAnJkr5kZV08g3UMYG2blpryYBg82abEVMxeMUbh-T4M-Z9dcgQyiZ4nyNMUs1bbfH_2kAtqfEXmP_9eZ42Kwa2ixFWFZDcvOp775bjkYcGvwSnHqmyBXivONzTxyPN6Ug7uFCvMTbeo10ctgOFfXJUZfoxRt-hCspTPJR8C4TzIK41fiy19uRpGjeezG5Ghwy9upXsomunwB4knTAn1otmj4afIxw",
"type": "string"
},
{
"key": "undefined",
"type": "any"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8443/pentests?projectId=8bc16303-f652-418a-b745-8a03d89356fb&category=INFORMATION_GATHERING",
"raw": "http://localhost:8443/pentests?projectId=5a4f126c-9471-43b8-80b9-6eb02b7c35d0&category=INFORMATION_GATHERING",
"protocol": "http",
"host": [
"localhost"
@ -276,7 +290,7 @@
"query": [
{
"key": "projectId",
"value": "8bc16303-f652-418a-b745-8a03d89356fb"
"value": "5a4f126c-9471-43b8-80b9-6eb02b7c35d0"
},
{
"key": "category",

View File

@ -12,8 +12,8 @@ data class Pentest(
val title: String,
val refNumber: String,
val status: PentestStatus,
val findingIds: String,
val commentIds: String
val findingIds: List<String> = emptyList(),
val commentIds: List<String> = emptyList()
)
fun Pentest.toPentestResponseBody(): ResponseBody {

View File

@ -2,7 +2,10 @@ package com.securityc4po.api.project
import com.fasterxml.jackson.annotation.JsonFormat
import com.securityc4po.api.ResponseBody
import com.securityc4po.api.pentest.PentestStatus
import org.springframework.data.mongodb.core.index.Indexed
import java.math.RoundingMode
import java.text.DecimalFormat
import java.time.Instant
import java.util.UUID
@ -14,6 +17,7 @@ data class Project(
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
val createdAt: String = Instant.now().toString(),
val tester: String? = null,
val projectPentests: List<ProjectPentest> = emptyList(),
val createdBy: String
)
@ -24,6 +28,7 @@ fun buildProject(body: ProjectRequestBody, projectEntity: ProjectEntity): Projec
title = body.title,
createdAt = projectEntity.data.createdAt,
tester = body.tester,
projectPentests = projectEntity.data.projectPentests,
createdBy = projectEntity.data.createdBy
)
}
@ -35,6 +40,8 @@ fun Project.toProjectResponseBody(): ResponseBody {
"title" to title,
"createdAt" to createdAt,
"tester" to tester,
/* ToDo: Calculate percentage in BE type: float */
"testingProgress" to calculateProgress(),
"createdBy" to createdBy
)
}
@ -45,16 +52,31 @@ fun Project.toProjectDeleteResponseBody(): ResponseBody {
)
}
fun Project.calculateProgress(): Float {
// Total number of pentests listet in the OWASP testing guide
// https://owasp.org/www-project-web-security-testing-guide/assets/archive/OWASP_Testing_Guide_v4.pdf
val TOTALPENTESTS = 95
return if (projectPentests.isEmpty())
0F
else {
var completedPentests = 0
projectPentests.forEach { projectPentest ->
if (projectPentest.status == PentestStatus.TRIAGED) {
completedPentests++
}
}
val df = DecimalFormat("#.##")
df.roundingMode = RoundingMode.DOWN
val progress = completedPentests / TOTALPENTESTS
df.format(progress).toFloat()
}
}
data class ProjectOverview(
val projects: List<Project>
)
fun ProjectOverview.toProjectOverviewResponseBody(): ResponseBody {
return mapOf(
"projects" to projects
)
}
data class ProjectRequestBody(
val client: String,
val title: String,

View File

@ -30,7 +30,8 @@ class ProjectController(private val projectService: ProjectService) {
it.toProjectResponseBody()
}
}.map {
ResponseEntity.ok(it)
if (it.isEmpty()) ResponseEntity.noContent().build()
else ResponseEntity.ok(it)
}
}

View File

@ -18,6 +18,7 @@ fun ProjectEntity.toProject() : Project {
this.data.title,
this.data.createdAt,
this.data.tester,
this.data.projectPentests,
this.data.createdBy
)
}

View File

@ -0,0 +1,8 @@
package com.securityc4po.api.project
import com.securityc4po.api.pentest.PentestStatus
data class ProjectPentest(
val pentestId: String,
val status: PentestStatus
)

View File

@ -72,12 +72,12 @@ class ProjectService(private val projectRepository: ProjectRepository) {
* @return status code of deleted [Project]
*/
fun deleteProject(id: String): Mono<Project> {
return projectRepository.findProjectById(id).switchIfEmpty{
return projectRepository.findProjectById(id).switchIfEmpty {
logger.info("Project with id $id not found. Deletion not necessary.")
Mono.empty()
}.flatMap{ projectEntity: ProjectEntity ->
}.flatMap { projectEntity: ProjectEntity ->
val project = projectEntity.toProject()
projectRepository.deleteProjectById(id).map{project}
projectRepository.deleteProjectById(id).map { project }
}.onErrorMap {
TransactionInterruptedException(
"Deleting Project failed!",
@ -101,13 +101,15 @@ class ProjectService(private val projectRepository: ProjectRepository) {
"Project not valid.", Errorcode.ProjectInvalid
)
)
return projectRepository.findProjectById(id).switchIfEmpty{
logger.info("Project with id $id not found. Updating not possible.")
Mono.empty()
}.flatMap{projectEntity: ProjectEntity ->
return projectRepository.findProjectById(id).switchIfEmpty {
logger.warn("Project with id $id not found. Updating not possible.")
val msg = "Project with id $id not found."
val ex = EntityNotFoundException(msg, Errorcode.ProjectNotFound)
throw ex
}.flatMap { projectEntity: ProjectEntity ->
projectEntity.lastModified = Instant.now()
projectEntity.data = buildProject(body, projectEntity)
projectRepository.save(projectEntity).map{
projectRepository.save(projectEntity).map {
it.toProject()
}.doOnError {
throw wrappedException(
@ -120,4 +122,18 @@ class ProjectService(private val projectRepository: ProjectRepository) {
}
}
}
/**
* Update testing progress of [Project]
*
* @throws [TransactionInterruptedException] if the [Project] could not be updated
* @return updated list of [ProjectPentest]s
*/
fun updateProjectTestingProgress(
projectId: String,
projectPentests: ProjectPentest
)/*: Mono<List<ProjectPentest>>*/ {
// ToDo: update Project Entity with progress
}
}

View File

@ -81,10 +81,10 @@ class PentestControllerDocumentationTest : BaseDocumentationIntTest() {
.description("The reference number of the requested pentest according to the current OWASP Testing Guide"),
PayloadDocumentation.fieldWithPath("[].status").type(JsonFieldType.STRING)
.description("The status of the requested pentest"),
PayloadDocumentation.fieldWithPath("[].findingIds").type(JsonFieldType.STRING)
.description("The ids of the findings in the requested pentest"),
PayloadDocumentation.fieldWithPath("[].commentIds").type(JsonFieldType.STRING)
.description("The ids of the comments of the requested pentest")
PayloadDocumentation.fieldWithPath("[].findingIds").type(JsonFieldType.ARRAY)
.description("List of ids of the findings in the requested pentest"),
PayloadDocumentation.fieldWithPath("[].commentIds").type(JsonFieldType.ARRAY)
.description("List of ids of the comments of the requested pentest")
)
)
)
@ -97,8 +97,8 @@ class PentestControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Search engine discovery/reconnaissance",
refNumber = "OTG-INFO-001",
status = PentestStatus.NOT_STARTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
private val pentestTwo = Pentest(
id = "43fbc63c-f624-11ec-b939-0242ac120002",
@ -107,8 +107,8 @@ class PentestControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Fingerprint Web Server",
refNumber = "OTG-INFO-002",
status = PentestStatus.REPORTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
private fun getProjectsResponse() = listOf(
@ -126,8 +126,8 @@ class PentestControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Search engine discovery/reconnaissance",
refNumber = "OTG-INFO-001",
status = PentestStatus.NOT_STARTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
val pentestTwo = Pentest(
id = "43fbc63c-f624-11ec-b939-0242ac120002",
@ -136,8 +136,8 @@ class PentestControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Fingerprint Web Server",
refNumber = "OTG-INFO-002",
status = PentestStatus.REPORTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
val pentestThree = Pentest(
id = "74eae112-f62c-11ec-b939-0242ac120002",
@ -146,8 +146,8 @@ class PentestControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Testing for Credentials Transported over an Encrypted Channel",
refNumber = "OTG-AUTHN-001",
status = PentestStatus.CHECKED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
// persist test data in database
mongoTemplate.save(PentestEntity(pentestOne))

View File

@ -72,8 +72,8 @@ class PentestControllerIntTest : BaseIntTest() {
title = "Search engine discovery/reconnaissance",
refNumber = "OTG-INFO-001",
status = PentestStatus.NOT_STARTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
private val pentestTwo = Pentest(
id = "43fbc63c-f624-11ec-b939-0242ac120002",
@ -82,8 +82,8 @@ class PentestControllerIntTest : BaseIntTest() {
title = "Fingerprint Web Server",
refNumber = "OTG-INFO-002",
status = PentestStatus.REPORTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
private fun getPentests() = listOf(
@ -101,8 +101,8 @@ class PentestControllerIntTest : BaseIntTest() {
title = "Search engine discovery/reconnaissance",
refNumber = "OTG-INFO-001",
status = PentestStatus.NOT_STARTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
val pentestTwo = Pentest(
id = "43fbc63c-f624-11ec-b939-0242ac120002",
@ -111,8 +111,8 @@ class PentestControllerIntTest : BaseIntTest() {
title = "Fingerprint Web Server",
refNumber = "OTG-INFO-002",
status = PentestStatus.REPORTED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
val pentestThree = Pentest(
id = "74eae112-f62c-11ec-b939-0242ac120002",
@ -121,8 +121,8 @@ class PentestControllerIntTest : BaseIntTest() {
title = "Testing for Credentials Transported over an Encrypted Channel",
refNumber = "OTG-AUTHN-001",
status = PentestStatus.CHECKED,
findingIds = "",
commentIds = ""
findingIds = emptyList(),
commentIds = emptyList()
)
// persist test data in database
mongoTemplate.save(PentestEntity(pentestOne))

View File

@ -74,7 +74,9 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
PayloadDocumentation.fieldWithPath("[].tester").type(JsonFieldType.STRING)
.description("The user that is assigned as a tester in the project"),
PayloadDocumentation.fieldWithPath("[].createdBy").type(JsonFieldType.STRING)
.description("The id of the user that created the project")
.description("The id of the user that created the project"),
PayloadDocumentation.fieldWithPath("[].testingProgress").type(JsonFieldType.NUMBER)
.description("The progress of the project from completed pentests")
)
)
)
@ -86,6 +88,7 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Some Mock API (v1.0) Scanning",
createdAt = "2021-01-10T18:05:00Z",
tester = "Novatester",
projectPentests = emptyList<ProjectPentest>(),
createdBy = "f8aab31f-4925-4242-a6fa-f98135b4b032"
)
val projectTwo = Project(
@ -94,6 +97,7 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
title = "CashMyData (iOS)",
createdAt = "2021-01-10T18:05:00Z",
tester = "Elliot",
projectPentests = emptyList<ProjectPentest>(),
createdBy = "f8aab31f-4925-4242-a6fa-f98135b4b032"
)
@ -137,7 +141,9 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
PayloadDocumentation.fieldWithPath("tester").type(JsonFieldType.STRING)
.description("The user that is assigned as a tester in the project"),
PayloadDocumentation.fieldWithPath("createdBy").type(JsonFieldType.STRING)
.description("The id of the user that created the project")
.description("The id of the user that created the project"),
PayloadDocumentation.fieldWithPath("testingProgress").type(JsonFieldType.NUMBER)
.description("The progress of the project from completed pentests")
)
)
)
@ -218,6 +224,7 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Some Mock API (v1.0) Scanning",
createdAt = "2021-01-10T18:05:00Z",
tester = "Novatester",
projectPentests = emptyList<ProjectPentest>(),
createdBy = "f8aab31f-4925-4242-a6fa-f98135b4b032"
)
}
@ -228,11 +235,11 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
fun updateProject() {
webTestClient.patch().uri("/projects/${projectUpdate.id}")
.header("Authorization", "Bearer $tokenAdmin")
.body(Mono.just(projectUpdate), ProjectRequestBody::class.java)
.body(Mono.just(projectUpdateRequest), ProjectRequestBody::class.java)
.exchange()
.expectStatus().isAccepted
.expectHeader().valueEquals("Application-Name", "SecurityC4PO")
.expectBody().json(Json.write(projectUpdate))
.expectBody().json(Json.write(projectUpdate.toProjectResponseBody()))
.consumeWith(
WebTestClientRestDocumentation.document(
"{methodName}",
@ -256,18 +263,27 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
PayloadDocumentation.fieldWithPath("tester").type(JsonFieldType.STRING)
.description("The updated user that is assigned as a tester in the project"),
PayloadDocumentation.fieldWithPath("createdBy").type(JsonFieldType.STRING)
.description("The id of the user that created the project")
.description("The id of the user that created the project"),
PayloadDocumentation.fieldWithPath("testingProgress").type(JsonFieldType.NUMBER)
.description("The progress of the project from completed pentests")
)
)
)
}
val projectUpdateRequest = ProjectRequestBody(
client = "Novatec_updated",
title = "log4j Pentest_updated",
tester = "Stipe_updated"
)
val projectUpdate = Project(
id = "4f6567a8-76fd-487b-8602-f82d0ca4d1f9",
client = "Novatec_updated",
title = "log4j Pentest_updated",
createdAt = "2021-01-10T18:05:00Z",
tester = "Stipe_updated",
projectPentests = emptyList<ProjectPentest>(),
createdBy = "f8aab31f-4925-4242-a6fa-f98135b4b032"
)
}
@ -280,6 +296,7 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
title = "Some Mock API (v1.0) Scanning",
createdAt = "2021-01-10T18:05:00Z",
tester = "Novatester",
projectPentests = emptyList<ProjectPentest>(),
createdBy = "f8aab31f-4925-4242-a6fa-f98135b4b032"
)
val projectTwo = Project(
@ -288,6 +305,7 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
title = "CashMyData (iOS)",
createdAt = "2021-01-10T18:05:00Z",
tester = "Elliot",
projectPentests = emptyList<ProjectPentest>(),
createdBy = "f8aab31f-4925-4242-a6fa-f98135b4b032"
)
// persist test data in database

View File

@ -1,55 +1,58 @@
[{
"_id": {
"$oid": "62c4018f18f1f463ed1e11be"
"$oid": "62f3c50c7acde34f740ba737"
},
"lastModified": {
"$date": {
"$numberLong": "1657012623629"
"$numberLong": "1660142860140"
}
},
"data": {
"_id": "41051d0a-63ef-4290-b984-e6fbd736f218",
"_id": "5a4f126c-9471-43b8-80b9-6eb02b7c35d0",
"client": "E Corp",
"title": "Some Mock API (v1.0) Scanning",
"createdAt": "2022-07-05T09:17:03.629331Z",
"createdAt": "2022-08-10T14:47:40.140406Z",
"tester": "Novatester",
"createdBy": "ca447a34-cac3-495e-9295-0a5bf5de502a"
"projectPentests": [],
"createdBy": "3c4ae87f-0d56-4634-a824-b4883c403c8a"
},
"_class": "com.securityc4po.api.project.ProjectEntity"
},{
"_id": {
"$oid": "62c401b718f1f463ed1e11bf"
"$oid": "62f3c5317acde34f740ba738"
},
"lastModified": {
"$date": {
"$numberLong": "1657012663386"
"$numberLong": "1660142897912"
}
},
"data": {
"_id": "0fa17ddb-7094-4f9c-b295-3433244c32c2",
"_id": "42b8c0df-b70e-4526-8ed0-7c022195fe85",
"client": "Allsafe",
"title": "CashMyData (iOS)",
"createdAt": "2022-07-05T09:17:43.386782Z",
"createdAt": "2022-08-10T14:48:17.912592Z",
"tester": "Elliot",
"createdBy": "1ac9753a-5a62-4bf7-8412-6fde779ea33a"
"projectPentests": [],
"createdBy": "6740ad72-8f42-486a-bcf3-e057e6afb0de"
},
"_class": "com.securityc4po.api.project.ProjectEntity"
},{
"_id": {
"$oid": "62c401e318f1f463ed1e11c0"
"$oid": "62f3c5427acde34f740ba739"
},
"lastModified": {
"$date": {
"$numberLong": "1657012707557"
"$numberLong": "1660142914204"
}
},
"data": {
"_id": "85aa8d79-5899-4b68-894c-d07f3b168cd4",
"_id": "1120bfa1-0d2b-4e42-a209-0289a1256266",
"client": "Novatec",
"title": "Openspace log4J",
"createdAt": "2022-07-05T09:18:27.557740Z",
"createdAt": "2022-08-10T14:48:34.204234Z",
"tester": "mhg",
"createdBy": "3201f6f8-10a4-4826-9b49-b6bdef28b152"
"projectPentests": [],
"createdBy": "5a4a8032-0726-4851-a105-9f079c3989b9"
},
"_class": "com.securityc4po.api.project.ProjectEntity"
}]