Skip to content

Commit cae136f

Browse files
committed
Add meta info
1 parent 7355b5b commit cae136f

File tree

3 files changed

+90
-39
lines changed

3 files changed

+90
-39
lines changed

data.php

Lines changed: 77 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

@@ -92,10 +93,15 @@ function getDifficultyOfImplementationWithDependencies($dimensions, $elementImpl
9293
}
9394
}
9495

96+
function getMeta($dimensions, $elementImplementation)
97+
{
98+
99+
}
100+
95101
function getDifficultyOfImplementation($dimensions, $elementImplementation)
96102
{
97-
if($elementImplementation == null) {
98-
return ;
103+
if ($elementImplementation == null) {
104+
return;
99105
}
100106
$knowledge = getKnowledge($elementImplementation);
101107

@@ -131,6 +137,51 @@ function getKnowledge($elementImplementation)
131137
return $knowledge;
132138
}
133139

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

135186
function build_table_tooltip($array, $headerWeight = 2)
136187
{
@@ -139,33 +190,24 @@ function build_table_tooltip($array, $headerWeight = 2)
139190
$mapResources = $mapTime;
140191
$mapUsefulness = $mapTime;
141192

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 {
193+
getElementContentAndCheckExistence($array, "meta");
194+
$evidenceContent = getElementContentAndCheckExistence($array, "evidence");
195+
if ($evidenceContent == "") {
154196
$evidenceContent = "TODO";
155197
}
156198

157199
$html = "";
158200
$html .= "<h" . $headerWeight . ">Risk and Opportunity</h$headerWeight>";
159201
$html .= "<div><b>" . "Risk" . ":</b> " . $array['risk'] . "</div>";
160202
$html .= "<div><b>" . "Opportunity" . ":</b> " . $array['measure'] . "</div>";
161-
if(IS_SHOW_EVIDENCE_TODO || $evidenceContent != "TODO")
162-
$html .= "<div><b>" . "Evidence" . ":</b> " . $evidenceContent . "</div>";
203+
if (IS_SHOW_EVIDENCE_TODO || $evidenceContent != "TODO")
204+
$html .= "<div><b>" . "Evidence" . ":</b> " . $evidenceContent . "</div>";
163205
$html .= "<hr />";
164206
$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>";
207+
$html .= "<div><b>Usefullness:</b> " . ucfirst($mapUsefulness[$array['usefulness'] - 1]) . "</div>";
208+
$html .= "<div><b>Required knowledge:</b> " . ucfirst($mapKnowLedge[$array['difficultyOfImplementation']['knowledge'] - 1]) . "</div>";
209+
$html .= "<div><b>Required time:</b> " . ucfirst($mapTime[$array['difficultyOfImplementation']['time'] - 1]) . "</div>";
210+
$html .= "<div><b>Required resources (systems):</b> " . ucfirst($mapResources[$array['difficultyOfImplementation']['resources'] - 1]) . "</div>";
169211
return $html;
170212
}
171213

data/BuildandDeployment.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ 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+
- CI/CD Tools, e.g. Jenkins
18+
- Container technologies and orchestration like Docker, Kubernetes
19+
level: 2
20+
- Container technologies and orchestration like Docker, Kubernetes
21+
- CI/CD Tools, e.g. Jenkins
1622
samm2: i-secure-build|A|2
1723
iso27001-2017:
1824
- 14.2.6
@@ -28,7 +34,9 @@ Build:
2834
resources: 2
2935
usefulness: 4
3036
level: 1
31-
implementation: "Jenkins, Docker"
37+
implementation:
38+
- CI/CD Tools, e.g. Jenkins
39+
- Container technologies and orchestration like Docker, Kubernetes
3240
samm2: i-secure-build|A|1
3341
iso27001-2017:
3442
- 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)