Skip to content

Commit

Permalink
Exporter in Analyst mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-vsarvepalli committed Sep 18, 2022
1 parent 76a3097 commit d265dcb
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 21 deletions.
36 changes: 35 additions & 1 deletion ssvc-calc/css.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
/* css version 2.2.7 */
.ssvcvector {
color: #7d1d1d;
}
.blackbody .ssvcvector {
color: #ffc107;
}
.export-header {
width: 100%;
}
.export-header h3 {
display: inline;
text-decoration: underline;
}
.export-header span {
padding: 8px;
}
.exportdiv {
top: 0px;
left: 30%;
border-radius: 6px;
border: 1px solid #333;
}
.blackbody .exportdiv {
border: 1px solid white;
}
.blackbody .radiogaga {
color: white;
}
.radiogaga > div.selected {
border: 1px solid white;
border: 1px solid #333;
border-radius: 4px;
padding-left: 4px;
}
.blackbody .radiogaga > div.selected {
border: 1px solid #eee;
}
.exportdiv {
background: rgba(255,255,255,0.95);
}
.blackbody .exportdiv {
background: rgba(32,32,32,0.9);
}
.margtop {
margin-top: 0.7em;
}
Expand Down
26 changes: 19 additions & 7 deletions ssvc-calc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<link href="magicsuggest-min.css" rel="stylesheet">
<script src="magicsuggest-min.js" async defer></script>
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="css.css?v=1663464249">
<script src="ungraph.js?v=1663464249"></script>
<link rel="stylesheet" href="css.css?v=1663537129">
<script src="ungraph.js?v=1663537129"></script>
</head>
<body class="text-center blackbody">
<img src="../moon_icon.png" class="cert-tweet" alt="CERT Logo"
Expand Down Expand Up @@ -87,6 +87,12 @@ <h4 class="cover-heading">
<div class="cover_heading_append d-none">
(CISA Coordinator v2)
</div>
<button type="button" class="btn btn-secondary" id="exportopen"
data-toggle="tooltip" data-placement="bottom"
title="Show Export" style="display:none"
onclick="export_show(false)">
Export</button>

</h4>
<div class="alert" id="topalert" role="alert">
This is an alert!
Expand All @@ -106,7 +112,8 @@ <h4 class="cover-heading">
data-toggle="tooltip" data-placement="bottom"
title="Explore the full decision tree of this SSVC Instance"
onclick="show_full_tree()">
Show Full Tree</button>
Show Full Tree
</button>
<a href="javascript:void(0)" title="View previous score"
alt="View previous score" id="table_toggle" style="display:none"
onclick="cve_table_toggle()">
Expand Down Expand Up @@ -399,8 +406,13 @@ <h4>Decision Tree Usage:</h4>
<div id="biscuit" class="top_fixed tescape tloader">
</div>
<div id="exporter" class="d-none">
<div class="row justify-content-center position-absolute exportdiv"
style="top:180px;left:30%">
<div class="row justify-content-center position-absolute exportdiv">
<div class="export-header">
<h3> Export Calculated Score</h3>
<button type="button" aria-label="Close" class="close h3" onclick="$(this).parent().parent().remove()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="col-auto">
<table class="table table-borderless w-auto">
<tbody>
Expand All @@ -424,7 +436,7 @@ <h4>Decision Tree Usage:</h4>
<tr>
<td>
<div>
<span class="text text-warning ssvcvector d-inline">
<span class="text ssvcvector d-inline">
</span>
<span onclick="copym('#graph .ssvcvector')">
<img src="icons8-copy-60.png"
Expand Down Expand Up @@ -478,7 +490,7 @@ <h4>Decision Tree Usage:</h4>
</form>
<canvas id="canvas" style="display:none">
</div>
<script src="ssvc.js?v=1663464249"></script>
<script src="ssvc.js?v=1663537129"></script>
</body>
</html>

