Skip to content

Commit 063d606

Browse files
authored
Source clouds table and scope table from compliance monitor (#262)
* Source scope table from compliance monitor * prepare template mechanism for clouds table * Source clouds table from compliance monitor Signed-off-by: Matthias Büchse <[email protected]>
1 parent 6e915da commit 063d606

File tree

6 files changed

+105
-115
lines changed

6 files changed

+105
-115
lines changed

package-lock.json

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"write-translations": "docusaurus write-translations",
3030
"write-heading-ids": "docusaurus write-heading-ids",
3131
"typecheck": "tsc",
32-
"postinstall": "node getDocs.js && node populateStds.js && node populateCerts.js",
32+
"postinstall": "node getDocs.js && node populateStds.js && node populateCerts.js && node populateClouds.js",
3333
"test": "echo \"Error: no test specified\" && exit 1",
3434
"lint:md": "markdownlint-cli2 \"**/*.md\"",
3535
"fix:md": "markdownlint-cli2-fix \"**/*.md\"",
@@ -54,6 +54,7 @@
5454
"lint-staged": "^13.1.2",
5555
"markdownlint-cli2": "^0.7.1",
5656
"markdownlint-rule-search-replace": "^1.0.9",
57+
"node-fetch": "^2.7.0",
5758
"prettier": "^2.8.4",
5859
"prism-react-renderer": "^2.3.1",
5960
"react": "^18.2.0",

populateCerts.js

Lines changed: 28 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,46 @@
1+
const fetch = require('node-fetch')
12
const fs = require('fs')
23
const YAML = require('yaml')
34

5+
async function fetchScopeTable(uuid, title, path) {
6+
const response = await fetch(
7+
`https://compliance.sovereignit.cloud/markdown/scope/${uuid}`
8+
)
9+
var text = await response.text()
10+
text = `# ${title}\n\n${text}`
11+
fs.writeFileSync(path, text, 'utf8')
12+
}
13+
414
// how many outdated versions of any scope to include
515
const MAX_OLD = 1
616

717
const filenames = fs
8-
.readdirSync('standards/')
9-
.filter((fn) => fn.startsWith('scs-') && fn.endsWith('.yaml'))
18+
.readdirSync('standards/')
19+
.filter((fn) => fn.startsWith('scs-') && fn.endsWith('.yaml'))
1020

1121
const scopes = filenames.map((filename) => {
12-
return {
13-
...YAML.parseDocument(fs.readFileSync(`standards/${filename}`, 'utf8')).toJSON(),
14-
filename,
15-
id: filename.substring(0, filename.length - 5),
16-
}
22+
return {
23+
...YAML.parseDocument(
24+
fs.readFileSync(`standards/${filename}`, 'utf8')
25+
).toJSON(),
26+
filename,
27+
id: filename.substring(0, filename.length - 5)
28+
}
1729
})
1830

1931
const today = new Date().toISOString().slice(0, 10)
2032

2133
const sidebarItems = scopes.map((scope) => {
22-
const matrix = {}
23-
const versionsShown = {}
24-
var numOld = 0
25-
var modules = {}
26-
scope.modules.forEach((module) => {
27-
modules[module.id] = module
28-
module.prettyName = module.id.startsWith('scs-') ? `${module.id}: ${module.name}` : module.name
29-
})
30-
scope.timeline.sort((a, b) => b.date.localeCompare(a.date))
31-
const current = scope.timeline.filter((entry) => entry.date <= today)
32-
const lookup = current.length ? current[0].versions : {}
33-
// sort in descending order, so we get the MAX_OLD most recent obsolete versions
34-
scope.versions.sort((a, b) => b.version.localeCompare(a.version));
35-
scope.versions.forEach((version) => {
36-
version.state = lookup[version.version] || 'deprecated'
37-
version.isStable = version.stabilized_at !== undefined && version.stabilized_at <= today
38-
version.isEffective = version.state == 'effective'
39-
if (['warn', 'effective', 'draft'].indexOf(version.state) == -1) {
40-
numOld += 1
41-
if (numOld > MAX_OLD) return
42-
}
43-
if (version.include === undefined) return
44-
versionsShown[version.version] = version
45-
version.include.forEach((include) => {
46-
if (include.ref === undefined) {
47-
include = {ref: include, parameters: {}}
48-
}
49-
const module = modules[include.ref]
50-
if (matrix[module.id] === undefined) {
51-
matrix[module.id] = {
52-
name: module.prettyName,
53-
columns: {},
54-
url: module.url,
55-
}
56-
}
57-
matrix[module.id].columns[version.version] = {
58-
parameters: include.parameters,
59-
}
60-
})
61-
})
62-
63-
const rows = Object.values(matrix)
64-
const columns = Object.keys(versionsShown)
65-
rows.sort((a, b) => a.name.localeCompare(b.name));
66-
columns.sort((a, b) => a.localeCompare(b));
67-
68-
lines = [`# ${scope.name}
69-
70-
Note that the state _Stable_ is shown here if _stabilized at_ is in the future, whereas _Effective_ is shown here if _stabilized at_ is in the past and _deprecated at_ is unset or in the future.
71-
`]
72-
lines.push('| Scope versions -> | ' + columns.join(' | ') + ' |')
73-
lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
74-
lines.push('| State | ' + columns.map((c) => versionsShown[c].state).join(' | ') + ' |')
75-
lines.push('| Stabilized at | ' + columns.map((c) => versionsShown[c].stabilized_at || '').join(' | ') + ' |')
76-
// lines.push('| Deprecated at | ' + columns.map((c) => versionsShown[c].deprecated_at || '').join(' | ') + ' |')
77-
// md doesn't allow intermediate header rows
78-
// lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
79-
lines.push('| **Modules** | ' + columns.map((c) => ' '.repeat(c.length)).join(' | ') + ' |')
80-
// md doesn't allow intermediate header rows
81-
// lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
82-
rows.forEach((row) => {
83-
lines.push(`| [${row.name}](${row.url}) | ` + columns.map((c) => row.columns[c]).map((col) => {
84-
if (col === undefined) {
85-
// this version of the cert does not include this standard
86-
return ''
87-
}
88-
let params = Object.entries(col.parameters || {}).map((entry) =>
89-
entry[1].startsWith('https://') ? `[${entry[0]}](${entry[1]})` : `${entry[0]}=${entry[1]}`
90-
).join(', ')
91-
if (params.length) {
92-
params = ` (${params})`
93-
}
94-
return `X${params}`
95-
}).join(' | ') + ' |')
96-
})
97-
lines.push('') // file should end with a single newline character
98-
fs.writeFileSync(`standards/${scope.id}.md`, lines.join('\n'), 'utf8')
99-
100-
const state = columns.filter((c) => versionsShown[c].isEffective).length ? '📜' : '✏️'
101-
return {
102-
type: 'doc',
103-
label: scope.name,
104-
id: scope.id,
34+
fetchScopeTable(scope.uuid, scope.name, `standards/${scope.id}.md`).catch(
35+
(e) => {
36+
console.log(e)
10537
}
38+
)
39+
return {
40+
type: 'doc',
41+
label: scope.name,
42+
id: scope.id
43+
}
10644
})
10745

10846
var newSidebars = `module.exports = ${JSON.stringify(sidebarItems, null, ' ')}`

populateClouds.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fetch = require('node-fetch')
2+
const fs = require('fs')
3+
4+
async function insertCloudTable(pathIn, pathOut) {
5+
const template = fs.readFileSync(pathIn, 'utf8')
6+
const response = await fetch(
7+
`https://compliance.sovereignit.cloud/markdown/table`
8+
)
9+
const text = template.replace('<!--CLOUDS-->', await response.text())
10+
fs.writeFileSync(pathOut, text, 'utf8')
11+
}
12+
13+
insertCloudTable(
14+
`standards/certification/overview.template.md`,
15+
`standards/certification/overview.md`
16+
).catch((e) => {
17+
console.log(e)
18+
})

standards/certification/overview.md

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!-- markdownlint-disable -->
2+
# Certification
3+
4+
SCS certificates come with various scopes. See [Scopes and Versions](scopes-versions.md) for details.
5+
6+
## Becoming certified
7+
8+
In order for a cloud service offering to obtain a certificate, it has to conform to all standards of the respective scope, which will be tested at regular intervals, and the results of these tests will be made available publicly. For more details on how to become certified, please consult the corresponding [document](/standards/scs-0004-v1-achieving-certification).
9+
10+
## Compliant cloud environments
11+
12+
This is a list of clouds that we test on a nightly basis against the certificate scope _SCS-compatible IaaS_.
13+
14+
<!--CLOUDS-->

0 commit comments

Comments
 (0)