Ejemplo n.º 1
0
    def update_goal_association(self,
                                assoc,
                                environment_name,
                                goal_name,
                                subgoal_name,
                                pathValues=[]):
        if (assoc.theGoal == assoc.theSubGoal):
            raise CairisHTTPError(status_code=http.client.BAD_REQUEST,
                                  status="Self-refinement error",
                                  message='Cannot self-refine ' +
                                  assoc.theGoal)

        old_assoc = self.get_goal_association(environment_name, goal_name,
                                              subgoal_name, False)
        assocId = old_assoc.theId

        assocParams = GoalAssociationParameters(
            envName=assoc.theEnvironmentName,
            goalName=assoc.theGoal,
            goalDimName=assoc.theGoalDimension,
            aType=assoc.theAssociationType,
            subGoalName=assoc.theSubGoal,
            subGoalDimName=assoc.theSubGoalDimension,
            alternativeId=assoc.theAlternativeId,
            rationale=assoc.theRationale)
        assocParams.setId(assocId)
        try:
            self.db_proxy.updateGoalAssociation(assocParams)
        except ARMException as ex:
            self.close()
            raise ARMHTTPError(ex)
Ejemplo n.º 2
0
 def parameters(self):
     parameters = GoalAssociationParameters(
         self.theEnvironmentName, self.theGoal, self.theGoalDimension,
         self.theGoalAssociationType, self.theSubGoal,
         self.theSubGoalDimension, self.theAlternativeFlag,
         self.theRationale)
     parameters.setId(self.theGoalAssociationId)
     return parameters
Ejemplo n.º 3
0
 def on_goalRefinementOkButton_clicked(self,callback_data):
   goalName = self.decorator.getComboValue("goalRefNameCtrl")
   assocType = self.decorator.getComboValue("goalRefinementCtrl")
   if (self.reqIndicator == True):
     parameters = GoalAssociationParameters(self.theEnvironmentName,self.inputGoalName,'goal','and',goalName,'requirement')
   elif (self.goalIndicator == True):
     parameters = GoalAssociationParameters(self.theEnvironmentName,goalName,'goal',assocType,self.inputGoalName,'goal')
   else:
     parameters = GoalAssociationParameters(self.theEnvironmentName,self.inputGoalName,'goal',assocType,goalName,'goal')
   self.dbProxy.addGoalAssociation(parameters)
   self.window.destroy()
Ejemplo n.º 4
0
 def parameters(self):
     parameters = GoalAssociationParameters(
         self.theEnvironmentName,
         self.theGoal,
         self.theGoalDimension,
         self.theGoalAssociationType,
         self.theSubGoal,
         self.theSubGoalDimension,
         self.theAlternativeFlag,
         self.theRationale,
     )
     parameters.setId(self.theGoalAssociationId)
     return parameters
Ejemplo n.º 5
0
 def endElement(self, name):
     if name == 'manual_association':
         try:
             fromId = self.dbProxy.getDimensionId(self.theFromName,
                                                  self.theFromDim)
             toId = self.dbProxy.getDimensionId(self.theToName,
                                                self.theToDim)
             tableName = self.theFromDim + '_' + self.theToDim
             if (tableName, fromId, toId, self.theReferenceType
                 ) not in self.theManualAssociations:
                 self.theManualAssociations.add(
                     (tableName, fromId, toId, self.theReferenceType))
         except DatabaseProxyException as e:
             pass  # skipping invalid trace
         self.resetManualAssociationAttributes()
     elif name == 'goal_association':
         p = GoalAssociationParameters(
             self.theEnvironmentName, self.theGoalName, self.theGoalDim,
             self.theReferenceType, self.theSubGoalName, self.theSubGoalDim,
             self.isAlternative, self.theRationale)
         self.theGoalAssociations.append(p)
         self.resetGoalAssociationAttributes()
     elif name == 'dependency':
         p = DependencyParameters(self.theEnvironmentName, self.theDepender,
                                  self.theDependee, self.theDepType,
                                  self.theDependency, self.theRationale)
         self.theDependencyAssociations.append(p)
         self.resetDependencyAssociationAttributes()
     elif name == 'rationale':
         self.inRationale = 0
Ejemplo n.º 6
0
 def update_goal_association(self,assoc):
   old_assoc = self.get_goal_association(assoc.theEnvironmentName,assoc.theGoal,assoc.theSubGoal)
   id = old_assoc.theId
   assocParams = GoalAssociationParameters(
     envName=assoc.theEnvironmentName,
     goalName=assoc.theGoal,
     goalDimName=assoc.theGoalDimension,
     aType=assoc.theAssociationType,
     subGoalName=assoc.theSubGoal,
     subGoalDimName=assoc.theSubGoalDimension,
     alternativeId=assoc.theAlternativeId,
     rationale=assoc.theRationale)
   assocParams.setId(id)
   try:
     self.db_proxy.updateGoalAssociation(assocParams)
   except ARMException as ex:
     self.close()
     raise ARMHTTPError(ex)
Ejemplo n.º 7
0
 def update_goal_association(self, assoc):
     old_assoc = self.get_goal_association(assoc.theEnvironmentName,
                                           assoc.theGoal, assoc.theSubGoal)
     id = old_assoc.theId
     assocParams = GoalAssociationParameters(
         envName=assoc.theEnvironmentName,
         goalName=assoc.theGoal,
         goalDimName=assoc.theGoalDimension,
         aType=assoc.theAssociationType,
         subGoalName=assoc.theSubGoal,
         subGoalDimName=assoc.theSubGoalDimension,
         alternativeId=assoc.theAlternativeId,
         rationale=assoc.theRationale)
     assocParams.setId(id)
     try:
         self.db_proxy.updateGoalAssociation(assocParams)
     except ARMException as ex:
         self.close()
         raise ARMHTTPError(ex)
Ejemplo n.º 8
0
 def onTrace(self, dimensionName, fromId, isFrom, envName):
     dlg = TraceExplorer(self, dimensionName, isFrom, envName)
     if (dlg.ShowModal() == TRACE_BUTTONADD_ID):
         objtTable = self.GetTable()
         objtName = ((
             objtTable.om.objects())[self.GetGridCursorRow()]).name()
         p = GoalAssociationParameters(envName, objtName, dimensionName,
                                       'and', dlg.toValue(),
                                       dlg.toDimension(), 0, '')
         self.dbProxy.addGoalAssociation(p)
     dlg.Destroy()
Ejemplo n.º 9
0
 def on_newRequirementOkButton_clicked(self, callback_data):
     req = self.requirementParameters()
     self.dbProxy.addRequirement(req, self.theAssetName, True)
     reqLabel = self.dbProxy.lastRequirementLabel(self.theAssetName)
     self.theGoalAssociation = GoalAssociationParameters(
         self.theEnvironmentName,
         self.theGoalName,
         'goal',
         'and',
         reqLabel,
         'requirement',
     )
     self.dbProxy.addGoalAssociation(self.theGoalAssociation)
     self.window.destroy()
Ejemplo n.º 10
0
 def onGoal(self,evt):
   try:
     dlg = SingleGoalDialog(self,self.theEnvironmentName)
     if (dlg.ShowModal() == GOAL_BUTTONCOMMIT_ID):
       gp = dlg.parameters()
       self.dbProxy.addGoal(gp)
       gap = GoalAssociationParameters(self.theEnvironmentName,gp.name(),'goal','and',self.theUseCaseName,'usecase',0,'')
       self.dbProxy.addGoalAssociation(gap)
       ackDlg = wx.MessageDialog(self,'Added goal ' + gp.name(),'Refining goal',wx.OK)
       ackDlg.ShowModal()
   except ARMException,errorText:
     dlg = wx.MessageDialog(self,str(errorText),'Refining goal',wx.OK | wx.ICON_ERROR)
     dlg.ShowModal()
     dlg.Destroy()
Ejemplo n.º 11
0
def build(objt,domainName,mainFrame):
  reqGrid = mainFrame.requirementGrid()
  priority = objt.priority('','')
  rationale = objt.definition('','') 
  reqTxt = 'Specialise: ' + rationale
  fitCriterion = objt.fitCriterion()
  originatorName = 'Goal model analysis'
  reqType = 'Functional'
  reqId = reqGrid.AppendRequirement(reqTxt,priority,rationale,fitCriterion,originatorName,reqType)
  b = Borg()
  p = b.dbProxy
  for envProps in objt.environmentProperties():
    gp = GoalAssociationParameters(envProps.name(),objt.name(),'goal','and',reqTxt,'requirement',0,rationale)
    p.addGoalAssociation(gp)
Ejemplo n.º 12
0
 def add_goal_association(self, assoc):
     assocParams = GoalAssociationParameters(
         envName=assoc.theEnvironmentName,
         goalName=assoc.theGoal,
         goalDimName=assoc.theGoalDimension,
         aType=assoc.theAssociationType,
         subGoalName=assoc.theSubGoal,
         subGoalDimName=assoc.theSubGoalDimension,
         alternativeId=assoc.theAlternativeId,
         rationale=assoc.theRationale)
     try:
         self.db_proxy.addGoalAssociation(assocParams)
     except ARMException as ex:
         self.close()
         raise ARMHTTPError(ex)
 def on_roleResponsibilityOkButton_clicked(self, callback_data):
     roleName = self.decorator.getComboValue("roleRespNameCtrl")
     if (self.isGoalIndicator == False):
         roleId = self.dbProxy.getDimensionId(roleName, 'role')
         self.dbProxy.addTrace('requirement_role', self.theObjtId, roleId)
     else:
         goalDim = 'goal'
         if (self.isGoalIndicator == False):
             goalDim = 'requirement'
         parameters = GoalAssociationParameters(self.theEnvironmentName,
                                                self.theGoalName, goalDim,
                                                'responsible', roleName,
                                                'role')
         self.dbProxy.addGoalAssociation(parameters)
     self.window.destroy()
