Skip to content

Commit d69ea04

Browse files
authored
Merge pull request #36 from wurstbrot/feat/meta
Add meta info
2 parents 7355b5b + d1ed4b3 commit d69ea04

File tree

3 files changed

+81
-39
lines changed

3 files changed

+81
-39
lines changed

data.php

Lines changed: 70 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
$files = scandir("data");
55

6-
function readYaml($file) {
6+
function readYaml($file)
7+
{
78
return yaml_parse(
89
file_get_contents($file)
910
);
@@ -28,19 +29,19 @@ function readYaml($file) {
2829
}
2930
}
3031

31-
if(array_key_exists("performed", $_GET)) {
32+
if (array_key_exists("performed", $_GET)) {
3233
$showPerformed = $_GET['performed'];
33-
34-
if($showPerformed != "true") $showPerformed = false;
35-
}else {
34+
35+
if ($showPerformed != "true") $showPerformed = false;
36+
} else {
3637
$showPerformed = false;
3738
}
3839

39-
if(array_key_exists("planned", $_GET)) {
40+
if (array_key_exists("planned", $_GET)) {
4041
$showPlanned = $_GET['planned'];
4142

42-
if($showPlanned != "true") $showPlanned = false;
43-
}else {
43+
if ($showPlanned != "true") $showPlanned = false;
44+
} else {
4445
$showPlanned = false;
4546
}
4647
$filteredDimensions = array();
@@ -49,25 +50,25 @@ function readYaml($file) {
4950
foreach ($subDimension as $subDimensionName => $elements) {
5051
$newElements = $elements;
5152
ksort($newElements);
52-
foreach($newElements as $activityName => $activity) {
53-
if(elementIsSelected($activityName) && !$showPerformed) {
53+
foreach ($newElements as $activityName => $activity) {
54+
if (elementIsSelected($activityName) && !$showPerformed) {
5455
continue;
5556
}
5657

57-
if(!elementIsSelected($activityName) && !$showPlanned) {
58+
if (!elementIsSelected($activityName) && !$showPlanned) {
5859
continue;
59-
}
60+
}
6061
$filteredDimensions[$dimensionName][$subDimensionName][$activityName] = $activity;
6162
}
62-
63+
6364
}
6465
}
6566

6667

6768
function getDifficultyOfImplementationWithDependencies($dimensions, $elementImplementation, &$allElements)
6869
{
69-
if($elementImplementation == null) {
70-
return ;
70+
if ($elementImplementation == null) {
71+
return;
7172
}
7273
$knowledge = getKnowledge($elementImplementation);
7374

@@ -94,8 +95,8 @@ function getDifficultyOfImplementationWithDependencies($dimensions, $elementImpl
9495

9596
function getDifficultyOfImplementation($dimensions, $elementImplementation)
9697
{
97-
if($elementImplementation == null) {
98-
return ;
98+
if ($elementImplementation == null) {
99+
return;
99100
}
100101
$knowledge = getKnowledge($elementImplementation);
101102

@@ -131,6 +132,49 @@ function getKnowledge($elementImplementation)
131132
return $knowledge;
132133
}
133134

135+
function getElementContentAndCheckExistence($parent, $name)
136+
{
137+
if (array_key_exists($name, $parent)) {
138+
return getElementContent($parent[$name]);
139+
}
140+
return "";
141+
}
142+
143+
function getElementContent($element)
144+
{
145+
$contentString = "";
146+
if (is_array($element)) {
147+
if (isAssoc($element)) {
148+
foreach ($element as $title => $elementContent) {
149+
$titleWithSpace = preg_replace('/(?<=[a-z])[A-Z]|[A-Z](?=[a-z])/', ' $0', $title);
150+
$contentString .= "<b>" . ucfirst($titleWithSpace) . "</b>";
151+
$contentString .= "<ul>";
152+
if (is_array($elementContent)) {
153+
$contentString .= getElementContent($elementContent);
154+
} else
155+
$contentString .= "<li>" . str_replace("\"", "'", $elementContent) . "</li>";
156+
$contentString .= "</ul>";
157+
}
158+
159+
} else {
160+
$contentString .= "<ul>";
161+
foreach ($element as $content) {
162+
$contentString .= "<li>" . str_replace("\"", "'", $content) . "</li>";
163+
}
164+
$contentString .= "</ul>";
165+
}
166+
167+
} else {
168+
$contentString = str_replace("\"", "'", $element);
169+
}
170+
return $contentString;
171+
}
172+
173+
function isAssoc(array $arr)
174+
{
175+
if (array() === $arr) return false;
176+
return array_keys($arr) !== range(0, count($arr) - 1);
177+
}
134178

135179
function build_table_tooltip($array, $headerWeight = 2)
136180
{
@@ -139,33 +183,24 @@ function build_table_tooltip($array, $headerWeight = 2)
139183
$mapResources = $mapTime;
140184
$mapUsefulness = $mapTime;
141185

142-
$evidenceContent = "";
143-
if(array_key_exists("evidence", $array)) {
144-
if( is_array($array['evidence'])) {
145-
$evidenceContent .= "<ul>";
146-
foreach($array['evidence'] as $content) {
147-
$evidenceContent .= "<li>".str_replace("\"", "'", $content) . "</li>";
148-
}
149-
$evidenceContent .= "</ul>";
150-
}else {
151-
$evidenceContent = str_replace("\"", "'", $array['evidence']);
152-
}
153-
}else {
186+
getElementContentAndCheckExistence($array, "meta");
187+
$evidenceContent = getElementContentAndCheckExistence($array, "evidence");
188+
if ($evidenceContent == "") {
154189
$evidenceContent = "TODO";
155190
}
156191

157192
$html = "";
158193
$html .= "<h" . $headerWeight . ">Risk and Opportunity</h$headerWeight>";
159194
$html .= "<div><b>" . "Risk" . ":</b> " . $array['risk'] . "</div>";
160195
$html .= "<div><b>" . "Opportunity" . ":</b> " . $array['measure'] . "</div>";
161-
if(IS_SHOW_EVIDENCE_TODO || $evidenceContent != "TODO")
162-
$html .= "<div><b>" . "Evidence" . ":</b> " . $evidenceContent . "</div>";
196+
if (IS_SHOW_EVIDENCE_TODO || $evidenceContent != "TODO")
197+
$html .= "<div><b>" . "Evidence" . ":</b> " . $evidenceContent . "</div>";
163198
$html .= "<hr />";
164199
$html .= "<h$headerWeight>Exploit details</h$headerWeight>";
165-
$html .= "<div><b>Usefullness:</b> " . ucfirst($mapUsefulness[$array['usefulness']-1]) . "</div>";
166-
$html .= "<div><b>Required knowledge:</b> " . ucfirst($mapKnowLedge[$array['difficultyOfImplementation']['knowledge']-1]) . "</div>";
167-
$html .= "<div><b>Required time:</b> " . ucfirst($mapTime[$array['difficultyOfImplementation']['time']-1]) . "</div>";
168-
$html .= "<div><b>Required resources (systems):</b> " . ucfirst($mapResources[$array['difficultyOfImplementation']['resources']-1]) . "</div>";
200+
$html .= "<div><b>Usefullness:</b> " . ucfirst($mapUsefulness[$array['usefulness'] - 1]) . "</div>";
201+
$html .= "<div><b>Required knowledge:</b> " . ucfirst($mapKnowLedge[$array['difficultyOfImplementation']['knowledge'] - 1]) . "</div>";
202+
$html .= "<div><b>Required time:</b> " . ucfirst($mapTime[$array['difficultyOfImplementation']['time'] - 1]) . "</div>";
203+
$html .= "<div><b>Required resources (systems):</b> " . ucfirst($mapResources[$array['difficultyOfImplementation']['resources'] - 1]) . "</div>";
169204
return $html;
170205
}
171206

data/BuildandDeployment.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ Build:
66
libraries or because they are altered during the delivery phase.
77
measure: Each step during within the build and testing phase is performed in a separate virtual
88
environments, which is destroyed afterward.
9+
meta:
10+
implementationGuide: Depending on your envirnoment, usage of virtual machines or container technoligy is a good way. After the build, the filesystem should not be used again in other builds.
911
difficultyOfImplementation:
1012
knowledge: 2
1113
time: 2
1214
resources: 2
1315
usefulness: 2
14-
level: 4
15-
implementation: Docker
16+
implementation:
17+
- Container technologies and orchestration like Docker, Kubernetes
18+
- CI/CD Tools, e.g. Jenkins
19+
level: 2
1620
samm2: i-secure-build|A|2
1721
iso27001-2017:
1822
- 14.2.6
@@ -28,7 +32,9 @@ Build:
2832
resources: 2
2933
usefulness: 4
3034
level: 1
31-
implementation: "Jenkins, Docker"
35+
implementation:
36+
- CI/CD Tools, e.g. Jenkins
37+
- Container technologies and orchestration like Docker, Kubernetes
3238
samm2: i-secure-build|A|1
3339
iso27001-2017:
3440
- 12.1.1

detail.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function printDetail($dimension, $subdimension, $activityName, $dimensions, $rep
4343
echo build_table_tooltip($element, $headerWeight + 1);
4444
echo "<hr/>";
4545

46-
if (array_key_exists("dependsOn", $element) || array_key_exists("implementation", $element) || array_key_exists("comment", $element)) {
46+
if (array_key_exists("dependsOn", $element) || array_key_exists("implementation", $element) || array_key_exists("comment", $element) || array_key_exists("meta", $element)) {
4747
echo "<h" . ($headerWeight + 1) . ">Additional Information</h" . ($headerWeight + 1) . ">";
4848
if (array_key_exists("dependsOn", $element)) {
4949
$dependsOn = $element['dependsOn'];
@@ -59,6 +59,7 @@ function printDetail($dimension, $subdimension, $activityName, $dimensions, $rep
5959

6060
echo "<div><b>Dependencies:</b> $dependencies</div>";
6161
}
62+
echo getElementContentAndCheckExistence($element, "meta");
6263
}
6364

6465

0 commit comments

Comments
 (0)