Skip to content

Commit cef5027

Browse files
committed
working mappings.php
1 parent 930bb12 commit cef5027

5 files changed

Lines changed: 165 additions & 90 deletions

File tree

data-new/BuildAndDeployment/Sub-Dimensions.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ Build:
3636
- *ci-cd
3737
references:
3838
samm2:
39-
- i-secure-build|A|2
39+
- "samm2:i-secure-build|A|2"
4040
iso27001-2017:
41-
- 14.2.6
41+
- "iso27001-2017:14.2.6"
4242
Defined build process:
4343
risk:
4444
- Performing builds without a defined process is error prone; for example, as
@@ -58,7 +58,8 @@ Build:
5858
- *ci-cd
5959
- Container technologies and orchestration like Docker, Kubernetes
6060
references:
61-
samm2: i-secure-build|A|1
61+
samm2:
62+
- i-secure-build|A|1
6263
iso27001-2017:
6364
- 12.1.1
6465
- 14.2.2
@@ -120,8 +121,10 @@ Deployment:
120121
dependsOn:
121122
- Defined deployment process
122123
references:
123-
samm: OE2-A
124-
samm2: TODO
124+
samm:
125+
- OE2-A
126+
samm2:
127+
- TODO
125128
iso27001-2017:
126129
- "12.3"
127130
- 14.2.6
@@ -141,7 +144,8 @@ Deployment:
141144
dependsOn:
142145
- Smoke Test
143146
references:
144-
samm2: TODO
147+
samm2:
148+
- TODO
145149
iso27001-2017:
146150
- 17.2.1
147151
- 12.1.1
@@ -179,8 +183,10 @@ Deployment:
179183
level: 2
180184
implementation: ""
181185
references:
182-
samm: SA2-A
183-
samm2: i-secure-deployment|B|1
186+
samm:
187+
- SA2-A
188+
samm2:
189+
- i-secure-deployment|B|1
184190
iso27001-2017:
185191
- 9.4.5
186192
- 14.2.6
@@ -283,7 +289,7 @@ Deployment:
283289
resources: 1
284290
usefulness: 3
285291
level: 2
286-
samm2: i-secure-deployment|A|2
292+
samm2: samm2:i-secure-deployment|A|2
287293
iso27001-2017:
288294
- 15.1.1
289295
- 15.1.2

data/strings.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@
55
strings:
66
en: &en
77
references:
8+
samm2:
9+
label: OWASP SAMM VERSION 2
10+
description: |-
11+
https://owaspsamm.org/blog/2020/01/31/samm2-release/
12+
iso27001-2017:
13+
label: ISO27001 2017
14+
description: |-
15+
ISO 27001 / 2017
816
samm:
917
label: OWASP SAMM (Software Assurance Maturity Model)
1018
description: |-
1119
Software Assurance Maturity Model
1220
The Software Assurance Maturity Model (SAMM) is an open framework to help organizations formulate
1321
and implement a strategy for software security that is tailored
1422
to the specific risks facing the organization.
15-
samm2:
16-
label: OWASP SAMM VERSION 2
17-
description: |-
18-
https://owaspsamm.org/blog/2020/01/31/samm2-release/
23+
1924
labels: ["Very Low", "Low", "Medium", "High", "Very High"]
2025
hardness: ["Very soft", "Soft", "Medium", "High", "Very high"]
2126
maturity_levels: ["Level 1: Basic understanding of security practices" ,

detail.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<?php
22

3-
$title = "Details for '" . htmlspecialchars($_GET['element']) . "'";
3+
if (array_key_exists("element", $_GET)) {
4+
$title = "Details for '" . htmlspecialchars($_GET['element']) . "'";
5+
}
46
include_once "head.php";
57
?>
68
<body>
79
<?php
810
include_once "data.php";
911
include_once "navi.php";
1012

11-
$dimension = $_GET['dimension'];
12-
$subdimension = $_GET['subdimension'];
13-
$activityName = $_GET['element'];
13+
$dimension = $_GET['dimension'] ?? null;
14+
$subdimension = $_GET['subdimension'] ?? null;
15+
$activityName = $_GET['element'] ?? null;
1416

1517
function printDetail($dimension, $subdimension, $activityName, $dimensions, $report = false)
1618
{
17-
$element = $dimensions[$dimension][$subdimension][$activityName];
19+
$element = $dimensions[$dimension][$subdimension][$activityName] ?? null;
1820

1921
if ($element == null) { //Whitelist approach for security reasons (deny XSS)
2022
//echo "Sorry, we could not found the element";
@@ -90,12 +92,15 @@ function printReferences($element) {
9092

9193
$references = $element['references'];
9294
foreach ($references as $r => $values) {
95+
// if it's not an array, array-ze it. Remove after fixing all yamls.
96+
$values = is_array($values) ? $values : array($values);
97+
9398
$label = getReferenceLabel($r);
9499
echo "<div><h3>$label</h3></div>";
95100
echo "<ul><li>". implode("</li><li>", $values) ."</li></ul>";
96101
}
97102

98103

99104
}
100-
echo var_dump($dimensions);
105+
// echo var_dump($dimensions);
101106
printDetail($dimension, $subdimension, $activityName, $dimensions);

functions.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function readYaml($file) {
1717
return $ret;
1818
}
1919

20+
/** This function should be a sort of db wrapper. */
2021
function getActions($dimensions) {
2122
ksort($dimensions);
2223
foreach ($dimensions as $dimension => $subdimensions) {
@@ -30,11 +31,43 @@ function getActions($dimensions) {
3031
}
3132
}
3233

34+
function getReferenceLabels(){
35+
return readYaml("data/strings.yml#/strings/en/references");
36+
}
3337
function getReferenceLabel($reference_id) {
3438
$referenceLabels = readYaml("data/strings.yml#/strings/en/references");
39+
3540
return $referenceLabels[$reference_id]["label"] ?? $reference_id;
3641
}
3742

43+
44+
function renderSamm($samm_reference){
45+
return "$samm_reference";
46+
}
47+
function as_list($items){
48+
if(is_array($items)){
49+
yield from $items;
50+
} else {
51+
yield $items;
52+
}
53+
}
54+
function renderSamms($samm_references) {
55+
if( ! is_array($samm_references) ){
56+
return renderSamm($samm_references);
57+
}
58+
59+
$ret = "<ul><li>"
60+
. implode("</li><li>", array_map('renderSamm', $samm_references))
61+
."</li></ul>";
62+
return $ret;
63+
}
64+
function getReferences($references) {
65+
foreach ($references as $r_name => $rlist) {
66+
67+
}
68+
69+
}
70+
3871
// TODO create testcases
3972

4073
function test_getActions(){

0 commit comments

Comments
 (0)