Ejemplo n.º 14
0
  def situateComponentView(self,cvName,envName,targets,goalObstacles):
    assetParametersList = []
    componentAssets = self.dbProxy.componentAssets(cvName)
    
    acDict = {}
    for assetName,componentName in componentAssets:
      assetParametersList.append(cairis.core.AssetParametersFactory.buildFromTemplate(assetName,[envName]))
      if assetName not in acDict:
        acDict[assetName] = []
      acDict[assetName].append(componentName)

    ops = []
    for goalName,obsName in goalObstacles:
      ops.append(GoalAssociationParameters(envName,goalName,'goal','obstruct',obsName,'obstacle',0,cvName + ' weakness analysis'))
    self.dbProxy.situateComponentView(cvName,envName,acDict,assetParametersList,targets,ops)
    self.theParentDialog.theMainWindow.updateObjectSelection()
Ejemplo n.º 15
0
 def generate_vulnerability(self, name):
     obs = self.db_proxy.dimensionObject(name, 'obstacle')
     vps = []
     gaps = []
     for op in obs.environmentProperties():
         vps.append(
             VulnerabilityEnvironmentProperties(op.name(), 'Negligible',
                                                op.concerns()))
         gaps.append(
             GoalAssociationParameters(op.name(), obs.name(), 'obstacle',
                                       'and',
                                       obs.name() + '(V)', 'vulnerability'))
     v = VulnerabilityParameters(
         obs.name() + '(V)', obs.name(),
         self.db_proxy.defaultValue('vulnerability_type'), [], vps)
     self.db_proxy.addVulnerability(v)
     for gap in gaps:
         self.db_proxy.addGoalAssociation(gap)
Ejemplo n.º 16
0
 def onObstacle(self, evt):
     try:
         dlg = SingleObstacleDialog(self, self.theEnvironmentName)
         if (dlg.ShowModal() == OBSTACLE_BUTTONCOMMIT_ID):
             op = dlg.parameters()
             self.dbProxy.addObstacle(op)
             gap = GoalAssociationParameters(self.theEnvironmentName,
                                             op.name(), 'obstacle', 'and',
                                             self.theUseCase, 'usecase', 0,
                                             '')
             self.dbProxy.addGoalAssociation(gap)
             ackDlg = wx.MessageDialog(self, 'Added obstacle ' + op.name(),
                                       'Refining goal', wx.OK)
             ackDlg.ShowModal()
     except ARMException, errorText:
         dlg = wx.MessageDialog(self, str(errorText), 'Refining obstacle',
                                wx.OK | wx.ICON_ERROR)
         dlg.ShowModal()
         dlg.Destroy()
Ejemplo n.º 17
0
    def add_goal_association(self, assoc):
        if (assoc.theGoal == assoc.theSubGoal):
            raise CairisHTTPError(status_code=http.client.BAD_REQUEST,
                                  status="Self-refinement error",
                                  message='Cannot self-refine ' +
                                  assoc.theGoal)

        assocParams = GoalAssociationParameters(
            envName=assoc.theEnvironmentName,
            goalName=assoc.theGoal,
            goalDimName=assoc.theGoalDimension,
            aType=assoc.theAssociationType,
            subGoalName=assoc.theSubGoal,
            subGoalDimName=assoc.theSubGoalDimension,
            alternativeId=assoc.theAlternativeId,
            rationale=assoc.theRationale)

        try:
            self.db_proxy.addGoalAssociation(assocParams)
        except ARMException as ex:
            self.close()
            raise ARMHTTPError(ex)
Ejemplo n.º 18
0
 def parentObstacle(self,obsName,assocType):
   self.theObstacleAssociation = GoalAssociationParameters(self.theEnvironmentName,obsName,'obstacle',assocType)
Ejemplo n.º 19
0
  def endElement(self,name):
    if name == 'intent':
      self.inIntent = 0
    elif name == 'definition':
      self.inDefinition = 0
    elif name == 'rationale':
      self.inRationale = 0
    elif name == 'motivation':
      self.theMotivations.append((self.theGoal,self.theValue,self.theDescription))
      self.resetMotivationElements()
    elif name == 'participant':
      self.theParticipants.append((self.theParticipant,self.theMotives,self.theResponsibilities))
      self.resetParticipantElements()
    elif name == 'description':
      self.inDescription = 0
      if self.inImplementation:
        self.inImplementation = 0
    elif name == 'consequences':
      self.inConsequences = 0
    elif name == 'implementation':
      self.inImplementation = 0
    elif name == 'known_uses':
      self.inKnownUses = 0
    elif name == 'related_patterns':
      self.inRelatedPatterns = 0
    elif name == 'obstacle':

      self.theObstacles.append( TemplateObstacleParameters(self.theObstacleName,self.theObstacleCategory,self.theDefinition,self.theConcerns,self.theResponsibilities,self.theProbability,self.theRationale))
      self.resetObstacleElements()
    elif name == 'obstacle_association':
      self.theObstacleAssociations.append((self.theObstacleName,self.theRefType,self.theSubObstacleName,self.theRationale))
      self.resetObstacleAssociationElements()
    elif name == 'attack_pattern':
      assetList = self.theTargets + self.theExploits
      for assetName in assetList:
        self.theAssetParameters.append(cairis.core.AssetParametersFactory.buildFromTemplate(assetName,[self.theEnvironment]))

      attackerNames = []
      for attackerName,attackerMotives,attackerCapabilities in self.theParticipants:
        attackerRoles = self.dbProxy.dimensionRoles(self.dbProxy.getDimensionId(attackerName,'persona'),self.dbProxy.getDimensionId(self.theEnvironment,'environment'),'persona')
        ep = AttackerEnvironmentProperties(self.theEnvironment,attackerRoles,attackerMotives,attackerCapabilities)
        p = AttackerParameters(attackerName,'','',[],[ep])
        p.isPersona = True
        self.theAttackerParameters.append(p) 
        attackerNames.append(attackerName)
  
      for tObs in self.theObstacles:
        sgRefs = []
        for resp in tObs.responsibilities():
          sgRefs.append((resp,'role','responsible',0,'None')) 
        ep = ObstacleEnvironmentProperties(self.theEnvironment,'',tObs.definition(),tObs.category(),[],sgRefs,tObs.concerns())
        ep.theProbability = tObs.probability()
        ep.theProbabilityRationale = tObs.probabilityRationale()
        self.theObstacleParameters.append(ObstacleParameters(tObs.name(),self.thePatternName,[],[ep]))

      for obsAssoc in self.theObstacleAssociations:
        obsName = obsAssoc[0]
        refType = obsAssoc[1]
        subObsName = obsAssoc[2]
        assocRationale = obsAssoc[3]  
        self.theObstacleAssociationParameters.append(GoalAssociationParameters(self.theEnvironment,obsName,'obstacle',refType,subObsName,'obstacle',0,assocRationale))
 
      vp = VulnerabilityEnvironmentProperties(self.theEnvironment,self.theSeverity,self.theExploits)
      vulRows = self.dbProxy.getVulnerabilityDirectory(self.theExploit)
      vulData = vulRows[0]
      self.theVulnerabilityParameters = VulnerabilityParameters(self.theExploit,vulData[2],vulData[3],[],[vp])

      spDict = {}
      spDict['confidentiality'] = (0,'None')
      spDict['integrity'] = (0,'None')
      spDict['availability'] = (0,'None')
      spDict['accountability'] = (0,'None')
      spDict['anonymity'] = (0,'None')
      spDict['pseudonymity'] = (0,'None')
      spDict['unlinkability'] = (0,'None')
      spDict['unobservability'] = (0,'None')

      for thrMotivation in self.theMotivations:
        spName = thrMotivation[0]
        spValue = thrMotivation[1]
        spRationale = thrMotivation[2]
        spDict[spName] = (a2i(spValue),spRationale)
      
      cProperty,cRationale = spDict['confidentiality']
      iProperty,iRationale = spDict['integrity']
      avProperty,avRationale = spDict['availability']
      acProperty,acRationale = spDict['accountability']
      anProperty,anRationale = spDict['anonymity']
      panProperty,panRationale = spDict['pseudonymity']
      unlProperty,unlRationale = spDict['unlinkability']
      unoProperty,unoRationale = spDict['unobservability']

      tp = ThreatEnvironmentProperties(self.theEnvironment,self.theLikelihood,self.theTargets,attackerNames,[cProperty,iProperty,avProperty,acProperty,anProperty,panProperty,unlProperty,unoProperty],[cRationale,iRationale,avRationale,acRationale,anRationale,panRationale,unlRationale,unoRationale])
      thrRows = self.dbProxy.getThreatDirectory(self.theAttack)
      thrData = thrRows[0]
      self.theThreatParameters = ThreatParameters(self.theAttack,thrData[3],thrData[2],[],[tp])

      if (self.theAttackObstacle != ''):
        self.theObstacleAssociationParameters.append(GoalAssociationParameters(self.theEnvironment,self.theAttackObstacle,'obstacle','or',self.theAttack,'threat',0,'None'))
      if (self.theExploitObstacle != ''):
        self.theObstacleAssociationParameters.append(GoalAssociationParameters(self.theEnvironment,self.theExploitObstacle,'obstacle','or',self.theExploit,'vulnerability',0,'None'))
      rep = MisuseCaseEnvironmentProperties(self.theEnvironment,self.theImplementation )
      mc = MisuseCase(-1,'Exploit ' + self.thePatternName,[rep],self.thePatternName)
      self.theRiskParameters = RiskParameters(self.thePatternName,self.theAttack,self.theExploit,mc,[],self.theIntent)
