From 03f6d51d385e3a836f98f6f780599c90bc85521a Mon Sep 17 00:00:00 2001 From: Shamal Faily Date: Sun, 11 Feb 2018 01:20:23 -0800 Subject: [PATCH] Fix #164 --- cairis/core/MySQLDatabaseProxy.py | 11 ++++++++- cairis/core/RoleEnvironmentProperties.py | 6 ++++- cairis/test/test_RoleAPI.py | 4 +++- cairis/tools/ModelDefinitions.py | 4 +++- cairis/web/dist/js/cairis/roles.js | 23 +++++++++++++++---- cairis/web/fastTemplates/editRoleOptions.html | 22 ++++++++++++++++-- 6 files changed, 59 insertions(+), 11 deletions(-) diff --git a/cairis/core/MySQLDatabaseProxy.py b/cairis/core/MySQLDatabaseProxy.py index 92735c36b..616337b15 100644 --- a/cairis/core/MySQLDatabaseProxy.py +++ b/cairis/core/MySQLDatabaseProxy.py @@ -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) @@ -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 = {} diff --git a/cairis/core/RoleEnvironmentProperties.py b/cairis/core/RoleEnvironmentProperties.py index 3133d117e..1b2d771a4 100644 --- a/cairis/core/RoleEnvironmentProperties.py +++ b/cairis/core/RoleEnvironmentProperties.py @@ -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 diff --git a/cairis/test/test_RoleAPI.py b/cairis/test/test_RoleAPI.py index 820763520..f476a3888 100644 --- a/cairis/test/test_RoleAPI.py +++ b/cairis/test/test_RoleAPI.py @@ -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 = { diff --git a/cairis/tools/ModelDefinitions.py b/cairis/tools/ModelDefinitions.py index 4a2d76b30..29a787983 100644 --- a/cairis/tools/ModelDefinitions.py +++ b/cairis/tools/ModelDefinitions.py @@ -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()) diff --git a/cairis/web/dist/js/cairis/roles.js b/cairis/web/dist/js/cairis/roles.js index e152c859f..392a93938 100644 --- a/cairis/web/dist/js/cairis/roles.js +++ b/cairis/web/dist/js/cairis/roles.js @@ -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++] = ""+ val + ""; }); - var theResp = obj.theResponses; - $.each(theResp , function (index1, valu) { - textForResponses[j++] = ""+ valu.__python_tuple__[0] +""+ valu.__python_tuple__[1] +""; + i = 0; + $.each(obj.theResponses , function (index1, valu) { + textForResponses[i++] = ""+ valu.__python_tuple__[0] +""+ valu.__python_tuple__[1] +""; }); + i = 0; + $.each(obj.theGoals , function (index1, val) { + textForGoals[i++] = ""+ val +""; + }); + i = 0; + $.each(obj.theRequirements , function (index1, val) { + textForRequirements[i++] = ""+ val +""; + }); + $("#theCounterMeasures").find('tbody').append(textForCounterMeasures.join('')); $("#theResponses").find('tbody').append(textForResponses.join('')); + $("#theGoals").find('tbody').append(textForGoals.join('')); + $("#theRequirements").find('tbody').append(textForRequirements.join('')); } }) }); diff --git a/cairis/web/fastTemplates/editRoleOptions.html b/cairis/web/fastTemplates/editRoleOptions.html index 2e7d10e65..13803e96d 100644 --- a/cairis/web/fastTemplates/editRoleOptions.html +++ b/cairis/web/fastTemplates/editRoleOptions.html @@ -57,7 +57,7 @@
-
+
@@ -66,7 +66,7 @@
ResponseCost
-
+
@@ -75,6 +75,24 @@
Countermeasure
+
+ + + + + + +
Goals
+
+
+ + + + + + +
Requirements
+