Skip to content

Commit 959ee1e

Browse files
authored
Merge pull request #69 from ioggstream/ioggstream-68
Syntax checks. Fix errors. See #68
2 parents 7e4e1da + ebeff09 commit 959ee1e

6 files changed

Lines changed: 79 additions & 46 deletions

File tree

.phptidy-config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
$indent_char = " ";
4+
?>

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ docker push $IMAGE_NAME
7979

8080
This approach also allows teams to perform self assessment with changes tracked in a repository.
8181

82+
8283
## Amazon EC2 Instance
8384

8485
1. In the _EC2_ sidenav select _Instances_ and click _Launch Instance_
@@ -99,6 +100,14 @@ service docker start
99100
docker run -d -p 80:80 wurstbrot/dsomm:latest
100101
```
101102

103+
## Tests
104+
105+
To run basic tests just
106+
107+
```bash
108+
docker-compose -f docker-compose.dev.yaml up test-php
109+
```
110+
102111
# Credits
103112

104113
* The dimension _Test and Verification_ is based on Christian Schneiders [Security DevOps Maturity Model (SDOMM)](https://www.christian-schneider.net/SecurityDevOpsMaturityModel.html). _Application tests_ and _Infrastructure tests_ are added by Timo Pagel. Also, the sub-dimension _Static depth_ has been evaluated by security experts at [OWASP Stammtisch Hamburg](https://www.owasp.org/index.php/OWASP_German_Chapter_Stammtisch_Initiative/Hamburg).

data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function build_table_tooltip($array, $headerWeight = 2) {
229229
if (IS_SHOW_EVIDENCE_TODO || $evidenceContent != "TODO")
230230
$html .= "<div><b>" . "Evidence" . ":</b> " . $evidenceContent . "</div>";
231231
$html .= "<hr />";
232-
$html .= "<h$headerWeight>Usefulness and Requirements of this Activitiy"</h$headerWeight>";
232+
$html .= "<h$headerWeight>Usefulness and Requirements of this Activitiy</h$headerWeight>";
233233
$html .= "<div><b>Usefullness:</b> " . ucfirst($mapUsefulness[$array['usefulness'] - 1]) . "</div>";
234234
$html .= "<div><b>Required knowledge:</b> " . ucfirst($mapKnowLedge[$array['difficultyOfImplementation']['knowledge'] - 1]) . "</div>";
235235
$html .= "<div><b>Required time:</b> " . ucfirst($mapTime[$array['difficultyOfImplementation']['time'] - 1]) . "</div>";

docker-compose.dev.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
version: "3.0"
22
services:
3-
dsomm:
3+
dsomm: &dsomm
44
build: .
55
volumes:
66
- .:/var/www/html
7+
working_dir: /var/www/html
78
ports:
89
- "8080:80"
9-
10+
test-php:
11+
<<: *dsomm
12+
volumes:
13+
- .:/var/www/html
14+
working_dir: /var/www/html
15+
entrypoint: ["/var/www/html/tests.sh"]

report-samm.php

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,60 +21,57 @@
2121
$old_dimension = null;
2222

2323

24-
foreach (getActions($dimensions) as list($dimension, $subdimensions, $element) {
25-
if ($dimension != $old_dimension) {
26-
echo "<h1>Dimension $dimension</h1>";
27-
$old_dimension = $dimension;
28-
}
24+
foreach (getActions($dimensions) as list($dimension, $subdimensions, $element)) {
25+
if ($dimension != $old_dimension) {
26+
echo "<h1>Dimension $dimension</h1>";
27+
$old_dimension = $dimension;
28+
}
2929

30-
$mappingExists[$subdimension] = array();
31-
$noMappingExists[$subdimension] = array();
32-
echo "<h2>Sub-Dimension $subdimension</h2>";
30+
$mappingExists[$subdimension] = array();
31+
$noMappingExists[$subdimension] = array();
32+
echo "<h2>Sub-Dimension $subdimension</h2>";
3333

34-
echo "<h3 style='color:green;'>With SAMM2 Mapping</h3>";
35-
for ($i = 1; $i <= 4; $i++) {
36-
$tableContent .= "<td><ul>";
37-
foreach ($element as $activityName => $content) {
38-
if (array_key_exists("samm2", $content) && !preg_match("/TODO/i", $content["samm2"])) {
39-
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
34+
echo "<h3 style='color:green;'>With SAMM2 Mapping</h3>";
35+
for ($i = 1; $i <= 4; $i++) {
36+
$tableContent .= "<td><ul>";
37+
foreach ($element as $activityName => $content) {
38+
if (array_key_exists("samm2", $content) && !preg_match("/TODO/i", $content["samm2"])) {
39+
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
4040

41-
if ($content2 != "") {
42-
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
43-
$mappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
44-
}
41+
if ($content2 != "") {
42+
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
43+
$mappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
4544
}
4645
}
4746
}
47+
}
4848

49-
echo "<h3 style='color:red;'>Without SAMM2 Mapping</h3>";
50-
for ($i = 1; $i <= 4; $i++) {
51-
$tableContent .= "<td><ul>";
52-
foreach ($element as $activityName => $content) {
53-
if (!array_key_exists("samm2", $content) || preg_match("/TODO/i", $content["samm2"])) {
54-
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
49+
echo "<h3 style='color:red;'>Without SAMM2 Mapping</h3>";
50+
for ($i = 1; $i <= 4; $i++) {
51+
$tableContent .= "<td><ul>";
52+
foreach ($element as $activityName => $content) {
53+
if (!array_key_exists("samm2", $content) || preg_match("/TODO/i", $content["samm2"])) {
54+
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
5555

56-
if ($content2 != "") {
57-
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
58-
$content["name"] = $activityName;
59-
$noMappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
60-
}
56+
if ($content2 != "") {
57+
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
58+
$content["name"] = $activityName;
59+
$noMappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
6160
}
6261
}
6362
}
6463
}
65-
foreach ($mappingExists as $dimension => $category) {
66-
//var_dump($mappingExists);
67-
echo "<h1>".$dimension ."</h1>";
68-
foreach ($category as $category => $content) {
69-
//var_dump($content);exit;
70-
echo $category . " ".count($content) . " ";
71-
foreach ($content as $activityName => $content2) {
72-
echo "$activityName" . " /"; }
73-
echo "<br>";
74-
}
64+
}
65+
foreach ($mappingExists as $dimension => $category) {
66+
//var_dump($mappingExists);
67+
echo "<h1>".$dimension ."</h1>";
68+
foreach ($category as $category => $content) {
69+
//var_dump($content);exit;
70+
echo $category . " ".count($content) . " ";
71+
foreach ($content as $activityName => $content2) {
72+
echo "$activityName" . " /"; }
73+
echo "<br>";
7574
}
75+
}
7676

77-
//var_dump($noMappingExists);
78-
79-
80-
77+
//var_dump($noMappingExists);

tests.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
test -f phptidy.php || wget https://raw.githubusercontent.com/cmrcx/phptidy/master/phptidy.php
4+
5+
echo "
6+
Reformat code according to .phptidy-config.php
7+
in order do minimize patch differences.
8+
"
9+
php ./phptidy.php replace *.php
10+
11+
echo "
12+
Checking php syntax.
13+
"
14+
find > /tmp/php-check.out 2>&1 . -type f -name \*.php -exec php -l {} \;
15+
cat /tmp/php-check.out
16+
grep 'Errors parsing' /tmp/php-check.out && exit 1 || exit 0
17+

0 commit comments

Comments
 (0)