Ejemplo n.º 20
0
    def testGoal(self):
        b = Borg()
        igep1d = GoalEnvironmentProperties(
            self.iGoals[0]["theEnvironmentProperties"][0]["theName"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theLabel"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theDefinition"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theCategory"],
            self.iGoals[0]["theEnvironmentProperties"][0]["thePriority"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theFitCriterion"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theIssue"], [], [],
            self.iGoals[0]["theEnvironmentProperties"][0]["theConcerns"], [])
        igep1n = GoalEnvironmentProperties(
            self.iGoals[0]["theEnvironmentProperties"][1]["theName"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theLabel"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theDefinition"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theCategory"],
            self.iGoals[0]["theEnvironmentProperties"][1]["thePriority"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theFitCriterion"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theIssue"], [], [],
            self.iGoals[0]["theEnvironmentProperties"][1]["theConcerns"], [])

        igep2d = GoalEnvironmentProperties(
            self.iGoals[1]["theEnvironmentProperties"][0]["theName"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theLabel"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theDefinition"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theCategory"],
            self.iGoals[1]["theEnvironmentProperties"][0]["thePriority"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theFitCriterion"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theIssue"], [], [],
            self.iGoals[1]["theEnvironmentProperties"][0]["theConcerns"], [])
        igep2n = GoalEnvironmentProperties(
            self.iGoals[1]["theEnvironmentProperties"][1]["theName"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theLabel"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theDefinition"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theCategory"],
            self.iGoals[1]["theEnvironmentProperties"][1]["thePriority"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theFitCriterion"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theIssue"], [], [],
            self.iGoals[1]["theEnvironmentProperties"][1]["theConcerns"], [])

        igep3d = GoalEnvironmentProperties(
            self.iGoals[2]["theEnvironmentProperties"][0]["theName"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theLabel"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theDefinition"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theCategory"],
            self.iGoals[2]["theEnvironmentProperties"][0]["thePriority"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theFitCriterion"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theIssue"], [], [],
            self.iGoals[2]["theEnvironmentProperties"][0]["theConcerns"], [])
        igep3n = GoalEnvironmentProperties(
            self.iGoals[2]["theEnvironmentProperties"][1]["theName"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theLabel"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theDefinition"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theCategory"],
            self.iGoals[2]["theEnvironmentProperties"][1]["thePriority"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theFitCriterion"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theIssue"], [], [],
            self.iGoals[2]["theEnvironmentProperties"][1]["theConcerns"], [])
        igp1 = GoalParameters(self.iGoals[0]["theName"],
                              self.iGoals[0]["theOriginator"], [],
                              [igep1d, igep1n])
        igp2 = GoalParameters(self.iGoals[1]["theName"],
                              self.iGoals[1]["theOriginator"], [],
                              [igep2d, igep2n])
        igp3 = GoalParameters(self.iGoals[2]["theName"],
                              self.iGoals[2]["theOriginator"], [],
                              [igep3d, igep2n])
        b.dbProxy.addGoal(igp1)
        b.dbProxy.addGoal(igp2)
        b.dbProxy.addGoal(igp3)
        b.dbProxy.relabelGoals(igep1d.name())
        oGoals = b.dbProxy.getGoals()
        og1 = oGoals[self.iGoals[0]["theName"]]
        og2 = oGoals[self.iGoals[1]["theName"]]
        og3 = oGoals[self.iGoals[2]["theName"]]
        self.assertEqual(igp1.name(), og1.name())
        self.assertEqual(igp1.originator(), og1.originator())
        ogep1 = og1.environmentProperty(igep1d.name())
        ogep2 = og2.environmentProperty(igep1d.name())
        self.assertEqual(og1.refinements('Day'), False)

        self.assertEqual(igep1d.label(), ogep1.label())
        self.assertEqual(igep1d.definition(), ogep1.definition())
        self.assertEqual(
            igep1d.definition() + ' [Day].  ' + igep1d.definition() +
            ' [Night].  ', og1.definition('', 'Maximise'))
        self.assertEqual(igep1d.category(), ogep1.category())
        self.assertEqual(
            igep1d.category() + ' [Day].  ' + igep1d.category() +
            ' [Night].  ', og1.category('', 'Maximise'))
        self.assertEqual(igep1d.priority(), ogep1.priority())
        self.assertEqual(
            igep1d.priority() + ' [Day].  ' + igep1d.priority() +
            ' [Night].  ', og1.priority('', 'Maximise'))
        self.assertEqual(igep1d.fitCriterion(), ogep1.fitCriterion())
        self.assertEqual(
            igep1d.fitCriterion() + ' [Day].  ' + igep1d.fitCriterion() +
            ' [Night].  ', og1.fitCriterion('', 'Maximise'))
        self.assertEqual(igep1d.issue(), ogep1.issue())
        self.assertEqual(
            igep1d.issue() + ' [Day].  ' + igep1d.issue() + ' [Night].  ',
            og1.issue('', 'Maximise'))
        self.assertEqual(igep1d.goalRefinements(), ogep1.goalRefinements())
        self.assertEqual(igep1d.subGoalRefinements(),
                         ogep1.subGoalRefinements())
        self.assertEqual(igep1d.concerns(), ogep1.concerns())
        self.assertEqual(igep1d.concernAssociations(),
                         ogep1.concernAssociations())

        envName = self.iGoals[0]["theEnvironmentProperties"][0]['theName']
        self.assertEqual(igep1d.label(), og1.label(envName))
        self.assertEqual(igep1d.definition(), og1.definition(envName, ''))
        self.assertEqual(igep1d.category(), og1.category(envName, ''))
        self.assertEqual(igep1d.priority(), og1.priority(envName, ''))
        self.assertEqual(igep1d.fitCriterion(), og1.fitCriterion(envName, ''))
        self.assertEqual(igep1d.issue(), og1.issue(envName, ''))

        self.assertEqual(igep2d.label(), ogep2.label())
        self.assertEqual(igep2d.definition(), ogep2.definition())
        self.assertEqual(igep2d.category(), ogep2.category())
        self.assertEqual(igep2d.priority(), ogep2.priority())
        self.assertEqual(igep2d.fitCriterion(), ogep2.fitCriterion())
        self.assertEqual(igep2d.issue(), ogep2.issue())
        self.assertEqual(igep2d.goalRefinements(), ogep2.goalRefinements())
        self.assertEqual(igep2d.subGoalRefinements(),
                         ogep2.subGoalRefinements())
        self.assertEqual(igep2d.concerns(), ogep2.concerns())
        self.assertEqual(igep2d.concernAssociations(),
                         ogep2.concernAssociations())

        igop1 = GoalAssociationParameters(igep1d.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp2.name(), 'goal', 0, 'None')
        igop2 = GoalAssociationParameters(igep1d.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp3.name(), 'goal', 0, 'None')

        b.dbProxy.addGoalAssociation(igop1)
        b.dbProxy.addGoalAssociation(igop2)

        ogops = b.dbProxy.getGoalAssociations()
        ogop1 = ogops[igep1d.name() + '/' + igp1.name() + '/' + igp2.name() +
                      '/and']
        ogop2 = ogops[igep2d.name() + '/' + igp1.name() + '/' + igp3.name() +
                      '/and']

        self.assertEqual(igop1.environment(), ogop1.environment())
        self.assertEqual(igop1.goal(), ogop1.goal())
        self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
        self.assertEqual(igop1.type(), ogop1.type())
        self.assertEqual(igop1.subGoal(), ogop1.subGoal())
        self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
        self.assertEqual(igop1.alternative(), ogop1.alternative())
        self.assertEqual(igop1.rationale(), ogop1.rationale())

        self.assertEqual(igop2.environment(), ogop2.environment())
        self.assertEqual(igop2.goal(), ogop2.goal())
        self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
        self.assertEqual(igop2.type(), ogop2.type())
        self.assertEqual(igop2.subGoal(), ogop2.subGoal())
        self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
        self.assertEqual(igop2.alternative(), ogop2.alternative())
        self.assertEqual(igop2.rationale(), ogop2.rationale())

        b.dbProxy.deleteGoalAssociation(ogop1.id(), ogop1.goal(),
                                        ogop1.subGoal())
        b.dbProxy.deleteGoalAssociation(ogop2.id(), ogop2.goal(),
                                        ogop2.subGoal())

        b.dbProxy.deleteGoal(og1.id())
        b.dbProxy.deleteGoal(og2.id())
        b.dbProxy.deleteGoal(og3.id())
Ejemplo n.º 21
0
class AssociationsContentHandler(ContentHandler,EntityResolver):
  def __init__(self):
    b = Borg()
    self.dbProxy = b.dbProxy
    self.configDir = b.configDir
    self.theManualAssociations = set([])
    self.theGoalAssociations = []
    self.theDependencyAssociations = []

    self.resetManualAssociationAttributes()
    self.resetGoalAssociationAttributes()
    self.resetDependencyAssociationAttributes()

  def resolveEntity(self,publicId,systemId):
    return self.configDir + '/associations.dtd'

  def manualAssociations(self):
    return self.theManualAssociations

  def goalAssociations(self):
    return self.theGoalAssociations

  def dependencyAssociations(self):
    return self.theDependencyAssociations

  def resetManualAssociationAttributes(self):
    self.theFromName = ''
    self.theFromDim = ''
    self.theToName = ''
    self.theToDim = ''
    self.theReferenceType = ''

  def resetGoalAssociationAttributes(self):
    self.theEnvironmentName = ''
    self.theGoalName = ''
    self.theGoalDim = ''
    self.theReferenceType = ''
    self.theSubGoalName = ''
    self.theSubGoalDim = ''
    self.isAlternative = 0
    self.inRationale = 0
    self.theRationale = ''

  def resetDependencyAssociationAttributes(self):
    self.theDepender = ''
    self.theDependee = ''
    self.theDepType = ''
    self.theDependency = ''
    self.theEnvironmentName = ''
    self.inRationale = 0
    self.theRationale = ''

  def startElement(self,name,attrs):
    self.currentElementName = name
    if name == 'manual_association':
      self.theFromName = attrs['from_name']
      self.theFromDim = attrs['from_dim']
      self.theToName = attrs['to_name']
      self.theToDim = attrs['to_dim']
      if (self.theFromDim == 'requirement') and (self.theToDim == 'task' or self.theToDim == 'usecase'):
        try:
          self.theReferenceType = attrs['ref_type']
        except KeyError:
          self.theReferenceType = 'and'

      if (self.theFromDim == 'requirement') and (self.theToDim == 'requirement'):
        try:
          self.theReferenceType = attrs['label']
        except KeyError:
          self.theReferenceType = ''

    elif name == 'goal_association':
      self.theEnvironmentName = attrs['environment']
      self.theGoalName = attrs['goal_name']
      self.theGoalDim = attrs['goal_dim']
      self.theReferenceType = attrs['ref_type']
      self.theSubGoalName = attrs['subgoal_name']
      self.theSubGoalDim = attrs['subgoal_dim']
      self.isAlternative = attrs['alternative_id']
    elif name == 'dependency':
      self.theDepender = attrs['depender']
      self.theDependee = attrs['dependee']
      self.theDepType = attrs['dependency_type']
      self.theDependency = attrs['dependency']
      self.theEnvironmentName = attrs['environment']
    elif name == 'rationale':
      self.inRationale = 1
      self.theRationale = ''

  def characters(self,data):
    if self.inRationale:
      self.theRationale += data

  def endElement(self,name):
    if name == 'manual_association':
      try:
        fromId = self.dbProxy.getDimensionId(self.theFromName,self.theFromDim)
        toId = self.dbProxy.getDimensionId(self.theToName,self.theToDim)
        tableName = self.theFromDim + '_' + self.theToDim
        if (tableName,fromId,toId,self.theReferenceType) not in self.theManualAssociations:
          self.theManualAssociations.add((tableName,fromId,toId,self.theReferenceType))
      except DatabaseProxyException, e:
        pass # skipping invalid trace
      self.resetManualAssociationAttributes()
    elif name == 'goal_association':
      p = GoalAssociationParameters(self.theEnvironmentName,self.theGoalName,self.theGoalDim,self.theReferenceType,self.theSubGoalName,self.theSubGoalDim,self.isAlternative,self.theRationale)
      self.theGoalAssociations.append(p)
      self.resetGoalAssociationAttributes()
Ejemplo n.º 22
0
 def parentGoal(self,goalName,assocType):
   self.theGoalAssociation = GoalAssociationParameters(self.theEnvironmentName,goalName,'goal',assocType)
Ejemplo n.º 23
0
  def testGoal(self):
    b = Borg()
    igep1 = GoalEnvironmentProperties(self.iGoals[0]["theEnvironmentProperties"][0],self.iGoals[0]["theEnvironmentProperties"][1],self.iGoals[0]["theEnvironmentProperties"][2],self.iGoals[0]["theEnvironmentProperties"][3],self.iGoals[0]["theEnvironmentProperties"][4],self.iGoals[0]["theEnvironmentProperties"][5],self.iGoals[0]["theEnvironmentProperties"][6],[],[],[self.iGoals[0]["theEnvironmentProperties"][7]],[])
    igep2 = GoalEnvironmentProperties(self.iGoals[1]["theEnvironmentProperties"][0],self.iGoals[1]["theEnvironmentProperties"][1],self.iGoals[1]["theEnvironmentProperties"][2],self.iGoals[1]["theEnvironmentProperties"][3],self.iGoals[1]["theEnvironmentProperties"][4],self.iGoals[1]["theEnvironmentProperties"][5],self.iGoals[1]["theEnvironmentProperties"][6],[],[],[self.iGoals[1]["theEnvironmentProperties"][7]],[])
    igep3 = GoalEnvironmentProperties(self.iGoals[2]["theEnvironmentProperties"][0],self.iGoals[2]["theEnvironmentProperties"][1],self.iGoals[2]["theEnvironmentProperties"][2],self.iGoals[2]["theEnvironmentProperties"][3],self.iGoals[2]["theEnvironmentProperties"][4],self.iGoals[2]["theEnvironmentProperties"][5],self.iGoals[2]["theEnvironmentProperties"][6],[],[],[self.iGoals[2]["theEnvironmentProperties"][7]],[])

    igp1 = GoalParameters(self.iGoals[0]["theName"],self.iGoals[0]["theOriginator"],[],[igep1])
    igp2 = GoalParameters(self.iGoals[1]["theName"],self.iGoals[1]["theOriginator"],[],[igep2])
    igp3 = GoalParameters(self.iGoals[2]["theName"],self.iGoals[2]["theOriginator"],[],[igep3])
    b.dbProxy.addGoal(igp1)
    b.dbProxy.addGoal(igp2)
    b.dbProxy.addGoal(igp3)
    b.dbProxy.relabelGoals(igep1.name())
    oGoals = b.dbProxy.getGoals()
    og1 = oGoals[self.iGoals[0]["theName"]]
    og2 = oGoals[self.iGoals[1]["theName"]]
    og3 = oGoals[self.iGoals[2]["theName"]]
    self.assertEqual(igp1.name(), og1.name())
    self.assertEqual(igp1.originator(), og1.originator())
    ogep1 = og1.environmentProperty(igep1.name())
    ogep2 = og2.environmentProperty(igep1.name())

    self.assertEqual(igep1.label(), ogep1.label())
    self.assertEqual(igep1.definition(), ogep1.definition())
    self.assertEqual(igep1.category(), ogep1.category())
    self.assertEqual(igep1.priority(), ogep1.priority())
    self.assertEqual(igep1.fitCriterion(), ogep1.fitCriterion())
    self.assertEqual(igep1.issue(), ogep1.issue())
    self.assertEqual(igep1.goalRefinements(), ogep1.goalRefinements())
    self.assertEqual(igep1.subGoalRefinements(), ogep1.subGoalRefinements())
    self.assertEqual(igep1.concerns(), ogep1.concerns())
    self.assertEqual(igep1.concernAssociations(), ogep1.concernAssociations())

    envName = self.iGoals[0]["theEnvironmentProperties"][0]
    self.assertEqual(igep1.label(), og1.label(envName))
    self.assertEqual(igep1.definition(), og1.definition(envName,''))
    self.assertEqual(igep1.category(), og1.category(envName,''))
    self.assertEqual(igep1.priority(), og1.priority(envName,''))
    self.assertEqual(igep1.fitCriterion(), og1.fitCriterion(envName,''))
    self.assertEqual(igep1.issue(), og1.issue(envName,''))

    self.assertEqual(igep2.label(), ogep2.label())
    self.assertEqual(igep2.definition(), ogep2.definition())
    self.assertEqual(igep2.category(), ogep2.category())
    self.assertEqual(igep2.priority(), ogep2.priority())
    self.assertEqual(igep2.fitCriterion(), ogep2.fitCriterion())
    self.assertEqual(igep2.issue(), ogep2.issue())
    self.assertEqual(igep2.goalRefinements(), ogep2.goalRefinements())
    self.assertEqual(igep2.subGoalRefinements(), ogep2.subGoalRefinements())
    self.assertEqual(igep2.concerns(), ogep2.concerns())
    self.assertEqual(igep2.concernAssociations(), ogep2.concernAssociations())



    igop1 = GoalAssociationParameters(igep1.name(),igp1.name(),'goal','and',igp2.name(),'goal',0,'None')
    igop2 = GoalAssociationParameters(igep1.name(),igp1.name(),'goal','and',igp3.name(),'goal',0,'None')

    b.dbProxy.addGoalAssociation(igop1)
    b.dbProxy.addGoalAssociation(igop2)

    ogops = b.dbProxy.getGoalAssociations()
    ogop1 = ogops[igep1.name() + '/' + igp1.name() + '/' + igp2.name() + '/and']
    ogop2 = ogops[igep2.name() + '/' + igp1.name() + '/' + igp3.name() + '/and']

    self.assertEqual(igop1.environment(), ogop1.environment())
    self.assertEqual(igop1.goal(), ogop1.goal())
    self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
    self.assertEqual(igop1.type(), ogop1.type())
    self.assertEqual(igop1.subGoal(), ogop1.subGoal())
    self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
    self.assertEqual(igop1.alternative(), ogop1.alternative())
    self.assertEqual(igop1.rationale(), ogop1.rationale())

    self.assertEqual(igop2.environment(), ogop2.environment())
    self.assertEqual(igop2.goal(), ogop2.goal())
    self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
    self.assertEqual(igop2.type(), ogop2.type())
    self.assertEqual(igop2.subGoal(), ogop2.subGoal())
    self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
    self.assertEqual(igop2.alternative(), ogop2.alternative())
    self.assertEqual(igop2.rationale(), ogop2.rationale())

    b.dbProxy.deleteGoalAssociation(ogop1.id(),ogop1.goal(),ogop1.subGoal())
    b.dbProxy.deleteGoalAssociation(ogop2.id(),ogop2.goal(),ogop2.subGoal())

    b.dbProxy.deleteGoal(og1.id())
    b.dbProxy.deleteGoal(og2.id())
    b.dbProxy.deleteGoal(og3.id())
Ejemplo n.º 24
0
  def setUp(self):
    call([os.environ['CAIRIS_CFG_DIR'] + "/initdb.sh"])
    cairis.core.BorgFactory.initialise()
    f = open(os.environ['CAIRIS_SRC'] + '/test/countermeasures.json')
    d = json.load(f)
    f.close()
    ienvs = d['environments']
    iep1 = EnvironmentParameters(ienvs[0]["theName"],ienvs[0]["theShortCode"],ienvs[0]["theDescription"])
    b = Borg()
    b.dbProxy.addEnvironment(iep1)
    iRoles = d['roles']
    irp = RoleParameters(iRoles[0]["theName"], iRoles[0]["theType"], iRoles[0]["theShortCode"], iRoles[0]["theDescription"],[])
    b.dbProxy.addRole(irp)
    iPersonas = d['personas']
    ipp = PersonaParameters(iPersonas[0]["theName"],iPersonas[0]["theActivities"],iPersonas[0]["theAttitudes"],iPersonas[0]["theAptitudes"],iPersonas[0]["theMotivations"],iPersonas[0]["theSkills"],iPersonas[0]["theIntrinsic"],iPersonas[0]["theContextual"],"","0",iPersonas[0]["thePersonaType"],[],[PersonaEnvironmentProperties(iPersonas[0]["theEnvironmentProperties"][0]["theName"],(iPersonas[0]["theEnvironmentProperties"][0]["theDirectFlag"] == "True"),iPersonas[0]["theEnvironmentProperties"][0]["theNarrative"],iPersonas[0]["theEnvironmentProperties"][0]["theRole"])],[])
    b.dbProxy.addPersona(ipp)
    iAttackers = d['attackers']
    iatkeps = [AttackerEnvironmentProperties(iAttackers[0]["theEnvironmentProperties"][0]["theName"],iAttackers[0]["theEnvironmentProperties"][0]["theRoles"],iAttackers[0]["theEnvironmentProperties"][0]["theMotives"],iAttackers[0]["theEnvironmentProperties"][0]["theCapabilities"])]
    iatk = AttackerParameters(iAttackers[0]["theName"], iAttackers[0]["theDescription"], iAttackers[0]["theImage"],[],iatkeps)
    b.dbProxy.addAttacker(iatk)
    iVtypes = d['valuetypes']
    ivt1 = ValueTypeParameters(iVtypes[0]["theName"], iVtypes[0]["theDescription"], iVtypes[0]["theType"])
    ivt2 = ValueTypeParameters(iVtypes[1]["theName"], iVtypes[1]["theDescription"], iVtypes[1]["theType"])
    b.dbProxy.addValueType(ivt1)
    b.dbProxy.addValueType(ivt2)
    iassets = d['assets']
    iaeps1 = [AssetEnvironmentProperties(iassets[0]["theEnvironmentProperties"][0][0],iassets[0]["theEnvironmentProperties"][0][1],iassets[0]["theEnvironmentProperties"][0][2])]
    iaeps2 = [AssetEnvironmentProperties(iassets[1]["theEnvironmentProperties"][0][0],iassets[1]["theEnvironmentProperties"][0][1],iassets[1]["theEnvironmentProperties"][0][2])]
    iaeps3 = [AssetEnvironmentProperties(iassets[2]["theEnvironmentProperties"][0][0],iassets[2]["theEnvironmentProperties"][0][1],iassets[2]["theEnvironmentProperties"][0][2])]
    iap1 = AssetParameters(iassets[0]["theName"],iassets[0]["theShortCode"],iassets[0]["theDescription"],iassets[0]["theSignificance"],iassets[0]["theType"],"0","N/A",[],[],iaeps1)
    iap2 = AssetParameters(iassets[1]["theName"],iassets[1]["theShortCode"],iassets[1]["theDescription"],iassets[1]["theSignificance"],iassets[1]["theType"],"0","N/A",[],[],iaeps2)
    iap3 = AssetParameters(iassets[2]["theName"],iassets[2]["theShortCode"],iassets[2]["theDescription"],iassets[2]["theSignificance"],iassets[2]["theType"],"0","N/A",[],[],iaeps3)
    b.dbProxy.addAsset(iap1)
    b.dbProxy.addAsset(iap2)
    b.dbProxy.addAsset(iap3)
    iThreats = d['threats']
    iteps = [ThreatEnvironmentProperties(iThreats[0]["theEnvironmentProperties"][0]["theName"],iThreats[0]["theEnvironmentProperties"][0]["theLikelihood"],iThreats[0]["theEnvironmentProperties"][0]["theAssets"],iThreats[0]["theEnvironmentProperties"][0]["theAttackers"],iThreats[0]["theEnvironmentProperties"][0]["theProperties"][0][1],iThreats[0]["theEnvironmentProperties"][0]["theProperties"][0][1])]
    itps = ThreatParameters(iThreats[0]["theName"],iThreats[0]["theType"],iThreats[0]["theMethod"],[],iteps)
    b.dbProxy.addThreat(itps)
    iVuln = d['vulnerabilities']
    iveps = [VulnerabilityEnvironmentProperties(iVuln[0]["theEnvironmentProperties"][0]["theName"],iVuln[0]["theEnvironmentProperties"][0]["theSeverity"],iVuln[0]["theEnvironmentProperties"][0]["theAssets"])]
    ivp = VulnerabilityParameters(iVuln[0]["theName"],iVuln[0]["theDescription"],iVuln[0]["theType"], [], iveps)
    b.dbProxy.addVulnerability(ivp)
    imc = d['misuseCase']
    iRisks = d['risks']
    imcep = [MisuseCaseEnvironmentProperties(imc[0]["theEnvironmentProperties"][0]["theName"],imc[0]["theEnvironmentProperties"][0]["theDescription"])]
    imcp = MisuseCase(int(0), imc[0]["theName"], imcep,imc[0]["theRisk"])
    irp = RiskParameters(iRisks[0]["theName"],iRisks[0]["threatName"],iRisks[0]["vulName"], imcp,[])
    b.dbProxy.addRisk(irp)
    iResponses = d['responses']
    iar1Name = iResponses[0]["theType"] + " " + iResponses[0]["theRisk"] 
    iaep1 = AcceptEnvironmentProperties(iResponses[0]["theEnvironmentProperties"][0],iResponses[0]["theEnvironmentProperties"][1],iResponses[0]["theEnvironmentProperties"][2])
    iar1 = ResponseParameters(iar1Name,iResponses[0]["theRisk"],[],[iaep1], iResponses[0]["theType"])

    iar2Name = iResponses[1]["theType"] + " " + iResponses[1]["theRisk"] 
    iaep2 = MitigateEnvironmentProperties(iResponses[1]["theEnvironmentProperties"],iResponses[1]["theType"])
    iar2 = ResponseParameters(iar2Name,iResponses[1]["theRisk"],[],[iaep2], iResponses[1]["theType"])

    b.dbProxy.addResponse(iar1)
    b.dbProxy.addResponse(iar2)

    ors = b.dbProxy.getResponses()
    oar1 = ors[iar1Name]
    oar2 = ors[iar2Name]

    rgp = cairis.core.GoalFactory.build(oar2)
    riskParameters = rgp[0]
    riskGoalId = b.dbProxy.addGoal(riskParameters)
    b.dbProxy.addTrace('response_goal',oar2.id(),riskGoalId)
    if (len(rgp) > 1):
      threatParameters = rgp[1]
      vulnerabilityParameters = rgp[2]
      b.dbProxy.addGoal(vulnerabilityParameters)
      b.dbProxy.addGoal(threatParameters)
    b.dbProxy.relabelGoals(iaep2.name())

    oGoals = b.dbProxy.getGoals()
    rg = oGoals['Deter' + oar2.risk()]
    vg = oGoals[vulnerabilityParameters.name()]
    tg = oGoals[threatParameters.name()]

    reqId = b.dbProxy.newId()
    irequirements = d['requirements']
    ireq = cairis.core.RequirementFactory.build(reqId,irequirements[0]["theLabel"],irequirements[0]["theName"],irequirements[0]["theDescription"],irequirements[0]["thePriority"],irequirements[0]["theRationale"],irequirements[0]["theFitCriterion"],irequirements[0]["theOriginator"],irequirements[0]["theType"],irequirements[0]["theReference"],1)
    b.dbProxy.addRequirement(ireq,irequirements[0]["theReference"],True)

    oreqs = b.dbProxy.getRequirements()
    oreq = oreqs[ireq.description()]

    iga = GoalAssociationParameters(iaep2.name(),vg.name(),'goal','and',oreq.name(),'requirement',0,'None')
    b.dbProxy.addGoalAssociation(iga)
    ogops = b.dbProxy.getGoalAssociations()
    self.ogop3 = ogops[iaep2.name() + '/' + vg.name() + '/' + oreq.name() + '/and']
    self.iCountermeasures = d['countermeasures']
Ejemplo n.º 25
0
  def testGoal(self):
    b = Borg()
    igep1d = GoalEnvironmentProperties(self.iGoals[0]["theEnvironmentProperties"][0]["theName"],self.iGoals[0]["theEnvironmentProperties"][0]["theLabel"],self.iGoals[0]["theEnvironmentProperties"][0]["theDefinition"],self.iGoals[0]["theEnvironmentProperties"][0]["theCategory"],self.iGoals[0]["theEnvironmentProperties"][0]["thePriority"],self.iGoals[0]["theEnvironmentProperties"][0]["theFitCriterion"],self.iGoals[0]["theEnvironmentProperties"][0]["theIssue"],[],[],self.iGoals[0]["theEnvironmentProperties"][0]["theConcerns"],[])
    igep1n = GoalEnvironmentProperties(self.iGoals[0]["theEnvironmentProperties"][1]["theName"],self.iGoals[0]["theEnvironmentProperties"][1]["theLabel"],self.iGoals[0]["theEnvironmentProperties"][1]["theDefinition"],self.iGoals[0]["theEnvironmentProperties"][1]["theCategory"],self.iGoals[0]["theEnvironmentProperties"][1]["thePriority"],self.iGoals[0]["theEnvironmentProperties"][1]["theFitCriterion"],self.iGoals[0]["theEnvironmentProperties"][1]["theIssue"],[],[],self.iGoals[0]["theEnvironmentProperties"][1]["theConcerns"],[])

    igep2d = GoalEnvironmentProperties(self.iGoals[1]["theEnvironmentProperties"][0]["theName"],self.iGoals[1]["theEnvironmentProperties"][0]["theLabel"],self.iGoals[1]["theEnvironmentProperties"][0]["theDefinition"],self.iGoals[1]["theEnvironmentProperties"][0]["theCategory"],self.iGoals[1]["theEnvironmentProperties"][0]["thePriority"],self.iGoals[1]["theEnvironmentProperties"][0]["theFitCriterion"],self.iGoals[1]["theEnvironmentProperties"][0]["theIssue"],[],[],self.iGoals[1]["theEnvironmentProperties"][0]["theConcerns"],[])
    igep2n = GoalEnvironmentProperties(self.iGoals[1]["theEnvironmentProperties"][1]["theName"],self.iGoals[1]["theEnvironmentProperties"][1]["theLabel"],self.iGoals[1]["theEnvironmentProperties"][1]["theDefinition"],self.iGoals[1]["theEnvironmentProperties"][1]["theCategory"],self.iGoals[1]["theEnvironmentProperties"][1]["thePriority"],self.iGoals[1]["theEnvironmentProperties"][1]["theFitCriterion"],self.iGoals[1]["theEnvironmentProperties"][1]["theIssue"],[],[],self.iGoals[1]["theEnvironmentProperties"][1]["theConcerns"],[])

    igep3d = GoalEnvironmentProperties(self.iGoals[2]["theEnvironmentProperties"][0]["theName"],self.iGoals[2]["theEnvironmentProperties"][0]["theLabel"],self.iGoals[2]["theEnvironmentProperties"][0]["theDefinition"],self.iGoals[2]["theEnvironmentProperties"][0]["theCategory"],self.iGoals[2]["theEnvironmentProperties"][0]["thePriority"],self.iGoals[2]["theEnvironmentProperties"][0]["theFitCriterion"],self.iGoals[2]["theEnvironmentProperties"][0]["theIssue"],[],[],self.iGoals[2]["theEnvironmentProperties"][0]["theConcerns"],[])
    igep3n = GoalEnvironmentProperties(self.iGoals[2]["theEnvironmentProperties"][1]["theName"],self.iGoals[2]["theEnvironmentProperties"][1]["theLabel"],self.iGoals[2]["theEnvironmentProperties"][1]["theDefinition"],self.iGoals[2]["theEnvironmentProperties"][1]["theCategory"],self.iGoals[2]["theEnvironmentProperties"][1]["thePriority"],self.iGoals[2]["theEnvironmentProperties"][1]["theFitCriterion"],self.iGoals[2]["theEnvironmentProperties"][1]["theIssue"],[],[],self.iGoals[2]["theEnvironmentProperties"][1]["theConcerns"],[])
    igp1 = GoalParameters(self.iGoals[0]["theName"],self.iGoals[0]["theOriginator"],[],[igep1d,igep1n])
    igp2 = GoalParameters(self.iGoals[1]["theName"],self.iGoals[1]["theOriginator"],[],[igep2d,igep2n])
    igp3 = GoalParameters(self.iGoals[2]["theName"],self.iGoals[2]["theOriginator"],[],[igep3d,igep2n])
    b.dbProxy.addGoal(igp1)
    b.dbProxy.addGoal(igp2)
    b.dbProxy.addGoal(igp3)
    b.dbProxy.relabelGoals(igep1d.name())
    oGoals = b.dbProxy.getGoals()
    og1 = oGoals[self.iGoals[0]["theName"]]
    og2 = oGoals[self.iGoals[1]["theName"]]
    og3 = oGoals[self.iGoals[2]["theName"]]
    self.assertEqual(igp1.name(), og1.name())
    self.assertEqual(igp1.originator(), og1.originator())
    ogep1 = og1.environmentProperty(igep1d.name())
    ogep2 = og2.environmentProperty(igep1d.name())
    self.assertEqual(og1.refinements('Day'),False)

    self.assertEqual(igep1d.label(), ogep1.label())
    self.assertEqual(igep1d.definition(), ogep1.definition())
    self.assertEqual(igep1d.definition() + ' [Day].  ' + igep1d.definition() + ' [Night].  ', og1.definition('','Maximise'))
    self.assertEqual(igep1d.category(), ogep1.category())
    self.assertEqual(igep1d.category() + ' [Day].  ' + igep1d.category() + ' [Night].  ', og1.category('','Maximise'))
    self.assertEqual(igep1d.priority(), ogep1.priority())
    self.assertEqual(igep1d.priority() + ' [Day].  ' + igep1d.priority() + ' [Night].  ', og1.priority('','Maximise'))
    self.assertEqual(igep1d.fitCriterion(), ogep1.fitCriterion())
    self.assertEqual(igep1d.fitCriterion() + ' [Day].  ' + igep1d.fitCriterion() + ' [Night].  ', og1.fitCriterion('','Maximise'))
    self.assertEqual(igep1d.issue(), ogep1.issue())
    self.assertEqual(igep1d.issue() + ' [Day].  ' + igep1d.issue() + ' [Night].  ', og1.issue('','Maximise'))
    self.assertEqual(igep1d.goalRefinements(), ogep1.goalRefinements())
    self.assertEqual(igep1d.subGoalRefinements(), ogep1.subGoalRefinements())
    self.assertEqual(igep1d.concerns(), ogep1.concerns())
    self.assertEqual(igep1d.concernAssociations(), ogep1.concernAssociations())

    envName = self.iGoals[0]["theEnvironmentProperties"][0]['theName']
    self.assertEqual(igep1d.label(), og1.label(envName))
    self.assertEqual(igep1d.definition(), og1.definition(envName,''))
    self.assertEqual(igep1d.category(), og1.category(envName,''))
    self.assertEqual(igep1d.priority(), og1.priority(envName,''))
    self.assertEqual(igep1d.fitCriterion(), og1.fitCriterion(envName,''))
    self.assertEqual(igep1d.issue(), og1.issue(envName,''))

    self.assertEqual(igep2d.label(), ogep2.label())
    self.assertEqual(igep2d.definition(), ogep2.definition())
    self.assertEqual(igep2d.category(), ogep2.category())
    self.assertEqual(igep2d.priority(), ogep2.priority())
    self.assertEqual(igep2d.fitCriterion(), ogep2.fitCriterion())
    self.assertEqual(igep2d.issue(), ogep2.issue())
    self.assertEqual(igep2d.goalRefinements(), ogep2.goalRefinements())
    self.assertEqual(igep2d.subGoalRefinements(), ogep2.subGoalRefinements())
    self.assertEqual(igep2d.concerns(), ogep2.concerns())
    self.assertEqual(igep2d.concernAssociations(), ogep2.concernAssociations())



    igop1 = GoalAssociationParameters(igep1d.name(),igp1.name(),'goal','and',igp2.name(),'goal',0,'None')
    igop2 = GoalAssociationParameters(igep1d.name(),igp1.name(),'goal','and',igp3.name(),'goal',0,'None')

    b.dbProxy.addGoalAssociation(igop1)
    b.dbProxy.addGoalAssociation(igop2)

    ogops = b.dbProxy.getGoalAssociations()
    ogop1 = ogops[igep1d.name() + '/' + igp1.name() + '/' + igp2.name() + '/and']
    ogop2 = ogops[igep2d.name() + '/' + igp1.name() + '/' + igp3.name() + '/and']

    self.assertEqual(igop1.environment(), ogop1.environment())
    self.assertEqual(igop1.goal(), ogop1.goal())
    self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
    self.assertEqual(igop1.type(), ogop1.type())
    self.assertEqual(igop1.subGoal(), ogop1.subGoal())
    self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
    self.assertEqual(igop1.alternative(), ogop1.alternative())
    self.assertEqual(igop1.rationale(), ogop1.rationale())

    self.assertEqual(igop2.environment(), ogop2.environment())
    self.assertEqual(igop2.goal(), ogop2.goal())
    self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
    self.assertEqual(igop2.type(), ogop2.type())
    self.assertEqual(igop2.subGoal(), ogop2.subGoal())
    self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
    self.assertEqual(igop2.alternative(), ogop2.alternative())
    self.assertEqual(igop2.rationale(), ogop2.rationale())

    b.dbProxy.deleteGoalAssociation(ogop1.id(),ogop1.goal(),ogop1.subGoal())
    b.dbProxy.deleteGoalAssociation(ogop2.id(),ogop2.goal(),ogop2.subGoal())

    b.dbProxy.deleteGoal(og1.id())
    b.dbProxy.deleteGoal(og2.id())
    b.dbProxy.deleteGoal(og3.id())
Ejemplo n.º 26
0
    def setUp(self):
        call([os.environ['CAIRIS_SRC'] + "/test/initdb.sh"])
        cairis.core.BorgFactory.initialise()
        f = open(os.environ['CAIRIS_SRC'] + '/test/countermeasures.json')
        d = json.load(f)
        f.close()
        self.ienvs = d['environments']
        self.iep1 = EnvironmentParameters(self.ienvs[0]["theName"],
                                          self.ienvs[0]["theShortCode"],
                                          self.ienvs[0]["theDescription"])
        b = Borg()
        b.dbProxy.addEnvironment(self.iep1)
        self.oenvs = b.dbProxy.getEnvironments()
        self.iRoles = d['roles']
        self.irp = RoleParameters(self.iRoles[0]["theName"],
                                  self.iRoles[0]["theType"],
                                  self.iRoles[0]["theShortCode"],
                                  self.iRoles[0]["theDescription"], [])
        b.dbProxy.addRole(self.irp)
        self.oRoles = b.dbProxy.getRoles()
        self.iPersonas = d['personas']
        self.ipp = PersonaParameters(
            self.iPersonas[0]["theName"], self.iPersonas[0]["theActivities"],
            self.iPersonas[0]["theAttitudes"],
            self.iPersonas[0]["theAptitudes"],
            self.iPersonas[0]["theMotivations"],
            self.iPersonas[0]["theSkills"], self.iPersonas[0]["theIntrinsic"],
            self.iPersonas[0]["theContextual"], "", "0",
            self.iPersonas[0]["thePersonaType"], [], [
                PersonaEnvironmentProperties(
                    self.iPersonas[0]["theEnvironmentProperties"][0]
                    ["theName"], (self.iPersonas[0]["theEnvironmentProperties"]
                                  [0]["theDirectFlag"] == "True"),
                    self.iPersonas[0]["theEnvironmentProperties"][0]
                    ["theNarrative"], self.iPersonas[0]
                    ["theEnvironmentProperties"][0]["theRole"])
            ], [])
        b.dbProxy.addPersona(self.ipp)
        self.opp = b.dbProxy.getPersonas()
        self.iExternalDocuments = d['external_documents']
        self.iec1 = ExternalDocumentParameters(
            self.iExternalDocuments[0]["theName"],
            self.iExternalDocuments[0]["theVersion"],
            self.iExternalDocuments[0]["thePublicationDate"],
            self.iExternalDocuments[0]["theAuthors"],
            self.iExternalDocuments[0]["theDescription"])
        self.iec2 = ExternalDocumentParameters(
            self.iExternalDocuments[1]["theName"],
            self.iExternalDocuments[1]["theVersion"],
            self.iExternalDocuments[1]["thePublicationDate"],
            self.iExternalDocuments[1]["theAuthors"],
            self.iExternalDocuments[1]["theDescription"])
        b.dbProxy.addExternalDocument(self.iec1)
        b.dbProxy.addExternalDocument(self.iec2)
        self.oecs = b.dbProxy.getExternalDocuments()
        self.iDocumentReferences = d['document_references']
        self.idr1 = DocumentReferenceParameters(
            self.iDocumentReferences[0]["theName"],
            self.iDocumentReferences[0]["theDocName"],
            self.iDocumentReferences[0]["theContributor"],
            self.iDocumentReferences[0]["theExcerpt"])
        self.idr2 = DocumentReferenceParameters(
            self.iDocumentReferences[1]["theName"],
            self.iDocumentReferences[1]["theDocName"],
            self.iDocumentReferences[1]["theContributor"],
            self.iDocumentReferences[1]["theExcerpt"])
        b.dbProxy.addDocumentReference(self.idr1)
        b.dbProxy.addDocumentReference(self.idr2)
        self.odrs = b.dbProxy.getDocumentReferences()
        self.iPersonaCharacteristics = d['persona_characteristics']
        self.ipc1 = PersonaCharacteristicParameters(
            self.iPersonaCharacteristics[0]["thePersonaName"],
            self.iPersonaCharacteristics[0]["theModQual"],
            self.iPersonaCharacteristics[0]["theVariable"],
            self.iPersonaCharacteristics[0]["theCharacteristic"],
            [(self.iPersonaCharacteristics[0]["ground"], '', 'document')],
            [(self.iPersonaCharacteristics[0]["warrant"], '', 'document')], [],
            [])
        b.dbProxy.addPersonaCharacteristic(self.ipc1)
        self.opcs = b.dbProxy.getPersonaCharacteristics()
        self.iAttackers = d['attackers']
        self.iatkeps = [
            AttackerEnvironmentProperties(
                self.iAttackers[0]["theEnvironmentProperties"][0]["theName"],
                self.iAttackers[0]["theEnvironmentProperties"][0]["theRoles"],
                self.iAttackers[0]["theEnvironmentProperties"][0]
                ["theMotives"], self.iAttackers[0]["theEnvironmentProperties"]
                [0]["theCapabilities"])
        ]
        self.iatk = AttackerParameters(self.iAttackers[0]["theName"],
                                       self.iAttackers[0]["theDescription"],
                                       self.iAttackers[0]["theImage"], [],
                                       self.iatkeps)
        b.dbProxy.addAttacker(self.iatk)
        self.oAttackers = b.dbProxy.getAttackers()
        self.iVtypes = d['valuetypes']
        self.ivt1 = ValueTypeParameters(self.iVtypes[0]["theName"],
                                        self.iVtypes[0]["theDescription"],
                                        self.iVtypes[0]["theType"])
        self.ivt2 = ValueTypeParameters(self.iVtypes[1]["theName"],
                                        self.iVtypes[1]["theDescription"],
                                        self.iVtypes[1]["theType"])
        b.dbProxy.addValueType(self.ivt1)
        b.dbProxy.addValueType(self.ivt2)
        self.ovtt = b.dbProxy.getValueTypes('threat_type')
        self.ovtv = b.dbProxy.getValueTypes('vulnerability_type')
        self.iassets = d['assets']
        self.iaeps1 = [
            AssetEnvironmentProperties(
                self.iassets[0]["theEnvironmentProperties"][0][0],
                self.iassets[0]["theEnvironmentProperties"][0][1],
                self.iassets[0]["theEnvironmentProperties"][0][2])
        ]
        self.iaeps2 = [
            AssetEnvironmentProperties(
                self.iassets[1]["theEnvironmentProperties"][0][0],
                self.iassets[1]["theEnvironmentProperties"][0][1],
                self.iassets[1]["theEnvironmentProperties"][0][2])
        ]
        self.iaeps3 = [
            AssetEnvironmentProperties(
                self.iassets[2]["theEnvironmentProperties"][0][0],
                self.iassets[2]["theEnvironmentProperties"][0][1],
                self.iassets[2]["theEnvironmentProperties"][0][2])
        ]
        self.iap1 = AssetParameters(self.iassets[0]["theName"],
                                    self.iassets[0]["theShortCode"],
                                    self.iassets[0]["theDescription"],
                                    self.iassets[0]["theSignificance"],
                                    self.iassets[0]["theType"], "0", "N/A", [],
                                    [], self.iaeps1)
        self.iap2 = AssetParameters(self.iassets[1]["theName"],
                                    self.iassets[1]["theShortCode"],
                                    self.iassets[1]["theDescription"],
                                    self.iassets[1]["theSignificance"],
                                    self.iassets[1]["theType"], "0", "N/A", [],
                                    [], self.iaeps2)
        self.iap3 = AssetParameters(self.iassets[2]["theName"],
                                    self.iassets[2]["theShortCode"],
                                    self.iassets[2]["theDescription"],
                                    self.iassets[2]["theSignificance"],
                                    self.iassets[2]["theType"], "0", "N/A", [],
                                    [], self.iaeps3)
        b.dbProxy.addAsset(self.iap1)
        b.dbProxy.addAsset(self.iap2)
        b.dbProxy.addAsset(self.iap3)
        self.oap = b.dbProxy.getAssets()
        self.iThreats = d['threats']
        self.iteps = [
            ThreatEnvironmentProperties(
                self.iThreats[0]["theEnvironmentProperties"][0]["theName"],
                self.iThreats[0]["theEnvironmentProperties"][0]
                ["theLikelihood"],
                self.iThreats[0]["theEnvironmentProperties"][0]["theAssets"],
                self.iThreats[0]["theEnvironmentProperties"][0]
                ["theAttackers"], self.iThreats[0]["theEnvironmentProperties"]
                [0]["theProperties"][0][1], self.iThreats[0]
                ["theEnvironmentProperties"][0]["theProperties"][0][1])
        ]
        self.itps = ThreatParameters(self.iThreats[0]["theName"],
                                     self.iThreats[0]["theType"],
                                     self.iThreats[0]["theMethod"], [],
                                     self.iteps)
        b.dbProxy.addThreat(self.itps)
        self.otps = b.dbProxy.getThreats()
        self.iVuln = d['vulnerabilities']
        self.iveps = [
            VulnerabilityEnvironmentProperties(
                self.iVuln[0]["theEnvironmentProperties"][0]["theName"],
                self.iVuln[0]["theEnvironmentProperties"][0]["theSeverity"],
                self.iVuln[0]["theEnvironmentProperties"][0]["theAssets"])
        ]
        self.ivp = VulnerabilityParameters(self.iVuln[0]["theName"],
                                           self.iVuln[0]["theDescription"],
                                           self.iVuln[0]["theType"], [],
                                           self.iveps)
        b.dbProxy.addVulnerability(self.ivp)
        self.ovp = b.dbProxy.getVulnerabilities()
        self.imc = d['misuseCase']
        self.iRisks = d['risks']

        imcep = [
            MisuseCaseEnvironmentProperties(
                self.imc[0]["theEnvironmentProperties"][0]["theName"],
                self.imc[0]["theEnvironmentProperties"][0]["theDescription"])
        ]
        imcp = MisuseCase(int(0), self.imc[0]["theName"], imcep,
                          self.imc[0]["theRisk"])
        irp = RiskParameters(self.iRisks[0]["theName"],
                             self.iRisks[0]["threatName"],
                             self.iRisks[0]["vulName"], imcp, [])
        b.dbProxy.addRisk(irp)
        oRisks = b.dbProxy.getRisks()
        self.r = oRisks[self.iRisks[0]["theName"]]
        self.iResponses = d['responses']
        iar1Name = self.iResponses[0]["theType"] + " " + self.iResponses[0][
            "theRisk"]
        iaep1 = AcceptEnvironmentProperties(
            self.iResponses[0]["theEnvironmentProperties"][0],
            self.iResponses[0]["theEnvironmentProperties"][1],
            self.iResponses[0]["theEnvironmentProperties"][2])
        iar1 = ResponseParameters(iar1Name, self.iResponses[0]["theRisk"], [],
                                  [iaep1], self.iResponses[0]["theType"])

        iar2Name = self.iResponses[1]["theType"] + " " + self.iResponses[1][
            "theRisk"]
        iaep2 = MitigateEnvironmentProperties(
            self.iResponses[1]["theEnvironmentProperties"],
            self.iResponses[1]["theType"])
        iar2 = ResponseParameters(iar2Name, self.iResponses[1]["theRisk"], [],
                                  [iaep2], self.iResponses[1]["theType"])

        b.dbProxy.addResponse(iar1)
        b.dbProxy.addResponse(iar2)

        self.ors = b.dbProxy.getResponses()
        self.oar1 = self.ors[iar1Name]
        self.oar2 = self.ors[iar2Name]

        rgp = cairis.core.GoalFactory.build(self.oar2)
        riskParameters = rgp[0]
        riskGoalId = b.dbProxy.addGoal(riskParameters)
        b.dbProxy.addTrace('response_goal', self.oar2.id(), riskGoalId)
        if (rgp > 1):
            threatParameters = rgp[1]
            vulnerabilityParameters = rgp[2]
            b.dbProxy.addGoal(vulnerabilityParameters)
            b.dbProxy.addGoal(threatParameters)
        b.dbProxy.relabelGoals(iaep2.name())

        oGoals = b.dbProxy.getGoals()
        self.rg = oGoals['Deter' + self.oar2.risk()]
        self.vg = oGoals[vulnerabilityParameters.name()]
        self.tg = oGoals[threatParameters.name()]

        ogops = b.dbProxy.getGoalAssociations()
        self.ogop1 = ogops[iaep2.name() + '/' + riskParameters.name() + '/' +
                           threatParameters.name() + '/or']
        self.ogop2 = ogops[iaep2.name() + '/' + riskParameters.name() + '/' +
                           vulnerabilityParameters.name() + '/or']

        self.reqId = b.dbProxy.newId()
        self.irequirements = d['requirements']
        self.ireq = cairis.core.RequirementFactory.build(
            self.reqId, self.irequirements[0]["theLabel"],
            self.irequirements[0]["theName"],
            self.irequirements[0]["theDescription"],
            self.irequirements[0]["thePriority"],
            self.irequirements[0]["theRationale"],
            self.irequirements[0]["theFitCriterion"],
            self.irequirements[0]["theOriginator"],
            self.irequirements[0]["theType"],
            self.irequirements[0]["theReference"], 1)
        b.dbProxy.addRequirement(self.ireq,
                                 self.irequirements[0]["theReference"], True)
        oreqs = b.dbProxy.getRequirements()
        self.oreq = oreqs[self.ireq.description()]

        iga = GoalAssociationParameters(iaep2.name(),
                                        self.vg.name(), 'goal', 'and',
                                        self.oreq.name(), 'requirement', 0,
                                        'None')
        b.dbProxy.addGoalAssociation(iga)
        ogops = b.dbProxy.getGoalAssociations()
        self.ogop3 = ogops[iaep2.name() + '/' + self.vg.name() + '/' +
                           self.oreq.name() + '/and']

        self.iCountermeasures = d['countermeasures']
Ejemplo n.º 27
0
    def testGoal(self):
        b = Borg()
        igep1 = GoalEnvironmentProperties(
            self.iGoals[0]["theEnvironmentProperties"][0],
            self.iGoals[0]["theEnvironmentProperties"][1],
            self.iGoals[0]["theEnvironmentProperties"][2],
            self.iGoals[0]["theEnvironmentProperties"][3],
            self.iGoals[0]["theEnvironmentProperties"][4],
            self.iGoals[0]["theEnvironmentProperties"][5],
            self.iGoals[0]["theEnvironmentProperties"][6], [], [],
            [self.iGoals[0]["theEnvironmentProperties"][7]], [])
        igep2 = GoalEnvironmentProperties(
            self.iGoals[1]["theEnvironmentProperties"][0],
            self.iGoals[1]["theEnvironmentProperties"][1],
            self.iGoals[1]["theEnvironmentProperties"][2],
            self.iGoals[1]["theEnvironmentProperties"][3],
            self.iGoals[1]["theEnvironmentProperties"][4],
            self.iGoals[1]["theEnvironmentProperties"][5],
            self.iGoals[1]["theEnvironmentProperties"][6], [], [],
            [self.iGoals[1]["theEnvironmentProperties"][7]], [])
        igep3 = GoalEnvironmentProperties(
            self.iGoals[2]["theEnvironmentProperties"][0],
            self.iGoals[2]["theEnvironmentProperties"][1],
            self.iGoals[2]["theEnvironmentProperties"][2],
            self.iGoals[2]["theEnvironmentProperties"][3],
            self.iGoals[2]["theEnvironmentProperties"][4],
            self.iGoals[2]["theEnvironmentProperties"][5],
            self.iGoals[2]["theEnvironmentProperties"][6], [], [],
            [self.iGoals[2]["theEnvironmentProperties"][7]], [])

        igp1 = GoalParameters(self.iGoals[0]["theName"],
                              self.iGoals[0]["theOriginator"], [], [igep1])
        igp2 = GoalParameters(self.iGoals[1]["theName"],
                              self.iGoals[1]["theOriginator"], [], [igep2])
        igp3 = GoalParameters(self.iGoals[2]["theName"],
                              self.iGoals[2]["theOriginator"], [], [igep3])
        b.dbProxy.addGoal(igp1)
        b.dbProxy.addGoal(igp2)
        b.dbProxy.addGoal(igp3)
        b.dbProxy.relabelGoals(igep1.name())
        oGoals = b.dbProxy.getGoals()
        og1 = oGoals[self.iGoals[0]["theName"]]
        og2 = oGoals[self.iGoals[1]["theName"]]
        og3 = oGoals[self.iGoals[2]["theName"]]
        self.assertEqual(igp1.name(), og1.name())
        self.assertEqual(igp1.originator(), og1.originator())
        ogep1 = og1.environmentProperty(igep1.name())
        ogep2 = og2.environmentProperty(igep1.name())

        self.assertEqual(igep1.label(), ogep1.label())
        self.assertEqual(igep1.definition(), ogep1.definition())
        self.assertEqual(igep1.category(), ogep1.category())
        self.assertEqual(igep1.priority(), ogep1.priority())
        self.assertEqual(igep1.fitCriterion(), ogep1.fitCriterion())
        self.assertEqual(igep1.issue(), ogep1.issue())
        self.assertEqual(igep1.goalRefinements(), ogep1.goalRefinements())
        self.assertEqual(igep1.subGoalRefinements(),
                         ogep1.subGoalRefinements())
        self.assertEqual(igep1.concerns(), ogep1.concerns())
        self.assertEqual(igep1.concernAssociations(),
                         ogep1.concernAssociations())

        envName = self.iGoals[0]["theEnvironmentProperties"][0]
        self.assertEqual(igep1.label(), og1.label(envName))
        self.assertEqual(igep1.definition(), og1.definition(envName, ''))
        self.assertEqual(igep1.category(), og1.category(envName, ''))
        self.assertEqual(igep1.priority(), og1.priority(envName, ''))
        self.assertEqual(igep1.fitCriterion(), og1.fitCriterion(envName, ''))
        self.assertEqual(igep1.issue(), og1.issue(envName, ''))

        self.assertEqual(igep2.label(), ogep2.label())
        self.assertEqual(igep2.definition(), ogep2.definition())
        self.assertEqual(igep2.category(), ogep2.category())
        self.assertEqual(igep2.priority(), ogep2.priority())
        self.assertEqual(igep2.fitCriterion(), ogep2.fitCriterion())
        self.assertEqual(igep2.issue(), ogep2.issue())
        self.assertEqual(igep2.goalRefinements(), ogep2.goalRefinements())
        self.assertEqual(igep2.subGoalRefinements(),
                         ogep2.subGoalRefinements())
        self.assertEqual(igep2.concerns(), ogep2.concerns())
        self.assertEqual(igep2.concernAssociations(),
                         ogep2.concernAssociations())

        igop1 = GoalAssociationParameters(igep1.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp2.name(), 'goal', 0, 'None')
        igop2 = GoalAssociationParameters(igep1.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp3.name(), 'goal', 0, 'None')

        b.dbProxy.addGoalAssociation(igop1)
        b.dbProxy.addGoalAssociation(igop2)

        ogops = b.dbProxy.getGoalAssociations()
        ogop1 = ogops[igep1.name() + '/' + igp1.name() + '/' + igp2.name() +
                      '/and']
        ogop2 = ogops[igep2.name() + '/' + igp1.name() + '/' + igp3.name() +
                      '/and']

        self.assertEqual(igop1.environment(), ogop1.environment())
        self.assertEqual(igop1.goal(), ogop1.goal())
        self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
        self.assertEqual(igop1.type(), ogop1.type())
        self.assertEqual(igop1.subGoal(), ogop1.subGoal())
        self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
        self.assertEqual(igop1.alternative(), ogop1.alternative())
        self.assertEqual(igop1.rationale(), ogop1.rationale())

        self.assertEqual(igop2.environment(), ogop2.environment())
        self.assertEqual(igop2.goal(), ogop2.goal())
        self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
        self.assertEqual(igop2.type(), ogop2.type())
        self.assertEqual(igop2.subGoal(), ogop2.subGoal())
        self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
        self.assertEqual(igop2.alternative(), ogop2.alternative())
        self.assertEqual(igop2.rationale(), ogop2.rationale())

        b.dbProxy.deleteGoalAssociation(ogop1.id(), ogop1.goal(),
                                        ogop1.subGoal())
        b.dbProxy.deleteGoalAssociation(ogop2.id(), ogop2.goal(),
                                        ogop2.subGoal())

        b.dbProxy.deleteGoal(og1.id())
        b.dbProxy.deleteGoal(og2.id())
        b.dbProxy.deleteGoal(og3.id())