Skip to content

Commit

Permalink
Merge pull request #241 from ishiDACo/feature/236-primary-src-patch
Browse files Browse the repository at this point in the history
Feature/236 primary src patch
  • Loading branch information
ishiDACo authored Sep 8, 2021
2 parents acd5993 + 8695882 commit 4288f16
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 8 deletions.
86 changes: 80 additions & 6 deletions dist/js/vulsrepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ const initDetail = function() {
$("#modal-label").text("");
$("#count-cert").text("0");
$("#count-References").text("0");
$("#CweID,#Mitigation,#Link,#cert,#exploit,#reference-tags,#References").empty();
$("#CweID,#Mitigation,#Link,#primary-src,#patch,#cert,#exploit,#reference-tags,#References").empty();
$("#Mitigation-section").hide();
$("#cert-section").hide();
$("#exploit-section").hide();
Expand Down Expand Up @@ -2542,6 +2542,71 @@ const displayDetail = function(cveID) {
$("#typeName_github").append("GitHub");
}

// ---Primary source---
var families = [];
for (const d of vulsrepo.detailRawData) {
families.push(d.data.family);
}

var primarySrcs = new Set();
var addPrimarySrc = function(target) {
if (data.cveContents[target] !== undefined) {
var cveContents = getCveContents(data.cveContents[target]);
for (const cveContent of cveContents) {
if (cveContent.references !== undefined) {
for (const reference of cveContent.references) {
if (target === "nvd" && reference.tags !== undefined && reference.tags.includes("Vendor Advisory")) {
primarySrcs.add(reference.link);
}
}
}
if (target === "nvd" || target === "jvn" || families.includes(target) || target === "github") {
if (cveContent.sourceLink !== "") {
primarySrcs.add(cveContent.sourceLink);
}
}
}
}
}

$.each(priority, function(i, i_val) {
addPrimarySrc(i_val);
});
if (isCheckNull(primarySrcs.size) === false) {
primarySrcs.add("https://nvd.nist.gov/vuln/detail/" + data.cveID);
}

$("#primary-src").append("<ul id='primary-src-list'>");
for (const link of primarySrcs) {
$("#primary-src-list").append("<li><a href=\"" + link + "\" rel='noopener noreferrer' target='_blank'>" + link + "</a></li>");
}
$("#primary-src").append("</ul>");

// ---Patch---
var patches = new Set();
if (data.cveContents["nvd"] !== undefined) {
var cveContents = getCveContents(data.cveContents["nvd"]);
for (const cveContent of cveContents) {
if (cveContent.references !== undefined) {
for (const reference of cveContent.references) {
if (reference.tags !== undefined && reference.tags.includes("Patch")) {
patches.add(reference.link);
}
}
}
}
}

if (patches.size > 0) {
$("#patch").append("<ul id='patch-list'>");
for (const link of patches) {
$("#patch-list").append("<li><a href=\"" + link + "\" rel='noopener noreferrer' target='_blank'>" + link + "</a></li>");
}
$("#patch").append("</ul>");
} else {
$("#patch").append("None");
}

// ---USCERT/JPCERT---
let countCert = 0;

Expand Down Expand Up @@ -2631,8 +2696,10 @@ const displayDetail = function(cveID) {
var references = new Map();
var cveContents = getCveContents(data.cveContents[target]);
for (const cveContent of cveContents) {
for (const reference of cveContent.references) {
references.set(reference.link, reference);
if (cveContent.references !== undefined) {
for (const reference of cveContent.references) {
references.set(reference.link, reference);
}
}
}
if (isCheckNull(references) === false) {
Expand All @@ -2644,16 +2711,23 @@ const displayDetail = function(cveID) {
for (const [key, x_val] of references) {
let src = "";
let itemTag = [];
// source
if (x_val.source !== undefined) {
src = x_val.source;
src = src.replace(" ", "");
tags.add(src);
itemTag.push(src);
} else if (isCheckNull(x_val.tags) === false) {
src = x_val.tags.join(", ");
}
// tags
if (isCheckNull(x_val.tags) === false) {
if (src !== "") {
src = src + ", ";
}
src = src + x_val.tags.join(", ");
x_val.tags.forEach(item => tags.add(item));
itemTag.push(...x_val.tags.map(tag => tag.replace(" ", "")));
} else {
}
if (itemTag.length == 0) {
tags.add(src);
itemTag.push(src);
}
Expand Down
20 changes: 18 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h3 class="drawer-title">Select File</h3>
<nav class="navbar navbar-inverse">

<div class="navbar-header">
<a id="toolName" class="navbar-brand">VulsRepo <span id="toolVersion">v0.6.4</span></a>
<a id="toolName" class="navbar-brand">VulsRepo <span id="toolVersion">v0.7.0</span></a>
</div>
<div class="collapse navbar-collapse">
<button id="Setting" type="button" class="btn btn-default navbar-btn glyphicon glyphicon-wrench pull-right"></button>
Expand Down Expand Up @@ -312,6 +312,22 @@ <h4 class="panel-title accordion-toggle title">
</div>
</div>
</div>
<div class="row full-width-row">
<div>
<div id="primary-src-section" class="col-xs-6">
<p class="bg-primary">
Primary source
</p>
<div id="primary-src"></div>
</div>
<div id="patch-section" class="col-xs-6">
<p class="bg-primary">
Patch
</p>
<div id="patch"></div>
</div>
</div>
</div>
<div class="row full-width-row">
<div>
<div id="cert-section" class="col-xs-6">
Expand All @@ -334,7 +350,7 @@ <h4 class="panel-title accordion-toggle title">
</div>
<div id="exploit-section" class="col-xs-6">
<section>
<div class="panel-group" id="panel-cert">
<div class="panel-group" id="panel-exploit">
<div class="panel panel-primary">
<div class="panel-heading">
<h4 class="panel-title accordion-toggle title">
Expand Down

0 comments on commit 4288f16

Please sign in to comment.