Skip to content

Commit

Permalink
Fix #164
Browse files Browse the repository at this point in the history
  • Loading branch information
failys committed Feb 11, 2018
1 parent 87ebdaa commit 03f6d51
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 11 deletions.
11 changes: 10 additions & 1 deletion cairis/core/MySQLDatabaseProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,9 @@ def getRoles(self,constraintId = -1):
for environmentId,environmentName in self.dimensionEnvironments(roleId,'role'):
roleResponses = self.roleResponsibilities(roleId,environmentId)
roleCountermeasures = self.roleCountermeasures(roleId,environmentId)
properties = RoleEnvironmentProperties(environmentName,roleResponses,roleCountermeasures)
roleGoals = self.roleGoals(roleId,environmentId)
roleRequirements = self.roleRequirements(roleId,environmentId)
properties = RoleEnvironmentProperties(environmentName,roleResponses,roleCountermeasures,roleGoals,roleRequirements)
environmentProperties.append(properties)
parameters = RoleParameters(roleName,roleType,shortCode,roleDescription,environmentProperties)
role = ObjectFactory.build(roleId,parameters)
Expand Down Expand Up @@ -1457,6 +1459,13 @@ def roleResponsibilities(self,roleId,environmentId):
def roleCountermeasures(self,roleId,environmentId):
return self.responseList('call roleCountermeasures(:rId,:eId)',{'rId':roleId,'eId':environmentId},'MySQL error getting countermeasures for role id ' + str(roleId) + ' in environment ' + str(environmentId))

def roleGoals(self,roleId,environmentId):
return self.responseList('call roleGoalResponsibilities(:rId,:eId)',{'rId':roleId,'eId':environmentId},'MySQL error getting goals for role id ' + str(roleId) + ' in environment ' + str(environmentId))

def roleRequirements(self,roleId,environmentId):
return self.responseList('call roleRequirementResponsibilities(:rId,:eId)',{'rId':roleId,'eId':environmentId},'MySQL error getting requirements for role id ' + str(roleId) + ' in environment ' + str(environmentId))


def getCountermeasures(self,constraintId = -1):
cmRows = self.responseList('call getCountermeasures(:id)',{'id':constraintId},'MySQL error getting countermeasures')
countermeasures = {}
Expand Down
6 changes: 5 additions & 1 deletion cairis/core/RoleEnvironmentProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
__author__ = 'Shamal Faily'

class RoleEnvironmentProperties(EnvironmentProperties):
def __init__(self,environmentName,responses,countermeasures):
def __init__(self,environmentName,responses,countermeasures,goals,requirements):
EnvironmentProperties.__init__(self,environmentName)
self.theResponses = responses
self.theCountermeasures = countermeasures
self.theGoals = goals
self.theRequirements = requirements

def responses(self): return self.theResponses
def countermeasures(self): return self.theCountermeasures
def goals(self): return self.theGoals
def requirements(self): return self.theRequirements
4 changes: 3 additions & 1 deletion cairis/test/test_RoleAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def setUp(self):
RoleEnvironmentProperties(
environmentName='Core Technology',
responses=[('Prevent Unauthorised Certificate Access', 'High')],
countermeasures=['Location-based X.509 extension']
countermeasures=['Location-based X.509 extension'],
goals=[],
requirements=[]
)
]
self.new_role_dict = {
Expand Down
4 changes: 3 additions & 1 deletion cairis/tools/ModelDefinitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,9 @@ class RoleEnvironmentPropertiesModel(object):
resource_fields = {
"theEnvironmentName": fields.String,
"theResponses": fields.List(fields.List(fields.String)),
"theCountermeasures": fields.List(fields.String)
"theCountermeasures": fields.List(fields.String),
"theGoals": fields.List(fields.String),
"theRequirements": fields.List(fields.String)
}
required = list(resource_fields.keys())

Expand Down
23 changes: 18 additions & 5 deletions cairis/web/dist/js/cairis/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,37 @@ mainContent.on("click", '.roleEnvironmentClick', function () {
$(this).closest('tr').addClass('active').siblings().removeClass('active');
$("#theCounterMeasures").find('tbody').empty();
$("#theResponses").find('tbody').empty();
$("#theGoals").find('tbody').empty();
$("#theRequirements").find('tbody').empty();
var text = $(this).text();
var environments = JSON.parse($.session.get("RoleEnvironments"));
var textForCounterMeasures = [];
var textForResponses = [];
var textForGoals = [];
var textForRequirements = [];
var i =0;
var j = 0;
$.each(environments, function (index, obj) {
if(obj.theEnvironmentName == text){
$.each(obj.theCountermeasures, function (index, val) {
debugLogger("Found one" + val);
textForCounterMeasures[i++] = "<tr><td>"+ val + "</td><tr>";
});
var theResp = obj.theResponses;
$.each(theResp , function (index1, valu) {
textForResponses[j++] = "<tr><td>"+ valu.__python_tuple__[0] +"</td><td>"+ valu.__python_tuple__[1] +"</td></tr>";
i = 0;
$.each(obj.theResponses , function (index1, valu) {
textForResponses[i++] = "<tr><td>"+ valu.__python_tuple__[0] +"</td><td>"+ valu.__python_tuple__[1] +"</td></tr>";
});
i = 0;
$.each(obj.theGoals , function (index1, val) {
textForGoals[i++] = "<tr><td>"+ val +"</td></tr>";
});
i = 0;
$.each(obj.theRequirements , function (index1, val) {
textForRequirements[i++] = "<tr><td>"+ val +"</td></tr>";
});

$("#theCounterMeasures").find('tbody').append(textForCounterMeasures.join(''));
$("#theResponses").find('tbody').append(textForResponses.join(''));
$("#theGoals").find('tbody').append(textForGoals.join(''));
$("#theRequirements").find('tbody').append(textForRequirements.join(''));
}
})
});
Expand Down
22 changes: 20 additions & 2 deletions cairis/web/fastTemplates/editRoleOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<div class="col-sm-10 col-md-10">
<div class="panel panel-default">
<div class="row row-eq-height">
<div class="col-sm-4 col-md-4">
<div class="col-sm-3 col-md-3">
<table id="theResponses" class="table table-condensed table-striped table-bordered">
<thead>
<tr><th>Response</th><th>Cost</th></tr>
Expand All @@ -66,7 +66,7 @@
</tbody>
</table>
</div>
<div class="col-sm-4 col-md-4">
<div class="col-sm-3 col-md-3">
<table id="theCounterMeasures" class="table table-condensed table-striped table-bordered">
<thead>
<tr><th>Countermeasure</th></tr>
Expand All @@ -75,6 +75,24 @@
</tbody>
</table>
</div>
<div class="col-sm-3 col-md-3">
<table id="theGoals" class="table table-condensed table-striped table-bordered">
<thead>
<tr><th>Goals</th></tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="col-sm-3 col-md-3">
<table id="theRequirements" class="table table-condensed table-striped table-bordered">
<thead>
<tr><th>Requirements</th></tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 03f6d51

Please sign in to comment.