Skip to content

Commit a964092

Browse files
authored
Merge pull request #102 from chandanbn/rc4
CVE JSON schema release candidate 4 documents update.
2 parents 16cb1e9 + a6b7b6b commit a964092

File tree

9 files changed

+2317
-127
lines changed

9 files changed

+2317
-127
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
package-lock.json
3+
node_modules

schema/v5.0/CVE_JSON_5.0.schema

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@
312312
]
313313
},
314314
"lessThan": {
315-
"description": "The non-inclusive upper limit of the range. This is the least version NOT in the range. The usual version syntax is expanded to allow a pattern to end in an asterisk (*), indicating an arbitrarily large number in the version ordering. For example, {version: 1.0 lessThan: 1.*} would describe the entire 1.X branch for most range kinds, and {version: 2.0, lessThan: *} describes all versions starting at 2.0, including 3.0, 5.1, and so on. Only one of lessThan and lessThanOrEqual should be specified.",
315+
"description": "The non-inclusive upper limit of the range. This is the least version NOT in the range. The usual version syntax is expanded to allow a pattern to end in an asterisk `(*)`, indicating an arbitrarily large number in the version ordering. For example, `{version: 1.0 lessThan: 1.*}` would describe the entire 1.X branch for most range kinds, and `{version: 2.0, lessThan: *}` describes all versions starting at 2.0, including 3.0, 5.1, and so on. Only one of lessThan and lessThanOrEqual should be specified.",
316316
"$ref": "#/definitions/version"
317317
},
318318
"lessThanOrEqual": {
319-
"description": "The inclusive upper limit of the range. This is the greatest version contained in the range. Only one of lessThan and lessThanOrEqual should be specified. For example, {version: 1.0, lessThanOrEqual: 1.3} covers all versions from 1.0 up to and including 1.3.",
319+
"description": "The inclusive upper limit of the range. This is the greatest version contained in the range. Only one of lessThan and lessThanOrEqual should be specified. For example, `{version: 1.0, lessThanOrEqual: 1.3}` covers all versions from 1.0 up to and including 1.3.",
320320
"$ref": "#/definitions/version"
321321
},
322322
"changes": {

schema/v5.0/docs/CVE_JSON_5.0_bundled.schema

Lines changed: 2101 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1 @@
1-
{
2-
"dataType": "CVE_RECORD",
3-
"dataVersion": "5.0",
4-
"cveMetadata": {
5-
"id": "CVE-2015-3000",
6-
"assigner": "9a527a5d-c98f-4910-8fa2-f6a927fa3ce3",
7-
"assignerShortName": "mitre",
8-
"state": "PUBLISHED"
9-
},
10-
"containers": {
11-
"cna": {
12-
"providerMetadata": {
13-
"id": "9a527a5d-c98f-4910-8fa2-f6a927fa3ce3"
14-
},
15-
"descriptions": [
16-
{
17-
"lang": "en",
18-
"value": "SysAid Help Desk before 15.2 allows remote attackers to cause a denial of service (CPU and memory consumption) via a large number of nested entity references in an XML document to (1) /agententry, (2) /rdsmonitoringresponse, or (3) /androidactions, aka an XML Entity Expansion (XEE) attack."
19-
}
20-
],
21-
"affected": {
22-
"vendors": [
23-
{
24-
"vendorName": "SysAid",
25-
"products": [
26-
{
27-
"productName": "SysAid Help Desk",
28-
"versions": [
29-
{
30-
"versionAffected": "<",
31-
"versionValue": "15.2"
32-
}
33-
]
34-
}
35-
]
36-
}
37-
]
38-
},
39-
"references": [
40-
{
41-
"url": "https://seclists.org/fulldisclosure/2015/Jun/8"
42-
}
43-
]
44-
}
45-
}
46-
}
1+
["to be generated"]

schema/v5.0/docs/index.html

Lines changed: 98 additions & 76 deletions
Large diffs are not rendered by default.

schema/v5.0/docs/mindmap.html

Lines changed: 7 additions & 2 deletions
Large diffs are not rendered by default.

schema/v5.0/support/docs/docs.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22
cd ../../
3-
sed s/file\://g CVE_JSON_5.0.schema > tmp.json | generate-schema-doc --minify tmp.json docs/index.html
3+
sed 's/file\://g' CVE_JSON_5.0.schema > tmp.json | generate-schema-doc --minify tmp.json docs/index.html
4+
perl -pi -e 's/<svg.*?<\/svg>/&gt;/g' docs/index.html
5+
node support/schema2markmap/index.js tmp.json
46
rm tmp.json
57
cat support/docs/css_override.css >> docs/schema_doc.css
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Author: Chandan BN (c) 2021
2+
// (1) convert CVE JSON schema to a mindmap
3+
// (2) creates a bundled schema
4+
5+
var ml = require('markmap-lib')
6+
var Transformer = ml.Transformer;
7+
var fillTemplate = ml.fillTemplate;
8+
var sw = require('@cloudflare/json-schema-walker');
9+
var rp = require('json-schema-ref-parser');
10+
var fold = ['metrics', 'cvssV3_1', 'cvssV3_0', 'cvssV2_0', 'supportingMedia',
11+
'tags', 'impacts', 'configurations', 'workarounds', 'solutions', 'exploits',
12+
'timeline', 'credits', 'tags', 'taxonomyMappings', 'adp'];
13+
var symbol = { object: '', array: '[]', string: '', boolean: '☯', number: '', integer: '', undefined: '' };
14+
const fs = require('fs');
15+
var markmap = require('markmap-view');
16+
const { Markmap, loadCSS, loadJS } = markmap;
17+
18+
let forDeletion = ['properties', 'items', 'anyOf', 'allOf', 'oneOf'];
19+
20+
var markdown = '';
21+
22+
function postfunc(obj, path, parent, parentPath) {
23+
if (path[1] && isNaN(path[1])) {
24+
var depth = parentPath.filter(i => !forDeletion.includes(i)).length;
25+
var reqStart = "";
26+
var reqEnd = "";
27+
28+
if (parent?.required?.includes(path[1])) {
29+
reqStart = "<b>";
30+
reqEnd = "</b>";
31+
}
32+
markdown += (" ".repeat(depth)
33+
+ "* " + reqStart + path[1] + reqEnd
34+
+ ' ' + (fold.includes(path[1]) ? '<!-- fold -->' : '')
35+
+ symbol[obj.type]
36+
+ (obj.examples ? 'e.g., `' + obj.examples[0] + '`' : '')
37+
+ (obj.enum ? '`' + obj.enum.join('` `') + '`' : ''))
38+
+ '\n';
39+
}
40+
}
41+
42+
async function schemaMindMap() {
43+
var cveSchema = await rp.dereference(process.argv[2]);
44+
markdown += "## Published <style>b {font-weight:800}</style>\n";
45+
sw.schemaWalk(cveSchema.oneOf[0], postfunc, null);
46+
47+
markdown += "## Reserved <style>b {font-weight:800}</style>\n";
48+
sw.schemaWalk(cveSchema.oneOf[1], postfunc, null);
49+
50+
markdown += "## Rejected <style>b {font-weight:800}</style>\n";
51+
sw.schemaWalk(cveSchema.oneOf[2], postfunc, null);
52+
53+
const transformer = new Transformer();
54+
55+
// transform markdown
56+
const { root, features } = transformer.transform(markdown);
57+
58+
// get assets required by used features
59+
var assets = transformer.getUsedAssets(features);
60+
61+
// create mindmap html
62+
var html = fillTemplate(root, assets);
63+
html = html.replace('<title>Markmap</title>', '<title>CVE JSON v5 Mindmap</title>')
64+
65+
try {
66+
var cveSchemaBundle = await rp.bundle(process.argv[2]);
67+
fs.writeFileSync('docs/CVE_JSON_5.0_bundled.schema', JSON.stringify(cveSchemaBundle, null, 2));
68+
fs.writeFileSync('docs/mindmap.html', html);
69+
} catch (err) {
70+
console.error(err)
71+
}
72+
}
73+
74+
var markdown = "# CVE JSON Record\n";
75+
schemaMindMap();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "schema2markmap",
3+
"version": "1.0.0",
4+
"description": "Convert CVE JSON schema to a Mardkdown document suitable for use with Markmap.js",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/CVEProject/cve-schema/tree/master/schema/v5.0/support"
12+
},
13+
"keywords": [
14+
"JSON",
15+
"Schema",
16+
"Markdown",
17+
"Markmap"
18+
],
19+
"author": "Chandan B.N.",
20+
"license": "CC0-1.0",
21+
"dependencies": {
22+
"@cloudflare/json-schema-walker": "^0.1.1",
23+
"json-schema-ref-parser": "^9.0.9",
24+
"markmap-lib": "^0.11.6",
25+
"markmap-view": "^0.2.6"
26+
}
27+
}

0 commit comments

Comments
 (0)