let init = { "containers": { "cna": { "affected": [ { "product": "Product 1", "vendor": "Vendor 1", "defaultStatus": "Unknown", "versions": [ { "version": "2.0.0", "versionType": "semver", "lessThan": "2.*", "status": "affected", "changes": [ { "at": "2.5.2", "status": "unaffected" }, { "at": "2.6.0", "status": "affected" }, { "at": "2.6.3", "status": "unaffected" } ] } ] }, { "product": "Product 2", "vendor": "Vendor 1", "defaultStatus": "Affected", "versions": [ { "version": "0", "versionType": "git", "lessThan": "*", "repo": "https://github.com/example/test", "status": "unaffected", "changes": [ { "at": "123abc...", "status": "affected" }, { "at": "234bcd...", "status": "unaffected" }, { "at": "567ef0...", "status": "unaffected" } ] } ] } ], "descriptions": [ { "lang": "en", "value": "A Sample from CVE Project" } ], "problemTypes": [ { "descriptions": [ { "description": "Elevation of Privilege", "lang": "en", "type": "text" } ] } ], "providerMetadata": { "dateUpdated": "2100-06-17T00:00:00", "orgId": "f38d0000-7300-4000-92c1-6c4a2c647800", "shortName": "cveproject" }, "references": [ { "tags": [ "related", "x_refsource_MISC" ], "url": "https://mitre.org" } ], "state": "PUBLISHED", "cveId": "CVE-2100-1000", "dateUpdated": "2100-06-17T00:00:00", "shortName": "cveproject", "cvssList": [] } }, "cveMetadata": { "assignerOrgId": "f38d0000-7300-4000-92c1-6c4a2c647800", "assignerShortName": "cveproject", "cveId": "CVE-2100-1000", "dateUpdated": "2100-06-17T00:00:00", "state": "PUBLISHED" }, "dataType": "CVE_RECORD", "dataVersion": "5.0" } function loadCVE(value) { var realId = value.toUpperCase().match(/(CVE-(\d{4})-(\d{1,12})(\d{3}))/); if (realId) { $('#cve').val(value.toUpperCase()); var id = realId[1]; var year = realId[2]; var bucket = realId[3]; var jsonURL = 'https://github.com/CVEProject/cvelistV5/tree/master/review_set/' + year + '/' + bucket + 'xxx/' + id + '.json' fetch('https://raw.githubusercontent.com/CVEProject/cvelistV5/master/review_set/' + year + '/' + bucket + 'xxx/' + id + '.json', { method: 'GET', credentials: 'omit', headers: { 'Accept': 'application/json, text/plain, */*' }, redirect: 'error' }) .then(function (response) { if (!response.ok) { throw Error(id + ' ' + response.statusText); } return response.json(); }) .then(function (res) { if (res.containers) { update(res); } else { alert("CVE does not have correct information"); } }) .catch(function (error) { alert("Error in collecting CVE record for " + error.message); }) } else { alert("CVE number is invalid "+value); } return false; } function vparse(cve) { var rstring = '
'; } $('#tjson').on("change",function() { this.style.height = ""; this.style.height = this.scrollHeight + "px"; }); $('#tjson').val(JSON.stringify(init,null,3)).trigger('change'); function update(p) { if(!p) { if($('#cve').val()) return loadCVE($('#cve').val()); else p = JSON.parse($('#tjson').val()); } if('containers' in p) $('#pv').html(vparse(p)); $('#tjson').val(JSON.stringify(p,null,3)).trigger('change'); } if(location.hash) loadCVE(location.hash.substr(1)) else update(init);