Skip to content

Commit 930a5a7

Browse files
committed
More YAML Parsng in Task Description section
1 parent 0594a50 commit 930a5a7

4 files changed

Lines changed: 122 additions & 49 deletions

File tree

src/app/app-routing.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { RouterModule, Routes } from '@angular/router';
33
import { CircularHeatmapComponent } from './component/circular-heatmap/circular-heatmap.component';
44
import { MainContentComponent } from './component/main-content/main-content.component';
55
import { MatrixComponent } from './component/matrix/matrix.component';
6+
import { TaskDescriptionComponent } from './component/task-description/task-description.component';
67

78

89
const routes: Routes = [
910
{path: '',component: MainContentComponent},
1011
{path: 'matrix', component: MatrixComponent},
11-
{path: 'circular-heatmap', component: CircularHeatmapComponent}
12+
{path: 'circular-heatmap', component: CircularHeatmapComponent},
13+
{path: 'task-description', component: TaskDescriptionComponent}
1214
];
1315

1416
@NgModule({

src/app/component/task-description/task-description.component.html

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,43 @@ <h1>{{currentTask.dimension}} -> {{currentTask.subDimension}}: Building and test
1111
<b>Description</b>
1212
</mat-panel-title>
1313
</mat-expansion-panel-header>
14-
<p [innerHTML]="description"></p>
15-
</mat-expansion-panel>
14+
<p [innerHTML]="currentTask.description"></p>
15+
</mat-expansion-panel>
1616
<mat-expansion-panel>
1717
<mat-expansion-panel-header>
1818
<mat-panel-title>
1919
<b>Risk</b>
2020
</mat-panel-title>
2121
</mat-expansion-panel-header>
22-
<p [innerHTML]="risk"></p>
22+
<ul *ngFor="let risk of currentTask.risk">
23+
<li>{{risk}}</li>
24+
</ul>
2325
</mat-expansion-panel>
2426
<mat-expansion-panel>
2527
<mat-expansion-panel-header>
2628
<mat-panel-title>
2729
<b>Measure</b>
2830
</mat-panel-title>
2931
</mat-expansion-panel-header>
30-
<p [innerHTML]="measure"></p>
32+
<p [innerHTML]="currentTask.measure"></p>
3133
</mat-expansion-panel>
3234
<mat-expansion-panel>
3335
<mat-expansion-panel-header>
3436
<mat-panel-title>
3537
<b>Implementation Guide</b>
3638
</mat-panel-title>
3739
</mat-expansion-panel-header>
38-
<p>Depending on your environment, usage of virtual machines
39-
or container technology is a good way. After the build, the filesystem should
40-
not be used again in other builds.</p>
40+
<p [innerHTML]="currentTask.implementatonGuide"></p>
4141
</mat-expansion-panel>
4242
<mat-expansion-panel>
4343
<mat-expansion-panel-header>
4444
<mat-panel-title>
4545
<b>Difficulty Of Implementation</b>
4646
</mat-panel-title>
4747
</mat-expansion-panel-header>
48-
<p>Knowledge: 2 </p>
49-
<p>Time: 2 </p>
50-
<p>Resources: 2 </p>
48+
<p>Knowledge: {{this.currentTask.knowledge}} </p>
49+
<p>Time: {{this.currentTask.time}} </p>
50+
<p>Resources: {{this.currentTask.resources}}</p>
5151
</mat-expansion-panel>
5252
<mat-expansion-panel>
5353
<mat-expansion-panel-header>
@@ -141,23 +141,33 @@ <h1>{{currentTask.dimension}} -> {{currentTask.subDimension}}: Building and test
141141
<b>OWASP SAMM VERSION 2</b>
142142
</mat-panel-title>
143143
</mat-expansion-panel-header>
144-
<p>
145-
I-SB-2-A
146-
</p>
144+
<ul *ngFor="let samm of currentTask.samm">
145+
<li>{{samm}}</li>
146+
</ul>
147147
</mat-expansion-panel>
148148
<mat-expansion-panel>
149149
<mat-expansion-panel-header>
150150
<mat-panel-title>
151151
<b>ISO27001 2017</b>
152152
</mat-panel-title>
153153
</mat-expansion-panel-header>
154-
<p>
155-
iso27001-2017:14.2.6
156-
</p>
154+
<ul *ngFor="let iso of currentTask.iso">
155+
<li>{{iso}}</li>
156+
</ul>
157157
</mat-expansion-panel>
158158
</mat-accordion>
159159
</p>
160160
</mat-expansion-panel>
161+
<mat-expansion-panel>
162+
<mat-expansion-panel-header>
163+
<mat-panel-title>
164+
<b>Depends on</b>
165+
</mat-panel-title>
166+
</mat-expansion-panel-header>
167+
<ul *ngFor="let dependency of this.currentTask.dependsOn">
168+
<li>{{dependency}}</li>
169+
</ul>
170+
</mat-expansion-panel>
161171
</mat-accordion>
162172
</div>
163173

src/app/component/task-description/task-description.component.ts

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ export interface taskDescription {
1010
level:string
1111
taskIndex:number
1212
description:string
13-
risk: string
13+
risk: string[]
1414
measure: string
15+
implementatonGuide:string
16+
iso:string[]
17+
samm:string[]
18+
knowledge:number
19+
resources:number
20+
time:number
21+
dependsOn:string[]
1522
}
1623

1724
@Component({
@@ -21,15 +28,14 @@ export interface taskDescription {
2128
})
2229
export class TaskDescriptionComponent implements OnInit {
2330

24-
currentTask: taskDescription={dimension:'',subDimension:'',level:'',taskIndex:-1,description:'',risk:'',measure:''}
31+
currentTask: taskDescription={dimension:'',subDimension:'',level:'',taskIndex:-1,description:'',risk:[],
32+
measure:'',implementatonGuide:'',samm:[''],iso:[''],knowledge:-1,resources:-1,
33+
time:-1,dependsOn:[]}
2534

2635
YamlObject:any;
2736

2837
rowIndex:number=0;
2938
markdown:md = md()
30-
description:any;
31-
risk:any;
32-
measure:any;
3339

3440
@ViewChildren(MatAccordion) accordion!: QueryList<MatAccordion>;
3541
constructor(private route: ActivatedRoute,private yaml:ymlService) { }
@@ -59,23 +65,72 @@ export class TaskDescriptionComponent implements OnInit {
5965
catch{
6066
console.log('Task does not exist!')
6167
}
68+
var data =this.YamlObject['dimension'][this.rowIndex]['subdimension']
69+
[this.currentTask.level][this.currentTask.taskIndex]
70+
71+
72+
this.currentTask.description=this.defineStringValues(data['description'],'')
73+
this.currentTask.risk=this.defineStringArrayValues(data['risk'],[])
74+
this.currentTask.measure=this.defineStringValues(data['measure'],'')
75+
try{
76+
data['meta']
77+
this.currentTask.implementatonGuide=this.defineStringValues(data['meta']['implementationGuide'],'')
78+
}
79+
catch{
80+
console.log('Meta does not exist')
81+
}
82+
try{
83+
data['difficultyOfImplementation']
84+
this.currentTask.knowledge=this.defineIntegerValues(data['difficultyOfImplementation']['knowledge'],-1)
85+
this.currentTask.time=this.defineIntegerValues(data['difficultyOfImplementation']['time'],-1)
86+
this.currentTask.resources=this.defineIntegerValues(data['difficultyOfImplementation']['resources'],-1)
87+
}
88+
catch{
89+
console.log('difficultyOfImplementation does not exist')
90+
}
91+
try{
92+
data['references']
93+
this.currentTask.iso=this.defineStringArrayValues(data['iso27001-2017'],[])
94+
this.currentTask.samm=this.defineStringArrayValues(data['samm2'],[])
95+
}
96+
catch{
97+
console.log('references does not exist')
98+
}
6299

63-
this.currentTask.description = this.YamlObject['dimension'][this.rowIndex]['subdimension']
64-
[this.currentTask.level][this.currentTask.taskIndex]['description']
65-
this.currentTask.risk = this.YamlObject['dimension'][this.rowIndex]['subdimension']
66-
[this.currentTask.level][this.currentTask.taskIndex]['risk']
67-
this.currentTask.measure = this.YamlObject['dimension'][this.rowIndex]['subdimension']
68-
[this.currentTask.level][this.currentTask.taskIndex]['measure']
69-
this.measure=this.markdown.render(this.currentTask.measure);
70-
this.description=this.markdown.render(this.currentTask.description);
71-
this.risk=this.markdown.render(this.currentTask.risk);
100+
this.currentTask.dependsOn=this.defineStringArrayValues(data['dependsOn'],[])
101+
102+
//console.log(this.measure)
72103

73-
74-
console.log('ere')
75104
})
76105
}
77106

107+
defineStringValues(dataToCheck:string,valueOfDataIfUndefined:string): string{
108+
try{
109+
return this.markdown.render(dataToCheck)
110+
}
111+
catch{
112+
return valueOfDataIfUndefined
113+
}
114+
}
115+
116+
defineStringArrayValues(dataToCheck:string[],valueOfDataIfUndefined:string[]): string[]{
117+
try{
118+
return dataToCheck
119+
}
120+
catch{
121+
return valueOfDataIfUndefined
122+
}
123+
}
78124

125+
defineIntegerValues(dataToCheck:number,valueOfDataIfUndefined:number): number{
126+
try{
127+
return dataToCheck
128+
}
129+
catch{
130+
return valueOfDataIfUndefined
131+
}
132+
}
133+
79134

80135
// Expand all function
81136
openall(): void{

src/assets/YAML/generated/sample.yaml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ dimension:
3737
- iso27001-2017:14.2.6
3838
samm2:
3939
- I-SB-1-A
40-
risk: Quality is not visible to everyone, quality checks are distributed or
40+
risk:
41+
- Quality is not visible to everyone, quality checks are distributed or
4142
manually and not deterministic.
4243
usefulness: 2
4344
- dependsOn:
@@ -98,12 +99,10 @@ dimension:
9899
- iso27001-2017:14.2.6
99100
samm2:
100101
- I-SB-2-A
101-
risk:
102-
- 'While building and testing artifacts, third party systems, application frameworks
103-
102+
risk:
103+
- While building and testing artifacts, third party systems, application frameworks
104104
and 3rd party libraries are used. These might be malicious as a result of
105-
106-
vulnerable libraries or because they are altered during the delivery phase.'
105+
vulnerable libraries or because they are altered during the delivery phase.
107106
usefulness: 2
108107
- comment: The usage of pinning requires a good processes for patching. Therefore,
109108
choose this activity wisly.
@@ -145,8 +144,7 @@ dimension:
145144
measure: Creation of an SBOM of components (e.g. application and container image
146145
content) during build.
147146
name: SBOM of components
148-
risk:
149-
- In case a vulnerability of severity high or critical exists, it needs to be
147+
risk: In case a vulnerability of severity high or critical exists, it needs to be
150148
known where an artifacts with that vulnerability is deployed with which dependencies.
151149
usefulness: 3
152150
level-3:
@@ -164,7 +162,8 @@ dimension:
164162
references:
165163
iso27001-2017:
166164
- 14.2.6
167-
samm2: I-SB-2-A
165+
samm2:
166+
- I-SB-2-A
168167
risk:
169168
- Unauthorized manipulation of source code might be difficult to spot.
170169
usefulness: 3
@@ -213,7 +212,8 @@ dimension:
213212
iso27001-2017:
214213
- 12.1.1
215214
- 14.2.2
216-
samm2: I-SD-1-A
215+
samm2:
216+
- I-SD-1-A
217217
risk:
218218
- Deployments without a defined process are error prone thus allowing old or
219219
untested artifact to be deployed.
@@ -265,7 +265,8 @@ dimension:
265265
risk:
266266
- Developers or operations might start random images in the production cluster
267267
which have malicious code or known vulnerabilities.
268-
samm2: I-SD-2-A
268+
samm2:
269+
- I-SD-2-A
269270
usefulness: 3
270271
- difficultyOfImplementation:
271272
knowledge: 1
@@ -305,7 +306,8 @@ dimension:
305306
name: Rolling update on deployment
306307
risk:
307308
- While a deployment is performed, the application can not be reached.
308-
samm2: I-SD-1-A
309+
samm2:
310+
- I-SD-1-A
309311
usefulness: 2
310312
- dependsOn:
311313
- Defined build process
@@ -326,7 +328,8 @@ dimension:
326328
risk:
327329
- Building of an artifact for different environments means that an untested
328330
artifact might reach the production environment.
329-
samm2: I-SD-2-A
331+
samm2:
332+
- I-SD-2-A
330333
usefulness: 4
331334
- dependsOn:
332335
- Environment depending configuration parameters (secrets)
@@ -347,7 +350,8 @@ dimension:
347350
- 9.4.3
348351
- 9.4.1
349352
- 10.1.2
350-
samm2: I-SD-2-B
353+
samm2:
354+
- I-SD-2-B
351355
risk:
352356
- Attackers who compromise a system can see confidential access information
353357
like database credentials.
@@ -394,7 +398,8 @@ dimension:
394398
- In case a vulnerability of severity high or critical exists, it needs to be
395399
known where an artifacts (e.g. container image) with that vulnerability is
396400
deployed.
397-
samm2: I-SD-2-A
401+
samm2:
402+
- I-SD-2-A
398403
usefulness: 3
399404
- dependesOn:
400405
- SBOM of components
@@ -417,7 +422,8 @@ dimension:
417422
- In case a vulnerability of severity high or critical is known by the organization,
418423
it needs to be known where an artifacts with that vulnerability is deployed
419424
with which dependencies.
420-
samm2: I-SD-2-A
425+
samm2:
426+
- I-SD-2-A
421427
usefulness: 3
422428
level-4:
423429
- dependsOn:

0 commit comments

Comments
 (0)