Skip to content

Commit

Permalink
Fix #291
Browse files Browse the repository at this point in the history
  • Loading branch information
cairisuser authored and cairisuser committed Aug 2, 2018
1 parent 514fad2 commit 66ed101
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
1 change: 1 addition & 0 deletions cairis/data/ThreatDAO.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def convert_props(self, real_props=None, fake_props=None):
new_attr = SecurityAttribute(attr_name, attr_value, attr_rationale)
new_attrs.append(new_attr)
real_prop.theProperties = new_attrs
del real_prop.theRationale
new_props.append(real_prop)

return new_props
Expand Down
6 changes: 3 additions & 3 deletions cairis/web/dist/js/cairis/attackers.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ mainContent.on('click', ".deleteAttackerEnv", function () {
UIenv.find(".attackerEnvironment:first").trigger('click');
}
else {
$("#Properties").hide("fast");
$("#attackerstabsID").hide("fast");
}
return false;
}
Expand Down Expand Up @@ -340,7 +340,7 @@ function addAttackerEnvironment() {
$(document).find(".attackerEnvironment").each(function () {
if($(this).text() == text){
$(this).trigger("click");
$("#Properties").show("fast");
$("#attackerstabsID").show("fast");
$('#chooseEnvironment').modal('hide');
}
});
Expand Down Expand Up @@ -413,7 +413,7 @@ $(document).on("click", "#addNewAttacker", function () {
$("#editAttackerOptionsForm").validator();
$("#UpdateAttacker").text("Create");
$("#editAttackerOptionsForm").addClass("new");
$("#Properties").hide();
$("#attackerstabsID").hide();
$.session.set("Attacker", JSON.stringify(jQuery.extend(true, {},attackerDefault )));
});
});
Expand Down
60 changes: 30 additions & 30 deletions cairis/web/dist/js/cairis/threats.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function viewThreat(thrName) {
refreshDimensionSelector($('#theType'),'threat_type',undefined,function(){
$("#theType").val(data.theType);
},['All']);
$.session.set("theThreat", JSON.stringify(data));
$.session.set("Threat", JSON.stringify(data));

$('#theTags').val(data.theTags.join(', '));
data.theTags = [];
Expand All @@ -128,14 +128,14 @@ function viewThreat(thrName) {
$(document).on("click", "#addNewThreat", function () {
refreshObjectBreadCrumb('New Threat');
activeElement("objectViewer");
$.session.set("Threat", JSON.stringify(jQuery.extend(true, {},threatDefault )));
fillOptionMenu("fastTemplates/editThreatOptions.html", "#objectViewer", null, true, true, function () {
$("#editThreatOptionsform").validator();
$("#UpdateThreat").text("Create");
$("#editThreatOptionsform").addClass("newThreat");
refreshDimensionSelector($('#theType'),'threat_type',undefined,function() {
$("#Properties").hide();
$("#threatstabsID").hide();
},['All']);
$.session.set("theThreat", JSON.stringify(jQuery.extend(true, {},threatDefault )));
});
});

Expand All @@ -146,9 +146,9 @@ function viewIntroducedThreat(dirEntry) {
$("#UpdateThreat").text("Create");
$("#editThreatOptionsform").addClass("newThreat");
refreshDimensionSelector($('#theType'),'threat_type',undefined,function() {
$("#Properties").hide();
$("#threatstabsID").hide();
},['All']);
$.session.set("theThreat", JSON.stringify(jQuery.extend(true, {},threatDefault )));
$.session.set("Threat", JSON.stringify(jQuery.extend(true, {},threatDefault )));
$('#theThreatName').val(dirEntry.theLabel);
$('#theType').val(dirEntry.theType);
$('#theMethod').val(dirEntry.theName + ': ' + dirEntry.theDescription + "\nReference: " + dirEntry.theReference);
Expand All @@ -163,7 +163,7 @@ $(document).on("click","#introduceThreatDirectoryEntry", function() {
mainContent.on("click", ".threatEnvironments", function () {
$(this).closest('tr').addClass('active').siblings().removeClass('active');
clearThreatEnvInfo();
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var envName = $(this).text();
$.session.set("threatEnvironmentName", envName);
$("#threatAssets").find("tbody").empty();
Expand Down Expand Up @@ -202,12 +202,12 @@ mainContent.on('click', '#addAssettoThreat', function () {

function addAssetToThreatEnvironment() {
var text = $("#chooseEnvironmentSelect").val();
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var theEnvName = $.session.get("threatEnvironmentName");
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
env.theAssets.push(text);
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
appendThreatAsset(text);
}
});
Expand All @@ -230,36 +230,36 @@ mainContent.on('click','#addAttackertoThreat', function () {
function addAttackerToEnvironment() {
var text = $("#chooseEnvironmentSelect").val();
var theEnvName = $.session.get("threatEnvironmentName");
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
$.each(threat.theEnvironmentProperties, function (index, env) {
if (env.theEnvironmentName == theEnvName) {
env.theAttackers.push(text);
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
appendThreatAttacker(text);
}
});
};

mainContent.on('change', '#theLikelihood', function () {
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var theEnvName = $.session.get("threatEnvironmentName");
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
env.theLikelihood = $("#theLikelihood option:selected").text();
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
}
});
});

mainContent.on('click', '.removeThreatAsset', function () {
var assetText = $(this).closest(".threatAssets").text();
$(this).closest("tr").remove();
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var theEnvName = $.session.get("threatEnvironmentName");
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
env.theAssets.splice( $.inArray(assetText,env.theAssets) ,1 );
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
}
});
});
Expand All @@ -268,11 +268,11 @@ mainContent.on('click','.removeThreatAttacker', function () {
var attackerName = $(this).closest(".threatAttackers").text();
$(this).closest("tr").remove();
var theEnvName = $.session.get("threatEnvironmentName");
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
env.theAttackers.splice( $.inArray(attackerName,env.theAttackers) ,1 );
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
}
});
});
Expand Down Expand Up @@ -307,7 +307,7 @@ function addThreatSecurityProperty(e) {
prop.value = $("#theSecurityPropertyValue").val();
prop.rationale = $("#theSecurityPropertyRationale").val()

var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var theEnvName = $.session.get("threatEnvironmentName");
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
Expand All @@ -316,7 +316,7 @@ function addThreatSecurityProperty(e) {
secProp.value = prop.value;
secProp.rationale = prop.rationale;
threat.theEnvironmentProperties[index].theProperties[idx] = secProp;
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
appendThreatProperty(prop);
}
});
Expand Down Expand Up @@ -350,15 +350,15 @@ function updateThreatSecurityProperty() {
updProp.value = $("#theSecurityPropertyValue").val();
updProp.rationale = $("#theSecurityPropertyRationale").val();

var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var theEnvName = $.session.get("threatEnvironmentName");

$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
$.each(env.theProperties, function(idx, secProp){
if (updProp.name == secProp.name) {
threat.theEnvironmentProperties[index].theProperties[idx] = updProp;
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
propRow.find("td:eq(1)").text(updProp.name);
propRow.find("td:eq(2)").text(updProp.value);
propRow.find("td:eq(3)").text(updProp.rationale);
Expand Down Expand Up @@ -402,19 +402,19 @@ function addThreatEnvironment() {
appendThreatEnvironment(text);
var environment = jQuery.extend(true, {},threatEnvironmentDefault );
environment.theEnvironmentName = text;
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
threat.theEnvironmentProperties.push(environment);
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
$(document).find(".threatEnvironments").each(function () {
if($(this).text() == text){
$(this).trigger("click");
$("#Properties").show("fast");
$("#threatstabsID").show("fast");
}
});
};

function commitThreat() {
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
if (threat.theEnvironmentProperties.length == 0) {
alert("Environments not defined");
}
Expand Down Expand Up @@ -447,17 +447,17 @@ function commitThreat() {
mainContent.on('click', ".deleteThreatEnv", function () {
var envi = $(this).next(".threatEnvironments").text();
$(this).closest("tr").remove();
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == envi){
threat.theEnvironmentProperties.splice( index ,1 );
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
var UIenv = $("#theThreatEnvironments").find("tbody");
if(jQuery(UIenv).has(".threatEnvironments").length){
UIenv.find(".threatEnvironments:first").trigger('click');
}
else {
$("#Properties").hide("fast");
$("#threatstabsID").hide("fast");
}
return false;
}
Expand All @@ -467,7 +467,7 @@ mainContent.on('click', ".deleteThreatEnv", function () {
mainContent.on('click', ".removeThreatProperty", function () {
var propName = $(this).closest("tr").find("td:eq(1)").text();
$(this).closest("tr").remove();
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var theEnvName = $.session.get("threatEnvironmentName");
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
Expand All @@ -477,7 +477,7 @@ mainContent.on('click', ".removeThreatProperty", function () {
threat.theEnvironmentProperties[index].theProperties[idx].rationale = 'None';
}
});
$.session.set("theThreat", JSON.stringify(threat));
$.session.set("Threat", JSON.stringify(threat));
}
});
});
Expand Down Expand Up @@ -513,7 +513,7 @@ $(document).on('click', 'td.deleteThreatButton', function (e) {
function fillThreatPropProperties(extra){
var propBox = $("#thePropName");
propBox.empty();
var threat = JSON.parse($.session.get("theThreat"));
var threat = JSON.parse($.session.get("Threat"));
var theEnvName = $.session.get("threatEnvironmentName");
$.each(threat.theEnvironmentProperties, function (index, env) {
if(env.theEnvironmentName == theEnvName){
Expand Down
3 changes: 1 addition & 2 deletions cairis/web/dist/js/objects/jsonDefaultObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,14 @@ var threatEnvironmentDefault = {
"theLikelihood": "",
"theEnvironmentName": "",
"theAttackers": [],
"theRationale": [],
"theProperties": [ConfidentialitySecurityAttribute,IntegritySecurityAttribute,AvailabilitySecurityAttribute,AccountabilitySecurityAttribute,AnonymitySecurityAttribute,PseudonymitySecurityAttribute,UnlinkabilitySecurityAttribute,UnobservabilitySecurityAttribute]
};
var threatDefault = {
"theTags": [],
"theThreatName": "",
"theType": "",
"theMethod": "",
"theProperties": []
"theEnvironmentProperties": []
};

var attackerEnvDefault = {
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editAttackerOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>
<div class="col-sm-10 col-md-10">
<div class="panel panel-default">
<div class="row row-eq-height">
<div class="row row-eq-height" id="attackerstabsID">
<div class="col-sm-4 col-md-4">
<table id="attackerRole" class="table table-condensed table-striped table-bordered table-hover">
<thead><tr><th id="addRoletoAttacker" class="addRemove"> <i class="fa fa-plus"></i></th><th>Role <i class="glyphicon glyphicon-question-sign" rel="tooltip" title="The role taken when attacking the system." id="attackerRoleHelp"></i></th></tr></thead>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editThreatOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</div>
</div>
<div class="col-sm-10 col-md-10">
<div class="panel panel-default">
<div class="panel panel-default" id="threatstabsID">
<div class="row">
<div class="col-sm-2 col-md-2">
<label for"theLikelihood" class="control-label"> Likelihood</label>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editVulnerabilityOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>
</div>
<div class="col-sm-10 col-md-10">
<div class="panel panel-default">
<div class="panel panel-default" id="vulnerabilitiestabsID">
<div class="row">
<div class="col-sm-2 col-md-2">
<label for="theSeverity" class="control-label"> Severity</label>
Expand Down

0 comments on commit 66ed101

Please sign in to comment.