47 changes: 36 additions & 11 deletions ssvc-calc/ssvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ function dynamic_mwb(w) {
}
function export_show(novector) {
console.log(novector);
$('#exportopen').show();
var ptranslate = "translate(120,-250)";
if(window.innerWidth <= 1000)
ptranslate = "translate(30,-90) scale(0.4,0.4)";
d3.select("#pgroup").transition()
.duration(600).attr("transform", ptranslate);
var q = $('#exporter').html();
$('.exportActive .exportdiv').remove();
$('.exportActive').removeClass('exportActive');
if($('#graph-ungraph').val() == "Analyst")
$('#ungraph').append(q).addClass('exportActive');
Expand Down Expand Up @@ -467,19 +469,39 @@ function permalink() {
"SSVCv2/E:A/V:S/T:T/M:H/D:C/2021-01-09/&CVE-2014-01-01&Coordinator" */
var sI = {}
var last_precheck = false;
/* Last three elements are not needed Decision,Timestamp,Empty as
vector ends with a slash */
for(var i=1;i<fm.length-3;i++) {
var dtup = fm[i].split(":");
/* Sort elements according to export_schema.decisions and run the simClicks */
let sfm = export_schema.decision_points.reduce(function(x,y) {
let t = fm.filter(function(z) { return y.key == z[0] });
if(t.length == 1) x.push(t[0]);
else console.log("Error important decision is missing in vector "+y.key)
return x;
},[]);
/* Remove the last element which is the Decision itself*/
sfm.pop();
for(var i=0;i<sfm.length;i++) {
var dtup = sfm[i].split(":");
var fstep = export_schema.decision_points.filter(x => x.key == dtup[0]);
if(fstep.length != 1) {
console.log("This decision point does not exist");
console.log(dtup);
continue;
}
var fopt = fstep[0].options.filter(x => x.key == dtup[1]);
if((fstep[0].label in ischild) && ($('#graph-ungraph').val() != "Analyst") ) {
console.log("This is a child decision, do it later");
if($('#graph-ungraph').val() == "Analyst") {
if(fstep[0].decision_type == "complex") {
console.log("Complex decision in Analyst mode skip "+fstep[0].label);
/* If this is the last element then finish_permalink and add SSVC
Vector creation for Analyst mode with appropriate delay*/
if(i == sfm.length-1) {
setTimeout(function() {
make_ssvc_vector();
finish_permalink(pchildren);
},600*i);
}
continue;
}
} else if(fstep[0].label in ischild) {
console.log("This is a child decision in Graph mode do it later "+fstep[0].label);
pchildren.push({
index: i-1,
childlabel: fstep[0].label,
Expand All @@ -488,21 +510,22 @@ function permalink() {
continue;
}
var precheck = fopt[0].label.toLowerCase();
sI[precheck] = setInterval(
function(u,p,last_precheck) {
var tag = fstep[0].label + ":" + precheck;
sI[tag] = setInterval(
function(u,p,tag,last_precheck) {
var ptype = 'textPath';
if($('#graph-ungraph').val() == "Analyst")
ptype = 'input';
var pselect = $(ptype+'.prechk-'+u+'[parentname="'+p+'"]');
if(pselect.length == 1) {
pselect.simClick();
clearInterval(sI[u]);
delete sI[u];
clearInterval(sI[tag]);
delete sI[tag];
if(last_precheck)
finish_permalink(pchildren);
return;
}
},600*i,precheck,fstep[0].label,i == fm.length-4);
},600*i,precheck,fstep[0].label,tag,i == sfm.length-1);
}
setTimeout(function() {
for (let k in sI) {
Expand Down Expand Up @@ -1541,6 +1564,7 @@ function dt_start() {
showFullTree = false
$('svg.mgraph').remove();
$('.exportActive .exportdiv').remove();
$('#exportopen').hide();
var xraw = JSON.parse(JSON.stringify(raw));
treeData=grapharray(xraw);
draw_graph();
Expand All @@ -1560,6 +1584,7 @@ function dt_clear() {
$('#zoomcontrol').hide();
$('svg.mgraph').remove();
$('#graph').html('');
$('#exportopen').hide();
}

function show_full_tree() {
Expand Down
8 changes: 6 additions & 2 deletions ssvc-calc/ungraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function ungraph() {
"name": fsattr.id,
"data-label": x.label,
"onclick": "ugchoose(this,false)",
"class":"form-check-input margtop",
"parentname": x.label,
"class":"form-check-input margtop prechk-"+y.label.toLowerCase(),
"value": y.label})).append(
$('<label>').addClass("h3").html(y.label).on("click",function() {
$(this).siblings().click();
Expand Down Expand Up @@ -229,8 +230,10 @@ function make_decision() {
})

var xfinal = export_schema.decisions_table.find( function(x) {
if(found)
if(found) {
export_show();
return;
}
var d = Object.keys(x);
var match = 0;
for(var j=0; j< d.length; j++) {
Expand All @@ -239,6 +242,7 @@ function make_decision() {
}
if(match == d.length - 1) {
found = true;
export_show();
var fselect = $('div.final-select');
var flabel = fselect.data('label');
var fvalue = x[flabel]
Expand Down

0 comments on commit d265dcb

Please sign in to comment.