diff --git a/cveClientlib.js b/cveClientlib.js
index 0a050ff..4fcca59 100644
--- a/cveClientlib.js
+++ b/cveClientlib.js
@@ -5,7 +5,7 @@ class cveClient {
this.key = key;
this.url = url;
this.user_path = "/org/" + this.org + "/user/" + this.user;
- this._version = "1.0.15";
+ this._version = "1.0.25";
}
/* PUT /cve/{id}/adp — the only ADP endpoint per CVE Services API spec
See https://cveawg.mitre.org/api-docs/ */
@@ -22,6 +22,8 @@ class cveClient {
let path = "/cve/" + cve + "/cna";
if(rejected)
path = "/cve/" + cve + "/reject";
+ if(!cnajson["x_generator"])
+ cnajson["x_generator"] = {engine: "cveClient/" + this._version};
return this.putjson(path,opts,null,{cnaContainer:cnajson});
}
reservecve(amount,cve_year,batch_type) {
diff --git a/cveInterface.js b/cveInterface.js
index 1332812..f5cddc7 100644
--- a/cveInterface.js
+++ b/cveInterface.js
@@ -1,9 +1,26 @@
/* Clientlib, UI html, css and UI js all are version controlled */
const _version = "1.0.25";
-const _tool = "CVE Services Client Interface "+_version;
-const _cna_template = { "descriptions": [ { "lang": "${descriptions.0.lang}", "value": "${descriptions.0.value}"} ] , "affected": [ { "versions": [{"version": "${affected.0.versions.0.version}"}], "product": "${affected.0.product}", "vendor": "${affected.0.vendor|client.orgobj.name}" } ],"references": [ { "name": "${references.0.name}", "url": "${references.0.url}" }], "providerMetadata": { "orgId": "${client.userobj.org_UUID}", "shortName": "${client.org}" } }
-const schemaUrl = "https://cveproject.github.io/cve-schema/schema/docs/CVE_Record_Format_bundled.json";
-const valid_states = {PUBLISHED: 1,RESERVED: 1, REJECTED: 1};
+const _tool = "CVE Services Client Interface " + _version;
+const _cna_template = {
+ descriptions: [
+ { lang: "${descriptions.0.lang}", value: "${descriptions.0.value}" },
+ ],
+ affected: [
+ {
+ versions: [{ version: "${affected.0.versions.0.version}" }],
+ product: "${affected.0.product}",
+ vendor: "${affected.0.vendor|client.orgobj.name}",
+ },
+ ],
+ references: [{ name: "${references.0.name}", url: "${references.0.url}" }],
+ providerMetadata: {
+ orgId: "${client.userobj.org_UUID}",
+ shortName: "${client.org}",
+ },
+};
+const schemaUrl =
+ "https://cveproject.github.io/cve-schema/schema/docs/CVE_Record_Format_bundled.json";
+const valid_states = { PUBLISHED: 1, RESERVED: 1, REJECTED: 1 };
let store;
let store_tag = "cveClient/";
/* User var to access client as window.client global var */
@@ -11,2009 +28,2161 @@ var client;
/* Global variables for dynamic forms */
var autoCompleter;
var allFieldsForm;
-function add_option(w,v,f,s) {
- $(w).append($('').attr({value:v,selected:s})
- .text(f));
+function add_option(w, v, f, s) {
+ $(w).append($("").attr({ value: v, selected: s }).text(f));
}
function askchatGPT(CVE_JSON) {
- if(!CVE_JSON)
- CVE_JSON = ace.edit('mjsoneditor').getValue();
- if(check_json(JSON.parse(CVE_JSON))) {
- const prompt = "I have this CVE record and want help improve it especially the \"affected\" block.\nPlease check it against the CVE JSON schema guidance (https://github.com/CVEProject/cve-schema/blob/main/schema/docs/versions.md).\nHere is the full CVE Record:\n\n " + CVE_JSON;
- const url = "https://chat.openai.com/?prompt=" + encodeURIComponent(prompt);
- window.open(url, "_blank");
- } else {
- swal.fire({type:"error",html:"It seems like your CVE JSON is not ready. Please inut required content before sending for validation.",title:"CVE JSON not ready or created yet!"});
- }
+ if (!CVE_JSON) CVE_JSON = ace.edit("mjsoneditor").getValue();
+ if (check_json(JSON.parse(CVE_JSON))) {
+ const prompt =
+ 'I have this CVE record and want help improve it especially the "affected" block.\nPlease check it against the CVE JSON 5.x schema guidance (https://github.com/CVEProject/cve-schema/blob/main/schema/docs/versions.md).\nHere is the full CVE Record:\n\n ' +
+ CVE_JSON;
+ const url = "https://chat.openai.com/?prompt=" + encodeURIComponent(prompt);
+ window.open(url, "_blank");
+ } else {
+ swal.fire({
+ type: "error",
+ html: "It seems like your CVE JSON is not ready. Please inut required content before sending for validation.",
+ title: "CVE JSON not ready or created yet!",
+ });
+ }
}
function checkurl(x) {
- try {
- new URL(x);
- return true;
- } catch(e) {
- console.log("URL Validator failed " + e);
- return false
- }
+ try {
+ new URL(x);
+ return true;
+ } catch (e) {
+ console.log("URL Validator failed " + e);
+ return false;
+ }
}
function clearChat() {
-
- Swal.fire({
- title: 'Start a new CVE chat?',
- html: 'This will clear any content entered or downloaded!',
- showDenyButton: true,
- showCancelButton: false,
- confirmButtonText: 'Sure',
- denyButtonText: 'Cancel',
- }).then(function(result) {
- if(result.isConfirmed) {
- cveChat();
- } else {
- $('#nice-tab').click();
- }
- });
+ Swal.fire({
+ title: "Start a new CVE chat?",
+ html: "This will clear any content entered or downloaded!",
+ showDenyButton: true,
+ showCancelButton: false,
+ confirmButtonText: "Sure",
+ denyButtonText: "Cancel",
+ }).then(function (result) {
+ if (result.isConfirmed) {
+ cveChat();
+ } else {
+ $("#nice-tab").click();
+ }
+ });
}
function cveChat() {
- document.addEventListener('dblclick', (event) => { if(event.target.placeholder) event.target.value = event.target.placeholder.replace('e.g..','') })
- const cweUrl = location.origin + "/" + location.pathname.split("/").slice(0,-1).join("/") +
- "/cwe-common.json";
- const questions = [
- { key: "title", prompt: "Provide a title for the CVE Record.", example:"Buffer overflow in FooBar 1.0 ..." },
- { key: "description", prompt: "Describe the vulnerability.", example: "Buffer overflow in FooBar 1.0 causes DOS when crafted input..." },
- { key: "cweObj", example: "CWE-121: Stack-based Buffer Overflow.", prompt: "Enter the CWE-ID", "suggestionUrl": cweUrl, "selector": "cwe-common" },
- { key: "vendor", prompt: "What is the vendor name?", example: "Acme" },
- { key: "product", prompt: "What is the product name?", example: "Widget" },
- { key: "versions", prompt: "What specific version(s) are affected? [comma-separated]", example: "1.0.1,2.1.1" },
- { key: "refUrl", prompt: "Provide the reference URL.", example: "https://example.com/security/psirt/CVE-1900-0001", validator: checkurl}
- ];
+ document.addEventListener("dblclick", (event) => {
+ if (event.target.placeholder)
+ event.target.value = event.target.placeholder.replace("e.g..", "");
+ });
+ const cweUrl =
+ location.origin +
+ "/" +
+ location.pathname.split("/").slice(0, -1).join("/") +
+ "/cwe-common.json";
+ const questions = [
+ {
+ key: "title",
+ prompt: "Provide a title for the CVE Record.",
+ example: "Buffer overflow in FooBar 1.0 ...",
+ },
+ {
+ key: "description",
+ prompt: "Describe the vulnerability.",
+ example: "Buffer overflow in FooBar 1.0 causes DOS when crafted input...",
+ },
+ {
+ key: "cweObj",
+ example: "CWE-121: Stack-based Buffer Overflow.",
+ prompt: "Enter the CWE-ID",
+ suggestionUrl: cweUrl,
+ selector: "cwe-common",
+ },
+ { key: "vendor", prompt: "What is the vendor name?", example: "Acme" },
+ { key: "product", prompt: "What is the product name?", example: "Widget" },
+ {
+ key: "versions",
+ prompt: "What specific version(s) are affected? [comma-separated]",
+ example: "1.0.1,2.1.1",
+ },
+ {
+ key: "refUrl",
+ prompt: "Provide the reference URL.",
+ example: "https://example.com/security/psirt/CVE-1900-0001",
+ validator: checkurl,
+ },
+ ];
- let answers = {};
- const chatbox = document.getElementById("chatbox");
- let step = 0;
- chatbox.innerHTML = "";
- const addMessage = function(text, sender) {
- if(!sender)
- sender = "bot";
- const msg = document.createElement("div");
- msg.className = sender;
- msg.textContent = text;
- chatbox.appendChild(msg);
- chatbox.scrollTop = chatbox.scrollHeight;
- }
- let chatbutton = document.getElementById("chatmsg");
- let chatinput = document.getElementById("chatinput");
- chatbutton.value = "";
- chatbutton.style.display = "inline-block";
- chatinput.value = "";
- chatinput.style.display = "inline-block";
- document.getElementById("chatsend").classList.add("d-none");
- if(!chatbutton.hasAttribute('handleinputadded')) {
- chatbutton.setAttribute('handleinputadded', 'true');
- chatbutton.addEventListener('click', function() {
- let input = document.getElementById("chatinput");
- let step = parseInt(chatbox.getAttribute("data-step"));
- const val = input.value.trim();
- if (!val) return;
- const qn = questions[step-1];
- if(qn.validator && (!qn.validator(val))) {
- input.classList.add("is-invalid");
- return;
- }
- addMessage(val, "user");
- answers[qn.key] = val;
- if (step >= questions.length) {
- buildCVE();
- return;
- }
-
- const q = questions[step];
- if(q.example)
- input.placeholder = "e.g.. " + q.example;
-
- input.value = "";
- input.classList.remove("is-valid","is-invalid")
- const iclone = input.cloneNode(true);
- input.after(iclone);
- input.remove();
- if(q.suggestionUrl) {
- let _ = new autoCompleter(iclone,q.suggestionsArray,q.suggestionUrl,q.selector);
- iclone.addEventListener('input', function(event) {
- iclone.focus();
- console.log("Changed");
- });
- }
- iclone.addEventListener('keydown', function(event) {
- if (event.key === 'Enter') {
- console.log('Enter key pressed in the input field!');
- chatbutton.click();
- }
- });
- iclone.focus();
- setTimeout(function() {
- addMessage(questions[step].prompt);
- step++;
- chatbox.setAttribute("data-step",step);
- }, 300);
- });
- }
+ let answers = {};
+ const chatbox = document.getElementById("chatbox");
+ let step = 0;
+ chatbox.innerHTML = "";
+ const addMessage = function (text, sender) {
+ if (!sender) sender = "bot";
+ const msg = document.createElement("div");
+ msg.className = sender;
+ msg.textContent = text;
+ chatbox.appendChild(msg);
+ chatbox.scrollTop = chatbox.scrollHeight;
+ };
+ let chatbutton = document.getElementById("chatmsg");
+ let chatinput = document.getElementById("chatinput");
+ chatbutton.value = "";
+ chatbutton.style.display = "inline-block";
+ chatinput.value = "";
+ chatinput.style.display = "inline-block";
+ document.getElementById("chatsend").classList.add("d-none");
+ if (!chatbutton.hasAttribute("handleinputadded")) {
+ chatbutton.setAttribute("handleinputadded", "true");
+ chatbutton.addEventListener("click", function () {
+ let input = document.getElementById("chatinput");
+ let step = parseInt(chatbox.getAttribute("data-step"));
+ const val = input.value.trim();
+ if (!val) return;
+ const qn = questions[step - 1];
+ if (qn.validator && !qn.validator(val)) {
+ input.classList.add("is-invalid");
+ return;
+ }
+ addMessage(val, "user");
+ answers[qn.key] = val;
+ if (step >= questions.length) {
+ buildCVE();
+ return;
+ }
- const buildCVE = function() {
- console.log(answers);
- let cve = {
- title: answers.title,
- descriptions: [
- {
- lang: "en",
- value: answers.description
- }
- ],
- problemTypes: [],
- affected: [
- {
- vendor: answers.vendor,
- product: answers.product,
- versions: answers.versions.split(",").map(v => ({ version: v.trim(),status: "affected" }))
- }
- ],
- references: [
- {
- url: answers.refUrl
- }
- ]
- };
- document.getElementById("chatinput").style.display = "none";
- chatbutton.style.display = "none";
- document.getElementById("chatsend").classList.remove("d-none");
- const match_cwe = answers.cweObj.toUpperCase().match(/^(cwe-[0-9]+)(.*)$/i);
- if(match_cwe && match_cwe.length == 3) {
- cve.problemTypes[0] = {
- descriptions: [
- {
- lang: "en",
- type: "CWE",
- cweId: match_cwe[1],
- description: answers.cweObj
- }
- ]
- };
- } else {
- cve.problemTypes[0] = {
- descriptions: [
- {
- lang: "en",
- description: answers.cweObj
- }
- ]
- };
- }
- let output = document.getElementById("chatoutput");
- output.textContent = JSON.stringify(cve, null, 2);
- }
- if(questions[step].example)
- document.getElementById("chatinput").placeholder = " e.g.. " + questions[step].example;
- addMessage(questions[step].prompt);
- chatbox.setAttribute("data-step",step + 1);
+ const q = questions[step];
+ if (q.example) input.placeholder = "e.g.. " + q.example;
+
+ input.value = "";
+ input.classList.remove("is-valid", "is-invalid");
+ const iclone = input.cloneNode(true);
+ input.after(iclone);
+ input.remove();
+ if (q.suggestionUrl) {
+ let _ = new autoCompleter(
+ iclone,
+ q.suggestionsArray,
+ q.suggestionUrl,
+ q.selector,
+ );
+ iclone.addEventListener("input", function (event) {
+ iclone.focus();
+ console.log("Changed");
+ });
+ }
+ iclone.addEventListener("keydown", function (event) {
+ if (event.key === "Enter") {
+ console.log("Enter key pressed in the input field!");
+ chatbutton.click();
+ }
+ });
+ iclone.focus();
+ setTimeout(function () {
+ addMessage(questions[step].prompt);
+ step++;
+ chatbox.setAttribute("data-step", step);
+ }, 300);
+ });
+ }
+ const buildCVE = function () {
+ console.log(answers);
+ let cve = {
+ title: answers.title,
+ descriptions: [
+ {
+ lang: "en",
+ value: answers.description,
+ },
+ ],
+ problemTypes: [],
+ affected: [
+ {
+ vendor: answers.vendor,
+ product: answers.product,
+ versions: answers.versions
+ .split(",")
+ .map((v) => ({ version: v.trim(), status: "affected" })),
+ },
+ ],
+ references: [
+ {
+ url: answers.refUrl,
+ },
+ ],
+ };
+ document.getElementById("chatinput").style.display = "none";
+ chatbutton.style.display = "none";
+ document.getElementById("chatsend").classList.remove("d-none");
+ const match_cwe = answers.cweObj.toUpperCase().match(/^(cwe-[0-9]+)(.*)$/i);
+ if (match_cwe && match_cwe.length == 3) {
+ cve.problemTypes[0] = {
+ descriptions: [
+ {
+ lang: "en",
+ type: "CWE",
+ cweId: match_cwe[1],
+ description: answers.cweObj,
+ },
+ ],
+ };
+ } else {
+ cve.problemTypes[0] = {
+ descriptions: [
+ {
+ lang: "en",
+ description: answers.cweObj,
+ },
+ ],
+ };
+ }
+ let output = document.getElementById("chatoutput");
+ output.textContent = JSON.stringify(cve, null, 2);
+ };
+ if (questions[step].example)
+ document.getElementById("chatinput").placeholder =
+ " e.g.. " + questions[step].example;
+ addMessage(questions[step].prompt);
+ chatbox.setAttribute("data-step", step + 1);
}
function triggerversionRange(w) {
- if(w.checked)
- $(w).parent().find(".versionRange").removeClass("d-none");
- else
- $(w).parent().find(".versionRange").addClass("d-none");
-
+ if (w.checked) $(w).parent().find(".versionRange").removeClass("d-none");
+ else $(w).parent().find(".versionRange").addClass("d-none");
}
-function showByClassName(w,c) {
- if(w)
- $(c).removeClass('d-none');
- else
- $(c).addClass('d-none');
+function showByClassName(w, c) {
+ if (w) $(c).removeClass("d-none");
+ else $(c).addClass("d-none");
}
function show_field(w) {
- var fclass = $(w).attr("data-show");
- $('.'+fclass).toggleClass("d-none");
- $(w).toggleClass("arrowdown");
+ var fclass = $(w).attr("data-show");
+ $("." + fclass).toggleClass("d-none");
+ $(w).toggleClass("arrowdown");
}
function load_cwes() {
- /*Load cwes */
- let suggestionUrl = location.origin + "/" + location.pathname.split("/").slice(0,-1).join("/") +
- "/cwe-common.json";
- autoComplete = autoCompleter($('.problemTypeDescription')[0],null,suggestionUrl,"cwe-common");
+ /*Load cwes */
+ let suggestionUrl =
+ location.origin +
+ "/" +
+ location.pathname.split("/").slice(0, -1).join("/") +
+ "/cwe-common.json";
+ autoComplete = autoCompleter(
+ $(".problemTypeDescription")[0],
+ null,
+ suggestionUrl,
+ "cwe-common",
+ );
}
function load_languages() {
- $.getJSON("language-codes.json").done(function(d) {
- var langs = d;
- if("langs" in d)
- langs = d.langs;
- for(var i=0; i > .erow").length;
- nrow.find(".form-control").each(function(_,p) {
- let rv = $(p).attr('data-field');
- if(!rv) {
- rv = $(p).attr('data-relatedfield');
- if(!rv) {
- console.log("Ignoring field with no data attribute",p);
- return;
- }
- }
-
- let regx = new RegExp("("+pclass+")\\.(\\d+)");
- rv = rv.replace(regx,function(s0,s1,s2) {
- try {
- return s1 + "." + String(offset);
- } catch(err) {
- console.log(err);
- console.log("Error while incrementing data-field id");
- return s0;
- };
- });
- if($(p).attr('data-relatedfield')) {
- $(p).attr("data-relatedfield",rv);
- } else if ($(p).attr('data-field')){
- $(p).attr("data-field",rv);
- }
- /* jquery data() method is distinct from data- fields so do both*/
- $(p).attr("data-field",rv);
+ /* Label has only one class just copy it*/
+ let pclass = $(pe).attr("data-rclass");
+ let childclass = "." + pclass;
+ let orow = $(pe).find(childclass);
+ let nrow = $(pe)
+ .find(childclass)
+ .clone(1)
+ .removeClass(pclass)
+ .addClass("duplicated");
+ let offset = $(pe).find("> > .erow").length;
+ nrow.find(".form-control").each(function (_, p) {
+ let rv = $(p).attr("data-field");
+ if (!rv) {
+ rv = $(p).attr("data-relatedfield");
+ if (!rv) {
+ console.log("Ignoring field with no data attribute", p);
+ return;
+ }
+ }
+
+ let regx = new RegExp("(" + pclass + ")\\.(\\d+)");
+ rv = rv.replace(regx, function (s0, s1, s2) {
+ try {
+ return s1 + "." + String(offset);
+ } catch (err) {
+ console.log(err);
+ console.log("Error while incrementing data-field id");
+ return s0;
+ }
});
- orow.parent().append(nrow);
+ if ($(p).attr("data-relatedfield")) {
+ $(p).attr("data-relatedfield", rv);
+ } else if ($(p).attr("data-field")) {
+ $(p).attr("data-field", rv);
+ }
+ /* jquery data() method is distinct from data- fields so do both*/
+ $(p).attr("data-field", rv);
+ });
+ orow.parent().append(nrow);
}
function unduplicate(pe) {
- let field = $(pe).parent().find(".form-control").attr("data-field");
- let rv = field.replace(/(\d)+\.[^\.]+$/,"$1");
- json_data = set_deep(get_json_data(),rv,undefined);
- let editor = $('#mjson .jsoneditor')[0].env.editor;
- editor.setValue(JSON.stringify(json_data,null,2));
- if($(pe).hasClass("duplicated"))
- $(pe).remove();
-}
-function data_selector(el,dfield,dvalue) {
- let sel = '[data-' + dfield + '="' + dvalue + '"]';
- return $(el+sel);
-}
-function top_alert(lvl,msg,tmr) {
- $('#topalert').removeClass("alert-danger alert-warning alert-success")
- .addClass("alert alert-"+lvl).text(msg).fadeIn();
- if(tmr)
- setTimeout(function() { $('#topalert').fadeOut();},tmr);
- else
- $('#topalert').append('');
+ let field = $(pe).parent().find(".form-control").attr("data-field");
+ let rv = field.replace(/(\d)+\.[^\.]+$/, "$1");
+ json_data = set_deep(get_json_data(), rv, undefined);
+ let editor = $("#mjson .jsoneditor")[0].env.editor;
+ editor.setValue(JSON.stringify(json_data, null, 2));
+ if ($(pe).hasClass("duplicated")) $(pe).remove();
+}
+function data_selector(el, dfield, dvalue) {
+ let sel = "[data-" + dfield + '="' + dvalue + '"]';
+ return $(el + sel);
+}
+function top_alert(lvl, msg, tmr) {
+ $("#topalert")
+ .removeClass("alert-danger alert-warning alert-success")
+ .addClass("alert alert-" + lvl)
+ .text(msg)
+ .fadeIn();
+ if (tmr)
+ setTimeout(function () {
+ $("#topalert").fadeOut();
+ }, tmr);
+ else
+ $("#topalert").append(
+ '',
+ );
}
function urlprompt(w) {
- if($(w).val() == "custom") {
- $('#loginModal').removeAttr("tabindex");
- Swal.fire({
- title: 'Enter API URL',
- input: 'url',
- inputLabel: 'API URL',
- inputPlaceholder: 'API URL',
- showCancelButton: true,
- inputValidator: function(value) {
- if (!value) {
- return 'You need to write something!';
- }
- try {
- var f= new URL(value)
- } catch(err) {
- return 'URL is invalid';
- }
- add_option(w,f.toString(),f.host,1);
- $('#loginModal').attr("tabindex","-1");
- }
- });
- }
+ if ($(w).val() == "custom") {
+ $("#loginModal").removeAttr("tabindex");
+ Swal.fire({
+ title: "Enter API URL",
+ input: "url",
+ inputLabel: "API URL",
+ inputPlaceholder: "API URL",
+ showCancelButton: true,
+ inputValidator: function (value) {
+ if (!value) {
+ return "You need to write something!";
+ }
+ try {
+ var f = new URL(value);
+ } catch (err) {
+ return "URL is invalid";
+ }
+ add_option(w, f.toString(), f.host, 1);
+ $("#loginModal").attr("tabindex", "-1");
+ },
+ });
+ }
}
function check_admin() {
- /* Either secretrait or CNA Admin can do reset
+ /* Either secretrait or CNA Admin can do reset
API keys and Add Users */
- if(client.orgobj.authority.active_roles.findIndex(function(n) {
- return n == "SECRETARIAT";
- }) > -1) {
- $('.admin').show();
- return 1;
- } else if(client.userobj.authority.active_roles
- .findIndex(function(n) {
- return n == "ADMIN";
- }) > -1) {
- $('.admin').show();
- return 1;
- } else {
- $('.admin').hide();
- return 0;
- }
+ if (
+ client.orgobj.authority.active_roles.findIndex(function (n) {
+ return n == "SECRETARIAT";
+ }) > -1
+ ) {
+ $(".admin").show();
+ return 1;
+ } else if (
+ client.userobj.authority.active_roles.findIndex(function (n) {
+ return n == "ADMIN";
+ }) > -1
+ ) {
+ $(".admin").show();
+ return 1;
+ } else {
+ $(".admin").hide();
+ return 0;
+ }
}
function saveUserOrgInfo(userobj) {
- client.userobj = userobj;
- try {
- /* Collect org information async */
- client.getorg().then(function(y) {
- client.orgobj = y;
- check_admin();
- });
-
- }catch(err) {
- console.log("Error while fetching User's organization");
- console.log(err);
- };
+ client.userobj = userobj;
+ try {
+ /* Collect org information async */
+ client.getorg().then(function (y) {
+ client.orgobj = y;
+ check_admin();
+ });
+ } catch (err) {
+ console.log("Error while fetching User's organization");
+ console.log(err);
+ }
}
function timefile() {
- var d = new Date();
- return d.getDate() + "-" + (d.getMonth()+1) + "-" + d.getFullYear() + "-" +
- d.getHours() + "-" + d.getMinutes()
-
+ var d = new Date();
+ return (
+ d.getDate() +
+ "-" +
+ (d.getMonth() + 1) +
+ "-" +
+ d.getFullYear() +
+ "-" +
+ d.getHours() +
+ "-" +
+ d.getMinutes()
+ );
}
async function get_cve() {
- let cve = $('#nice .cve').val();
- if(!cve.match(/^CVE-\d{4}-\d{4,7}$/)) {
- $('#nice .cve').addClass('is-invalid').focus()
- return;
- }
- if((!client) || (!client.url)) {
- client = new cveClient();
- let loc = await Swal.fire({
- title: 'CVE Download',
- input: 'select',
- inputOptions: $('#url option').toArray()
- .reduce(function(a,x,i) {
- a[x.value] = x.innerHTML;
- return a;
- },{}),
- inputPlaceholder: 'Download Location',
- showCancelButton: true,
- });
- console.log(loc);
- let value = loc.value;
- if(!value)
- return;
- if (value == 'custom') {
- let url = await Swal.fire({
- title: 'Enter API URL',
- input: 'url',
- inputLabel: 'API URL',
- inputPlaceholder: 'API URL',
- showCancelButton: true,
- inputValidator: function(rvalue) {
- try {
- new URL(rvalue);
- client.url = rvalue;
- } catch(err) {
- console.log(err);
- return "URL is invalid";
- }
- }
- });
- } else {
- client.url = value;
- }
+ let cve = $("#nice .cve").val();
+ if (!cve.match(/^CVE-\d{4}-\d{4,7}$/)) {
+ $("#nice .cve").addClass("is-invalid").focus();
+ return;
+ }
+ if (!client || !client.url) {
+ client = new cveClient();
+ let loc = await Swal.fire({
+ title: "CVE Download",
+ input: "select",
+ inputOptions: $("#url option")
+ .toArray()
+ .reduce(function (a, x, i) {
+ a[x.value] = x.innerHTML;
+ return a;
+ }, {}),
+ inputPlaceholder: "Download Location",
+ showCancelButton: true,
+ });
+ console.log(loc);
+ let value = loc.value;
+ if (!value) return;
+ if (value == "custom") {
+ let url = await Swal.fire({
+ title: "Enter API URL",
+ input: "url",
+ inputLabel: "API URL",
+ inputPlaceholder: "API URL",
+ showCancelButton: true,
+ inputValidator: function (rvalue) {
+ try {
+ new URL(rvalue);
+ client.url = rvalue;
+ } catch (err) {
+ console.log(err);
+ return "URL is invalid";
+ }
+ },
+ });
+ } else {
+ client.url = value;
}
- get_display_cve(cve);
+ }
+ get_display_cve(cve);
}
function get_display_cve(cve) {
- client.getcvedetail(cve)
- .then(function(x) {
- if(get_deep(x,"containers.cna")) {
- $('.duplicated').remove();
- json_edit(JSON.stringify(x.containers.cna));
- } else {
- swal_error("Could not find data to load! " +
- "See console for details.");
- }
- //console.log(x);
- client["cveDownload"] = x;
- },function(y) {
- swal_error("Unable to collect CVE information! " +
- "See console for details");
- //console.log(y);
- });
+ client.getcvedetail(cve).then(
+ function (x) {
+ if (get_deep(x, "containers.cna")) {
+ $(".duplicated").remove();
+ json_edit(JSON.stringify(x.containers.cna));
+ } else {
+ swal_error(
+ "Could not find data to load! " + "See console for details.",
+ );
+ }
+ //console.log(x);
+ client["cveDownload"] = x;
+ },
+ function (y) {
+ swal_error(
+ "Unable to collect CVE information! " + "See console for details",
+ );
+ //console.log(y);
+ },
+ );
}
async function skip() {
- $('#loginModal').modal('hide');
- $('#morjson li.adp').hide();
- const template = _cna_template;
- let xj = JSON.stringify(template);
- json_edit(xj);
- $('#cveUpdateModal').modal();
- $('#cveUpdateModal .cveupdate').html("Download JSON");
- $('#cveUpdateModal .cveupdate').removeAttr('onclick');
- $('#cveUpdateModal .cveupdate').on("click", download_json);
- $('.nologin').show();
+ $("#loginModal").modal("hide");
+ $("#morjson li.adp").hide();
+ const template = _cna_template;
+ let xj = JSON.stringify(template);
+ json_edit(xj);
+ $("#cveUpdateModal").modal();
+ $("#cveUpdateModal .cveupdate").html("Download JSON");
+ $("#cveUpdateModal .cveupdate").removeAttr("onclick");
+ $("#cveUpdateModal .cveupdate").on("click", download_json);
+ $(".nologin").show();
}
-
async function download_json() {
- let cve = $('#nice .cve').val();
- if(!cve.match(/^CVE-\d{4}-\d{4,7}$/)) {
- $('#nice .cve').addClass('is-invalid').focus()
- return;
- }
- try {
- client = new cveClient();
- if($('#nice-or-json').find(".active.show").attr("id") == "nice") {
- if(to_json() == false) {
- $('#cveform .is-invalid').focus();
- swal_error("Some required fields are missing or incomplete");
- return;
- }
- }
- let editor = $('#mjson .jsoneditor')[0].env.editor;
- let returnJSON = {"containers": {"cna": JSON.parse(editor.getValue())}};
- returnJSON["cveMetadata"] = {"cveId": cve,
- "assignerOrgId": "00000000-0000-0000-0000-000000000000",
- "requesterUserId": "00000000-0000-0000-0000-000000000000",
- "serial": 1,
- "state": "PUBLISHED"};
- returnJSON["containers"]["cna"]["providerMetadata"] =
- { orgId: "00000000-0000-0000-0000-000000000000",
- shortName: "none" };
- if(get_deep(client,'constructor.name') && client._version)
- returnJSON["x_generator"] = {engine: client.constructor.name + "/" +
- client._version };
- $('#cveUpdateModal .cveupdate').attr('download',cve+'.json');
- let cson = encodeURIComponent(JSON.stringify(returnJSON));
- $('#cveUpdateModal .cveupdate').attr('href','data:text/plain;charset=utf-8,' + cson);
- } catch (err) {
- console.log(err);
- swal_error("Could not create this CVE. Fix the errors please!");
- }
+ let cve = $("#nice .cve").val();
+ if (!cve.match(/^CVE-\d{4}-\d{4,7}$/)) {
+ $("#nice .cve").addClass("is-invalid").focus();
+ return;
+ }
+ try {
+ client = new cveClient();
+ if ($("#nice-or-json").find(".active.show").attr("id") == "nice") {
+ if (to_json() == false) {
+ $("#cveform .is-invalid").focus();
+ swal_error("Some required fields are missing or incomplete");
+ return;
+ }
+ }
+ let editor = $("#mjson .jsoneditor")[0].env.editor;
+ let returnJSON = { containers: { cna: JSON.parse(editor.getValue()) } };
+ returnJSON["cveMetadata"] = {
+ cveId: cve,
+ assignerOrgId: "00000000-0000-0000-0000-000000000000",
+ requesterUserId: "00000000-0000-0000-0000-000000000000",
+ serial: 1,
+ state: "PUBLISHED",
+ };
+ returnJSON["containers"]["cna"]["providerMetadata"] = {
+ orgId: "00000000-0000-0000-0000-000000000000",
+ shortName: "none",
+ };
+ returnJSON["x_generator"] = { engine: "cveClient/" + _version };
+ $("#cveUpdateModal .cveupdate").attr("download", cve + ".json");
+ let cson = encodeURIComponent(JSON.stringify(returnJSON));
+ $("#cveUpdateModal .cveupdate").attr(
+ "href",
+ "data:text/plain;charset=utf-8," + cson,
+ );
+ } catch (err) {
+ console.log(err);
+ swal_error("Could not create this CVE. Fix the errors please!");
+ }
}
async function login() {
- let vids = ['org','user','key'];
- for(var i=0; i < vids.length; i++) {
- var el = $('#'+vids[i]);
- if(!el.val()) {
- el.addClass("is-invalid");
- return;
- }
- }
- client = new cveClient($('#org').val(),$('#user').val(),$('#key').val(),$('#url').val());
- let d;
- try {
- d = await client.getuser();
- }catch(err) {
- console.log(err);
- swal_error("Login failed. Perhaps Network error. See console for details!");
- return;
- };
- let messages = "Unknown";
- let title = "CVE CNA Login";
- let mtype = "error";
- try {
- let robj = await d.json();
- if("name" in robj) {
- messages = "Welcome "+robj.name.first+" "+robj.name.last;
- saveUserOrgInfo(robj);
- } else if("message" in robj) {
- messages = robj.message;
- } else if("error" in robj) {
- messages = robj.error;
- }
- } catch(err) {
- console.log("Could not find json text");
- swal_error("Login failed or network error! See console for details!");
- console.log(err);
- }
- if(d.status == 401) {
- title = "Login Failed!";
- if(messages == "Unknown")
- messages = 'Perhaps your API key is wrong';
- }
- else if(d.status == 200) {
- mtype = "success";
- title = "Login Success";
- /* By default enable encryption */
- enable_encryption();
- setTimeout(function() {
- Swal.close();
- $('#loginModal').modal('hide');
- show_cve_table();
- }, 2300);
- if ($('#storeLocal').is(':checked')) {
- store = localStorage;
- } else {
- store = sessionStorage;
- }
- $('#loginModal .form-control').each(function(_,x) {
- /* Skip storing API key in plaintext; enable_encryption()
- will store it after encryption completes */
- if($(x).attr('id') === 'key') return;
- store.setItem(store_tag+$(x).attr('id'),$(x).val());
- });
+ let vids = ["org", "user", "key"];
+ for (var i = 0; i < vids.length; i++) {
+ var el = $("#" + vids[i]);
+ if (!el.val()) {
+ el.addClass("is-invalid");
+ return;
+ }
+ }
+ client = new cveClient(
+ $("#org").val(),
+ $("#user").val(),
+ $("#key").val(),
+ $("#url").val(),
+ );
+ let d;
+ try {
+ d = await client.getuser();
+ } catch (err) {
+ console.log(err);
+ swal_error("Login failed. Perhaps Network error. See console for details!");
+ return;
+ }
+ let messages = "Unknown";
+ let title = "CVE CNA Login";
+ let mtype = "error";
+ try {
+ let robj = await d.json();
+ if ("name" in robj) {
+ messages = "Welcome " + robj.name.first + " " + robj.name.last;
+ saveUserOrgInfo(robj);
+ } else if ("message" in robj) {
+ messages = robj.message;
+ } else if ("error" in robj) {
+ messages = robj.error;
+ }
+ } catch (err) {
+ console.log("Could not find json text");
+ swal_error("Login failed or network error! See console for details!");
+ console.log(err);
+ }
+ if (d.status == 401) {
+ title = "Login Failed!";
+ if (messages == "Unknown") messages = "Perhaps your API key is wrong";
+ } else if (d.status == 200) {
+ mtype = "success";
+ title = "Login Success";
+ /* By default enable encryption */
+ enable_encryption();
+ setTimeout(function () {
+ Swal.close();
+ $("#loginModal").modal("hide");
+ show_cve_table();
+ }, 2300);
+ if ($("#storeLocal").is(":checked")) {
+ store = localStorage;
} else {
- title = "Unspecified Error!";
- if(messages == "Unknown")
- messages = "Unknown error! See console for more information";
- //console.log(d);
+ store = sessionStorage;
}
- Swal.fire({
- title: title,
- text: messages,
- icon: mtype,
- confirmButtonText: 'OK'
+ $("#loginModal .form-control").each(function (_, x) {
+ /* Skip storing API key in plaintext; enable_encryption()
+ will store it after encryption completes */
+ if ($(x).attr("id") === "key") return;
+ store.setItem(store_tag + $(x).attr("id"), $(x).val());
});
+ } else {
+ title = "Unspecified Error!";
+ if (messages == "Unknown")
+ messages = "Unknown error! See console for more information";
+ //console.log(d);
+ }
+ Swal.fire({
+ title: title,
+ text: messages,
+ icon: mtype,
+ confirmButtonText: "OK",
+ });
}
function logout() {
- Swal.fire({
- title: 'Are you sure?',
- showDenyButton: true,
- showCancelButton: false,
- confirmButtonText: 'Logout',
- denyButtonText: 'Cancel',
- }).then((result) => {
- if (result.isConfirmed) {
- $('#loginModal .form-control').each(function(_,x) {
- if(store)
- store.removeItem(store_tag+$(x).attr('id'),$(x).val());
- else {
- sessionStorage
- .removeItem(store_tag+$(x).attr('id'),$(x).val());
- localStorage
- .removeItem(store_tag+$(x).attr('id'),$(x).val());
- }
- });
- location.reload();
- } else if (result.isDenied) {
- console.log("User is still on");
- }
- });
-}
-function swal_error(err_msg,err_type) {
- if(!err_type)
- err_type = "error";
- Swal.fire({
- title: "Error!",
- text: err_msg,
- icon: err_type,
- confirmButtonText: "OK"
- });
+ Swal.fire({
+ title: "Are you sure?",
+ showDenyButton: true,
+ showCancelButton: false,
+ confirmButtonText: "Logout",
+ denyButtonText: "Cancel",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ $("#loginModal .form-control").each(function (_, x) {
+ if (store) store.removeItem(store_tag + $(x).attr("id"), $(x).val());
+ else {
+ sessionStorage.removeItem(store_tag + $(x).attr("id"), $(x).val());
+ localStorage.removeItem(store_tag + $(x).attr("id"), $(x).val());
+ }
+ });
+ location.reload();
+ } else if (result.isDenied) {
+ console.log("User is still on");
+ }
+ });
+}
+function swal_error(err_msg, err_type) {
+ if (!err_type) err_type = "error";
+ Swal.fire({
+ title: "Error!",
+ text: err_msg,
+ icon: err_type,
+ confirmButtonText: "OK",
+ });
}
function do_login() {
- client.getuser().then(function(x) {
- x.json().then(function(y) {
- if('error' in y) {
- swal_error("Automatic Login failed! Error: " + y.error +
- ", If credentials have changed" +
- ", please logout and refresh" +
- " for a new login. Failure message is "+y.message);
- return;
- } else {
- show_cve_table();
- }
- saveUserOrgInfo(y);
- });
- }).catch(function(err) {
- console.log(err);
- swal_error("Automatic Login failed! "+
- "If credentials have changed"+
- ", please logout and refresh"+
- " for a new login");
+ client
+ .getuser()
+ .then(function (x) {
+ x.json().then(function (y) {
+ if ("error" in y) {
+ swal_error(
+ "Automatic Login failed! Error: " +
+ y.error +
+ ", If credentials have changed" +
+ ", please logout and refresh" +
+ " for a new login. Failure message is " +
+ y.message,
+ );
+ return;
+ } else {
+ show_cve_table();
+ }
+ saveUserOrgInfo(y);
+ });
+ })
+ .catch(function (err) {
+ console.log(err);
+ swal_error(
+ "Automatic Login failed! " +
+ "If credentials have changed" +
+ ", please logout and refresh" +
+ " for a new login",
+ );
});
}
-$(function() {
- store = null;
- let year = (new Date()).getFullYear();
- add_option('#year',String(year),'(Default: '+String(year)+')',true);
- while (year > 1998) {
- year = year - 1;
- add_option('#year',String(year),String(year),false);
- }
- if(localStorage.getItem(store_tag+"url")) {
- store = localStorage;
- } else if(sessionStorage.getItem(store_tag+"url")) {
- store = sessionStorage;
- }
- let qparams = queryParser();
- try {
- load_languages();
- load_cwes();
- allFieldsForm = schemaToForm(schemaUrl, "allFields");
- } catch(err) {
- console.error(err);
- console.log("Failed to create autocompleters");
- }
- if (store == null) {
- if("skip" in qparams)
- skip();
- else
- $('#loginModal').modal();
- } else {
- $('#loginModal .form-control').each(function(_,x) {
- var vid = $(x).attr('id');
- var val = store.getItem(store_tag+vid);
- $(x).val(val);
- if($(x).val() != val) {
- let f = new URL(val);
- add_option(x,f.toString(),f.host,1);
- }
- });
- client = new cveClient($('#org').val(),$('#user').val(),$('#key').val(),$('#url').val());
- try {
- /* If the key value is a URL it is an encrypted data URI */
- let _ = new URL($('#key').val());
- $.getScript("encrypt-storage.js").done(function() {
- console.log("Already encrypted key");
- activate_encryption();
- do_login();
- });
- } catch(_) {
- do_login();
- }
-
- }
-
- $('#allfields-tab').on('shown.bs.tab', function (event) {
- allFields(event.target, event.relatedTarget);
+$(function () {
+ store = null;
+ let year = new Date().getFullYear();
+ add_option("#year", String(year), "(Default: " + String(year) + ")", true);
+ while (year > 1998) {
+ year = year - 1;
+ add_option("#year", String(year), String(year), false);
+ }
+ if (localStorage.getItem(store_tag + "url")) {
+ store = localStorage;
+ } else if (sessionStorage.getItem(store_tag + "url")) {
+ store = sessionStorage;
+ }
+ let qparams = queryParser();
+ try {
+ load_languages();
+ load_cwes();
+ allFieldsForm = schemaToForm(schemaUrl, "allFields");
+ } catch (err) {
+ console.error(err);
+ console.log("Failed to create autocompleters");
+ }
+ if (store == null) {
+ if ("skip" in qparams) skip();
+ else $("#loginModal").modal();
+ } else {
+ $("#loginModal .form-control").each(function (_, x) {
+ var vid = $(x).attr("id");
+ var val = store.getItem(store_tag + vid);
+ $(x).val(val);
+ if ($(x).val() != val) {
+ let f = new URL(val);
+ add_option(x, f.toString(), f.host, 1);
+ }
});
+ client = new cveClient(
+ $("#org").val(),
+ $("#user").val(),
+ $("#key").val(),
+ $("#url").val(),
+ );
+ try {
+ /* If the key value is a URL it is an encrypted data URI */
+ let _ = new URL($("#key").val());
+ $.getScript("encrypt-storage.js").done(function () {
+ console.log("Already encrypted key");
+ activate_encryption();
+ do_login();
+ });
+ } catch (_) {
+ do_login();
+ }
+ }
+
+ $("#allfields-tab").on("shown.bs.tab", function (event) {
+ allFields(event.target, event.relatedTarget);
+ });
});
-async function get_pages(m,tag,fld,tbn,fun,fvars) {
- let itime = 0;
- for(var i=m.itemsPerPage; i< m.totalCount; i = i + m.itemsPerPage) {
- setTimeout(async function(i) {
- let ipage = Math.floor(i/m.itemsPerPage)+1;
- let popts = {page:ipage};
- if(fvars) {
- /* Append year or other options apart from page */
- Object.assign(popts,fvars[2]);
- }
- let x = await client[fun](null,null,popts);
- for(var j=0; j")
- .append($("
").addClass(rowClass)
- .append($("
").html(safeHTML(dp))
- .append($("
").html(safeHTML(r[d]))))).html();
- }
+ let tableid = $("#svTab a.active").attr("data-tableid");
+ client[tableid].bootstrapTable("destroy");
+ $("#svTab a.active").parent().find("a.refresh").click();
+}
+function objwalk(h, d, r, s) {
+ /* add a Class to some of the rows */
+ let rowClass = "normal";
+ if (d in { new: 1, warn: 1 }) {
+ rowClass = "h" + d;
+ /* Unique case of internal data no need to display it */
+ if (r[d] == 1) return h;
+ }
+ if (d in { secret: 1, password: 1, "API-secret": 1, "API-key": 1 })
+ rowClass = "hdanger";
+ if (typeof r[d] == "object") {
+ let mr = r[d];
+ let ls = d;
+ if (s) ls = s + "/" + d;
+ let f = Object.keys(mr).reduce(function (hr, dr) {
+ return objwalk(hr, dr, mr, ls);
+ }, "");
+ return h + f;
+ } else {
+ if (!r[d]) return h;
+ dp = d;
+ if (s) dp = s + "/" + d;
+ return (
+ h +
+ $("
")
+ .append(
+ $("
")
+ .addClass(rowClass)
+ .append(
+ $("
")
+ .html(safeHTML(dp))
+ .append($("
").html(safeHTML(r[d]))),
+ ),
+ )
+ .html()
+ );
+ }
}
function deepdive(_a, _b, row, el) {
- try {
- var tinfo = el.closest('tr').attr('data-uniqueid');
- if(tinfo)
- $('#detailtag').text("("+tinfo+")");
- else
- $('#detailtag').text('');
- } catch(err) {
- console.log("Ignore this error");
- $('#detailtag').text('');
- }
- /* Show the updaterecord button by default and hide it later
+ try {
+ var tinfo = el.closest("tr").attr("data-uniqueid");
+ if (tinfo) $("#detailtag").text("(" + tinfo + ")");
+ else $("#detailtag").text("");
+ } catch (err) {
+ console.log("Ignore this error");
+ $("#detailtag").text("");
+ }
+ /* Show the updaterecord button by default and hide it later
if user is not admin and not self */
- $('#updaterecord').show();
- $('#cvereject').addClass("d-none");
- $('#cvedetails').addClass('d-none');
- if("username" in row) {
- if(check_admin() || (row.username == client.user)) {
- $('#updaterecord').show();
- $('.selfadmin').show();
- } else {
- $('#updaterecord').hide();
- $('.selfadmin').hide();
- }
- $('#updaterecord').html("Update User");
- } else if(("cve_id" in row) && ("state" in row)) {
- $('#cveUpdateModal .mtitle').text("("+row.cve_id+")");
- if (row.state == "RESERVED") {
- $('#updaterecord').html("Edit & Publish CVE").show();
- $('#cveUpdateModal .cveupdate').html("Publish CVE");
- $('#cvedetails').addClass('d-none');
- $('#cvereject').removeClass('d-none');
- } else if (row.state == "PUBLISHED") {
- $('#updaterecord').html("Update CVE").show();
- $('#cvedetails').removeClass('d-none');
- $('#cveUpdateModal .cveupdate').html("Update CVE");
- $('#cvereject').removeClass("d-none");
- } else {
- if(row.state == "REJECTED") {
- $('#cvereject').addClass('d-none');
- $('#cvedetails').removeClass('d-none');
- }
- $('#updaterecord').hide();
- }
- } else
- $('#updaterecord').hide();
- display_object(row);
- $('#deepDive').attr('data-crecord',JSON.stringify(row)).modal();
+ $("#updaterecord").show();
+ $("#cvereject").addClass("d-none");
+ $("#cvedetails").addClass("d-none");
+ if ("username" in row) {
+ if (check_admin() || row.username == client.user) {
+ $("#updaterecord").show();
+ $(".selfadmin").show();
+ } else {
+ $("#updaterecord").hide();
+ $(".selfadmin").hide();
+ }
+ $("#updaterecord").html("Update User");
+ } else if ("cve_id" in row && "state" in row) {
+ $("#cveUpdateModal .mtitle").text("(" + row.cve_id + ")");
+ if (row.state == "RESERVED") {
+ $("#updaterecord").html("Edit & Publish CVE").show();
+ $("#cveUpdateModal .cveupdate").html("Publish CVE");
+ $("#cvedetails").addClass("d-none");
+ $("#cvereject").removeClass("d-none");
+ } else if (row.state == "PUBLISHED") {
+ $("#updaterecord").html("Update CVE").show();
+ $("#cvedetails").removeClass("d-none");
+ $("#cveUpdateModal .cveupdate").html("Update CVE");
+ $("#cvereject").removeClass("d-none");
+ } else {
+ if (row.state == "REJECTED") {
+ $("#cvereject").addClass("d-none");
+ $("#cvedetails").removeClass("d-none");
+ }
+ $("#updaterecord").hide();
+ }
+ } else $("#updaterecord").hide();
+ display_object(row);
+ $("#deepDive").attr("data-crecord", JSON.stringify(row)).modal();
}
async function display_cvedetails(cve) {
- $('#deepDive .nav-default').click();
- if(!cve) {
- let crecord = JSON.parse($('#deepDive').attr('data-crecord'));
- cve = crecord.cve_id;
- }
- let f = await client.getcvedetail(cve);
- if("error" in f) {
- swal_error("Unable to view CVE due to error: " + f.error +
- ": " + f.message);
- return;
- }
- let adp = get_deep(f,"containers.adp");
- if(get_deep(f,"containers.cna"))
- display_object(f.containers.cna,adp);
- else
- swal_error("Required information in cna.container is not " +
- "available or missing ");
+ $("#deepDive .nav-default").click();
+ if (!cve) {
+ let crecord = JSON.parse($("#deepDive").attr("data-crecord"));
+ cve = crecord.cve_id;
+ }
+ let f = await client.getcvedetail(cve);
+ if ("error" in f) {
+ swal_error(
+ "Unable to view CVE due to error: " + f.error + ": " + f.message,
+ );
+ return;
+ }
+ let adp = get_deep(f, "containers.adp");
+ if (get_deep(f, "containers.cna")) display_object(f.containers.cna, adp);
+ else
+ swal_error(
+ "Required information in cna.container is not " + "available or missing ",
+ );
}
function swapout(w) {
- $(w).parent().find('table tbody tr.normal').toggleClass('d-none');
- if($(w).html().indexOf('View') > -1)
- $(w).html('Hide JSON');
- else
- $(w).html('View JSON');
+ $(w).parent().find("table tbody tr.normal").toggleClass("d-none");
+ if ($(w).html().indexOf("View") > -1) $(w).html("Hide JSON");
+ else $(w).html("View JSON");
}
function display_object() {
- $('#deepDive .tab-pane').removeClass('active show');
- $('#f0').addClass('active show');
- for(let i=0; i' +
- safeHTML(JSON.stringify(obj,null,3)) + '