Example #1
0
    def prepare_new_obstacle(self):
        new_goal_refinements = []
        new_subgoal_refinements = []
        new_obs_props = [
            ObstacleEnvironmentProperties(
                environmentName=self.existing_environment_name_1,
                lbl='New Obstacle',
                definition='This is a test definition for env1',
                category='Integrity Threat',
                gRefs=new_goal_refinements,
                sgRefs=new_subgoal_refinements,
                concs=[]),
            ObstacleEnvironmentProperties(
                environmentName=self.existing_environment_name_2,
                lbl='New Obstacle',
                category='Integrity Threat',
                definition='This is a test definition for env2',
                gRefs=new_goal_refinements,
                sgRefs=new_subgoal_refinements,
                concs=[])
        ]

        new_obstacle = Obstacle(obsId=-1,
                                obsName='Test obstacle',
                                obsOrig='test case',
                                tags=['test', 'test123'],
                                environmentProperties=new_obs_props)
        return new_obstacle
Example #2
0
    def convert_properties(self, real_props=None, fake_props=None):
        new_props = []
        if real_props is not None:
            for real_prop in real_props:
                assert isinstance(real_prop, ObstacleEnvironmentProperties)
                del real_prop.theLabel

                new_goal_refinements = []
                for gr in real_prop.theGoalRefinements:
                    new_goal_refinements.append(
                        RefinementModel(gr[0], gr[1], gr[2], gr[3], gr[4]))

                new_subgoal_refinements = []
                for sgr in real_prop.theSubGoalRefinements:
                    new_subgoal_refinements.append(
                        RefinementModel(sgr[0], sgr[1], sgr[2], sgr[3],
                                        sgr[4]))

                real_prop.theGoalRefinements = new_goal_refinements
                real_prop.theSubGoalRefinements = new_subgoal_refinements
                new_props.append(real_prop)
        elif fake_props is not None:
            for fake_prop in fake_props:
                check_required_keys(
                    fake_prop, ObstacleEnvironmentPropertiesModel.required)

                new_goal_refinements = []
                for gr in fake_prop['theGoalRefinements']:
                    new_goal_refinements.append(
                        (gr['theEndName'], gr['theEndType'], gr['theRefType'],
                         gr['isAlternate'], gr['theRationale']))

                new_subgoal_refinements = []
                for sgr in fake_prop['theSubGoalRefinements']:
                    new_subgoal_refinements.append(
                        (sgr['theEndName'], sgr['theEndType'],
                         sgr['theRefType'], sgr['isAlternate'],
                         sgr['theRationale']))

                new_prop = ObstacleEnvironmentProperties(
                    environmentName=fake_prop['theEnvironmentName'],
                    lbl='',
                    definition=fake_prop['theDefinition'],
                    category=fake_prop['theCategory'],
                    gRefs=new_goal_refinements,
                    sgRefs=new_subgoal_refinements,
                    concs=fake_prop['theConcerns'])
                new_prop.theProbability = fake_prop['theProbability']
                new_prop.theProbabilityRationale = fake_prop[
                    'theProbabilityRationale']
                new_props.append(new_prop)
        else:
            self.close()
            raise MissingParameterHTTPError(
                param_names=['real_props', 'fake_props'])

        return new_props
Example #3
0
 def prepare_new_obstacle(self):
     return Obstacle(-1, 'Test obstacle', 'test case', [
         'test', 'test123'
     ], [
         ObstacleEnvironmentProperties('Psychosis', 'New Obstacle',
                                       'This a test definition for env1',
                                       'Integrity Threat', [], [], []),
         ObstacleEnvironmentProperties(
             'Stroke', 'New Obstacle', 'This is a test definition for env2',
             'Integrity Threat', [], [], [])
     ])
Example #4
0
 def OnEnvironmentDeselected(self, evt):
     self.theSelectedIdx = evt.GetIndex()
     environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
     self.theEnvironmentDictionary[
         environmentName] = ObstacleEnvironmentProperties(
             environmentName, self.labelCtrl.GetValue(),
             self.definitionCtrl.GetValue(), self.categoryCtrl.GetValue(),
             self.goalAssociationCtrl.dimensions(),
             self.subGoalAssociationCtrl.dimensions(),
             self.concernsCtrl.dimensions())
     self.labelCtrl.SetValue('')
     self.probCtrl.SetValue('')
     self.categoryCtrl.SetValue('')
     self.definitionCtrl.SetValue('')
     self.goalAssociationCtrl.DeleteAllItems()
     self.goalAssociationCtrl.setEnvironment('')
     self.subGoalAssociationCtrl.DeleteAllItems()
     self.concernsCtrl.DeleteAllItems()
     self.subGoalAssociationCtrl.setEnvironment('')
     self.concernsCtrl.setEnvironment('')
     self.theSelectedIdx = -1
     self.categoryCtrl.Disable()
     self.definitionCtrl.Disable()
     self.goalAssociationCtrl.Disable()
     self.subGoalAssociationCtrl.Disable()
     self.concernsCtrl.Disable()
Example #5
0
 def environmentProperties(self):
     obsCat = self.decorator.getComboValue("obstacleCategoryCtrl")
     obsDef = self.decorator.getMLText("obstacleDefinitionCtrl")
     envProperties = ObstacleEnvironmentProperties(
         self.theEnvironmentName, '', obsDef, obsCat,
         self.obstacleAssociations, self.subObstacleAssociations)
     return envProperties
Example #6
0
  def convert_properties(self, real_props=None, fake_props=None):
    new_props = []
    if real_props is not None:
      for real_prop in real_props:
        assert isinstance(real_prop, ObstacleEnvironmentProperties)
        del real_prop.theLabel

        new_goal_refinements = []
        for gr in real_prop.theGoalRefinements:
          new_goal_refinements.append(RefinementModel(gr[0],gr[1],gr[2],gr[3],gr[4]))

        new_subgoal_refinements = []
        for sgr in real_prop.theSubGoalRefinements:
          new_subgoal_refinements.append(RefinementModel(sgr[0],sgr[1],sgr[2],sgr[3],sgr[4]))

        real_prop.theGoalRefinements = new_goal_refinements
        real_prop.theSubGoalRefinements = new_subgoal_refinements
        new_props.append(real_prop)
    elif fake_props is not None:
      for fake_prop in fake_props:
        check_required_keys(fake_prop, ObstacleEnvironmentPropertiesModel.required)

        new_goal_refinements = []
        for gr in fake_prop['theGoalRefinements']:
          new_goal_refinements.append((gr['theEndName'],gr['theEndType'],gr['theRefType'],gr['isAlternate'],gr['theRationale']))

        new_subgoal_refinements = []
        for sgr in fake_prop['theSubGoalRefinements']:
          new_subgoal_refinements.append((sgr['theEndName'],sgr['theEndType'],sgr['theRefType'],sgr['isAlternate'],sgr['theRationale']))

        new_prop = ObstacleEnvironmentProperties(
                   environmentName=fake_prop['theEnvironmentName'],
                   lbl='',
                   definition=fake_prop['theDefinition'],
                   category=fake_prop['theCategory'],
                   gRefs=new_goal_refinements,
                   sgRefs=new_subgoal_refinements,
                   concs=fake_prop['theConcerns'])
        new_prop.theProbability = fake_prop['theProbability']
        new_prop.theProbabilityRationale = fake_prop['theProbabilityRationale']
        new_props.append(new_prop)
    else:
      self.close()
      raise MissingParameterHTTPError(param_names=['real_props', 'fake_props'])

    return new_props
Example #7
0
 def inheritedObstacleProperties(self, obsId, environmentName):
     environmentId = self.getDimensionId(environmentName, 'environment')
     obsDef = self.obstacleDefinition(obsId, environmentId)
     obsType = self.obstacleCategory(obsId, environmentId)
     goalRefinements, subGoalRefinements = self.goalRefinements(
         obsId, environmentId)
     return ObstacleEnvironmentProperties(environmentName, '', obsDef,
                                          obsType, goalRefinements,
                                          subGoalRefinements)
Example #8
0
  def testObstacle(self):
    b = Borg()
    igep1 = ObstacleEnvironmentProperties(self.iObstacle[0]["theEnvironmentProperties"][0],self.iObstacle[0]["theEnvironmentProperties"][1],self.iObstacle[0]["theEnvironmentProperties"][2],self.iObstacle[0]["theEnvironmentProperties"][3])
   

    igp1 = ObstacleParameters(self.iObstacle[0]["theName"],self.iObstacle[0]["theOriginator"],[],[igep1])
   
    b.dbProxy.addObstacle(igp1)
  
    b.dbProxy.relabelObstacles(igep1.name())
    oObstacle = b.dbProxy.getObstacles()
    og1 = oObstacle[self.iObstacle[0]["theName"]]
    self.assertEqual(igp1.name(), og1.name())
    self.assertEqual(igp1.originator(), og1.originator())
    ogep1 = og1.environmentProperty(igep1.name())
    
    self.assertEqual(igep1.definition(), ogep1.definition())
    self.assertEqual(igep1.category(), ogep1.category())

    b.dbProxy.deleteObstacle(og1.id())
Example #9
0
def build(envName,excDetails):

  obsName = excDetails[0]
  excDim = excDetails[1]
  excVal = excDetails[2]
  excDef = excDetails[4]
  excCat = excDetails[3]
  sgRef = [(excVal,excDim,'obstruct','No','use case exception')]
  envProperties = [ObstacleEnvironmentProperties(envName,'',excDef,excCat,sgRef,[])]
  parameters = ObstacleParameters(obsName,[],envProperties)
  return parameters 
Example #10
0
    def testObstacle(self):
        b = Borg()
        igep1 = ObstacleEnvironmentProperties(
            self.iObstacle[0]["theEnvironmentProperties"][0],
            self.iObstacle[0]["theEnvironmentProperties"][1],
            self.iObstacle[0]["theEnvironmentProperties"][2],
            self.iObstacle[0]["theEnvironmentProperties"][3])

        igp1 = ObstacleParameters(self.iObstacle[0]["theName"],
                                  self.iObstacle[0]["theOriginator"], [],
                                  [igep1])

        b.dbProxy.addObstacle(igp1)

        b.dbProxy.relabelObstacles(igep1.name())
        oObstacle = b.dbProxy.getObstacles()
        og1 = oObstacle[self.iObstacle[0]["theName"]]
        self.assertEqual(igp1.name(), og1.name())
        self.assertEqual(igp1.originator(), og1.originator())
        ogep1 = og1.environmentProperty(igep1.name())
        self.assertEqual(igep1.definition(), ogep1.definition())
        self.assertEqual(igep1.category(), ogep1.category())

        igp1.setId(og1.id())
        b.dbProxy.updateObstacle(igp1)

        b.dbProxy.deleteObstacle(og1.id())
Example #11
0
 def environmentProperties(self):
     if (self.theSelectedIdx != -1):
         environmentName = self.environmentList.GetItemText(
             self.theSelectedIdx)
         self.theEnvironmentDictionary[
             environmentName] = ObstacleEnvironmentProperties(
                 environmentName, self.labelCtrl.GetValue(),
                 self.definitionCtrl.GetValue(),
                 self.categoryCtrl.GetValue(),
                 self.goalAssociationCtrl.dimensions(),
                 self.subGoalAssociationCtrl.dimensions(),
                 self.concernsCtrl.dimensions())
     return self.theEnvironmentDictionary.values()
Example #12
0
    def convert_properties(self, real_props=None, fake_props=None):
        new_props = []
        if real_props is not None:
            for real_prop in real_props:
                assert isinstance(real_prop, ObstacleEnvironmentProperties)

                new_goal_refinements = []
                for goal_refinement in real_prop.theGoalRefinements:
                    new_goal_refinements.append(list(goal_refinement))

                new_subgoal_refinements = []
                for subgoal_refinement in real_prop.theSubGoalRefinements:
                    new_subgoal_refinements.append(list(subgoal_refinement))

                real_prop.theGoalRefinements = new_goal_refinements
                real_prop.theSubGoalRefinements = new_subgoal_refinements
                new_props.append(real_prop)
        elif fake_props is not None:
            for fake_prop in fake_props:
                check_required_keys(
                    fake_prop, ObstacleEnvironmentPropertiesModel.required)

                new_goal_refinements = []
                for goal_refinement in fake_prop['theGoalRefinements']:
                    new_goal_refinements.append(tuple(goal_refinement))

                new_subgoal_refinements = []
                for subgoal_refinement in fake_prop['theSubGoalRefinements']:
                    new_subgoal_refinements.append(tuple(subgoal_refinement))

                    new_prop = ObstacleEnvironmentProperties(
                        environmentName=fake_prop['theEnvironmentName'],
                        lbl=fake_prop['theLabel'],
                        definition=fake_prop['theDefinition'],
                        category=fake_prop['theCategory'],
                        gRefs=new_goal_refinements,
                        sgRefs=new_subgoal_refinements,
                        concs=fake_prop['theConcerns'])
                    new_props.append(new_prop)
        else:
            self.close()
            raise MissingParameterHTTPError(
                param_names=['real_props', 'fake_props'])

        return new_props
Example #13
0
    def add(self,
            idx=-1,
            obsName="",
            envName="",
            newDefinition="",
            newCategory="Vulnerability",
            newOriginator=""):
        envName = self.envCombo.GetValue()
        parentObsName = self.obsCombo.GetValue()

        ep = ObstacleEnvironmentProperties(
            envName, '', newDefinition, newCategory,
            [(parentObsName, 'obstacle', 'and', 'No', 'None')])
        o = Obstacle(-1, obsName, newOriginator, [ep])
        op = ObstacleParameters(obsName, newOriginator, [ep])
        o.setId(self.dbProxy.addObstacle(op))
        if (idx != -1):
            self.obstacles.insert(idx, o)
        else:
            self.obstacles.append(o)
        return o
Example #14
0
 def OnAddEnvironment(self, evt):
     self.theSelectedIdx = evt.GetIndex()
     environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
     self.theEnvironmentDictionary[
         environmentName] = ObstacleEnvironmentProperties(environmentName)
     self.environmentList.Select(self.theSelectedIdx)
     self.labelCtrl.SetValue('')
     self.probCtrl.SetValue('')
     self.categoryCtrl.SetValue('')
     self.definitionCtrl.SetValue('None')
     self.goalAssociationCtrl.setEnvironment(environmentName)
     self.goalAssociationCtrl.DeleteAllItems()
     self.subGoalAssociationCtrl.setEnvironment(environmentName)
     self.concernsCtrl.setEnvironment(environmentName)
     self.subGoalAssociationCtrl.DeleteAllItems()
     self.concernsCtrl.DeleteAllItems()
     self.categoryCtrl.Enable()
     self.definitionCtrl.Enable()
     self.goalAssociationCtrl.Enable()
     self.subGoalAssociationCtrl.Enable()
     self.concernsCtrl.Enable()
     inheritedEnv = self.environmentList.inheritedEnvironment()
     if (inheritedEnv != '' and self.theObstacleId != None):
         p = self.dbProxy.inheritedObstacleProperties(
             self.theObstacleId, inheritedEnv)
         self.theEnvironmentDictionary[environmentName] = p
         self.labelCtrl.SetValue(p.label())
         self.labelCtrl.SetValue(str(p.probability()))
         self.categoryCtrl.SetValue(p.category())
         self.definitionCtrl.SetValue(p.definition())
         self.goalAssociationCtrl.setEnvironment(environmentName)
         self.goalAssociationCtrl.load(p.goalRefinements())
         self.subGoalAssociationCtrl.setEnvironment(environmentName)
         self.concernsCtrl.setEnvironment(environmentName)
         self.subGoalAssociationCtrl.load(p.subGoalRefinements())
         self.concernsCtrl.load(p.concerns())
  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)
Example #16
0
 def endElement(self, name):
     if name == 'domainproperty':
         p = DomainPropertyParameters(unescape(self.theName),
                                      unescape(self.theDefinition),
                                      self.theType,
                                      unescape(self.theOriginator),
                                      self.theTags)
         self.theDomainProperties.append(p)
         self.resetDomainPropertyAttributes()
     elif name == 'goal_environment':
         p = GoalEnvironmentProperties(self.theEnvironmentName, '',
                                       unescape(self.theDefinition),
                                       self.theCategory, self.thePriority,
                                       unescape(self.theFitCriterion),
                                       unescape(self.theIssue), [], [],
                                       self.theConcerns,
                                       self.theConcernAssociations)
         self.theEnvironmentProperties.append(p)
         self.resetGoalEnvironmentAttributes()
     elif name == 'obstacle_environment':
         p = ObstacleEnvironmentProperties(self.theEnvironmentName, '',
                                           unescape(self.theDefinition),
                                           self.theCategory, [], [],
                                           self.theConcerns)
         p.theProbability = self.theProbability
         p.theProbabilityRationale = unescape(self.theRationale)
         self.theEnvironmentProperties.append(p)
         self.resetObstacleEnvironmentAttributes()
     elif name == 'goal':
         p = GoalParameters(unescape(self.theName),
                            unescape(self.theOriginator), self.theTags,
                            self.theEnvironmentProperties)
         self.theGoals.append(p)
         self.resetGoalAttributes()
     elif name == 'obstacle':
         p = ObstacleParameters(unescape(self.theName),
                                unescape(self.theOriginator), self.theTags,
                                self.theEnvironmentProperties)
         self.theObstacles.append(p)
         self.resetObstacleAttributes()
     elif name == 'requirement':
         reqId = self.dbProxy.newId()
         r = cairis.core.RequirementFactory.build(
             reqId, self.theLabel, unescape(self.theName),
             unescape(self.theDescription), self.thePriority,
             unescape(self.theRationale), unescape(self.theFitCriterion),
             unescape(self.theOriginator), self.theType, self.theReference)
         self.theRequirements.append(
             (r, self.theReference, self.theReferenceType))
         self.resetRequirementAttributes()
     elif name == 'exception':
         self.theCurrentStep.addException(
             (self.theExcName, self.theExcType.lower(), self.theExcValue,
              self.theExcCat, unescape(self.theDefinition)))
     elif name == 'step':
         self.theCurrentStep.setTags(self.theTags)
         self.theSteps.append(self.theCurrentStep)
         self.theCurrentStep = None
     elif name == 'usecase_environment':
         vProperty, vRationale = self.theCognitiveAttribute['vigilance']
         saProperty, saRationale = self.theCognitiveAttribute[
             'situation awareness']
         sProperty, sRationale = self.theCognitiveAttribute['stress']
         wProperty, wRationale = self.theCognitiveAttribute['workload']
         raProperty, raRationale = self.theCognitiveAttribute[
             'risk awareness']
         p = UseCaseEnvironmentProperties(
             self.theEnvironmentName, unescape(self.thePreconditions),
             self.theSteps, unescape(self.thePostconditions),
             [vProperty, saProperty, sProperty, wProperty, raProperty],
             [vRationale, saRationale, sRationale, wRationale, raRationale])
         self.theEnvironmentProperties.append(p)
         self.resetUseCaseEnvironmentAttributes()
     elif name == 'usecase':
         p = UseCaseParameters(self.theName, self.theAuthor,
                               unescape(self.theCode), self.theActors,
                               unescape(self.theDescription), self.theTags,
                               self.theEnvironmentProperties)
         self.theUseCases.append(p)
         self.resetUseCaseAttributes()
     elif name == 'countermeasure':
         p = CountermeasureParameters(self.theName,
                                      unescape(self.theDescription),
                                      self.theType, self.theTags,
                                      self.theEnvironmentProperties)
         self.theCountermeasures.append(p)
         self.resetCountermeasureAttributes()
     elif name == 'mitigating_property':
         self.theSpDict[self.thePropertyName] = (self.thePropertyValue,
                                                 unescape(
                                                     self.theDescription))
         self.resetMitigatingPropertyAttributes()
     elif name == 'countermeasure_environment':
         cProperty, cRationale = self.theSpDict['confidentiality']
         iProperty, iRationale = self.theSpDict['integrity']
         avProperty, avRationale = self.theSpDict['availability']
         acProperty, acRationale = self.theSpDict['accountability']
         anProperty, anRationale = self.theSpDict['anonymity']
         panProperty, panRationale = self.theSpDict['pseudonymity']
         unlProperty, unlRationale = self.theSpDict['unlinkability']
         unoProperty, unoRationale = self.theSpDict['unobservability']
         p = CountermeasureEnvironmentProperties(
             self.theEnvironmentName, self.theCmRequirements,
             self.theTargets, [
                 cProperty, iProperty, avProperty, acProperty, anProperty,
                 panProperty, unlProperty, unoProperty
             ], [
                 cRationale, iRationale, avRationale, acRationale,
                 anRationale, panRationale, unlRationale, unoRationale
             ], self.theCost, self.theCmRoles, self.theTaskPersonas)
         self.theEnvironmentProperties.append(p)
         self.resetCountermeasureEnvironmentAttributes()
     elif (name == 'target'):
         self.theTargets.append(
             Target(self.theTargetName, self.theTargetEffectiveness,
                    unescape(self.theRationale)))
         self.theTargetResponses = []
     elif (name == 'description'):
         self.inDescription = 0
     elif (name == 'definition'):
         self.inDefinition = 0
     elif name == 'fit_criterion':
         self.inFitCriterion = 0
     elif name == 'issue':
         self.inIssue = 0
     elif name == 'rationale':
         self.inRationale = 0
     elif name == 'originator':
         self.inOriginator = 0
     elif name == 'preconditions':
         self.inPreconditions = 0
     elif name == 'postconditions':
         self.inPostconditions = 0
Example #17
0
 def endElement(self, name):
     if name == 'domainproperty':
         p = DomainPropertyParameters(self.theName, self.theDescription,
                                      self.theType, self.theOriginator,
                                      self.theTags)
         self.theDomainProperties.append(p)
         self.resetDomainPropertyAttributes()
     elif name == 'goal_environment':
         p = GoalEnvironmentProperties(self.theEnvironmentName, '',
                                       self.theDescription,
                                       self.theCategory, self.thePriority,
                                       self.theFitCriterion, self.theIssue,
                                       [], [], self.theConcerns,
                                       self.theConcernAssociations)
         self.theEnvironmentProperties.append(p)
         self.resetGoalEnvironmentAttributes()
     elif name == 'obstacle_environment':
         p = ObstacleEnvironmentProperties(self.theEnvironmentName, '',
                                           self.theDescription,
                                           self.theCategory, [], [],
                                           self.theConcerns)
         self.theEnvironmentProperties.append(p)
         self.resetObstacleEnvironmentAttributes()
     elif name == 'goal':
         p = GoalParameters(self.theName, self.theOriginator, self.theTags,
                            self.theEnvironmentProperties)
         self.theGoals.append(p)
         self.resetGoalAttributes()
     elif name == 'obstacle':
         p = ObstacleParameters(self.theName, self.theOriginator,
                                self.theTags, self.theEnvironmentProperties)
         self.theObstacles.append(p)
         self.resetObstacleAttributes()
     elif name == 'requirement':
         reqId = self.dbProxy.newId()
         r = cairis.core.RequirementFactory.build(
             reqId, self.theLabel, self.theName, self.theDescription,
             self.thePriority, self.theRationale, self.theFitCriterion,
             self.theOriginator, self.theType, self.theReference)
         self.theRequirements.append(
             (r, self.theReference, self.theReferenceType))
         self.resetRequirementAttributes()
     elif name == 'countermeasure':
         p = CountermeasureParameters(self.theName, self.theDescription,
                                      self.theType, self.theTags,
                                      self.theEnvironmentProperties)
         self.theCountermeasures.append(p)
         self.resetCountermeasureAttributes()
     elif name == 'mitigating_property':
         self.theSpDict[self.thePropertyName] = (self.thePropertyValue,
                                                 self.theDescription)
         self.resetMitigatingPropertyAttributes()
     elif name == 'countermeasure_environment':
         cProperty, cRationale = self.theSpDict['confidentiality']
         iProperty, iRationale = self.theSpDict['integrity']
         avProperty, avRationale = self.theSpDict['availability']
         acProperty, acRationale = self.theSpDict['accountability']
         anProperty, anRationale = self.theSpDict['anonymity']
         panProperty, panRationale = self.theSpDict['pseudonymity']
         unlProperty, unlRationale = self.theSpDict['unlinkability']
         unoProperty, unoRationale = self.theSpDict['unobservability']
         p = CountermeasureEnvironmentProperties(
             self.theEnvironmentName, self.theCmRequirements,
             self.theTargets, [
                 cProperty, iProperty, avProperty, acProperty, anProperty,
                 panProperty, unlProperty, unoProperty
             ], [
                 cRationale, iRationale, avRationale, acRationale,
                 anRationale, panRationale, unlRationale, unoRationale
             ], self.theCost, self.theCmRoles, self.theTaskPersonas)
         self.theEnvironmentProperties.append(p)
         self.resetCountermeasureEnvironmentAttributes()
     elif (name == 'target'):
         self.theTargets.append(
             Target(self.theTargetName, self.theTargetEffectiveness,
                    self.theRationale))
         self.theTargetResponses = []
     elif (name == 'description'):
         self.inDescription = 0
     elif (name == 'definition'):
         self.inDescription = 0
     elif name == 'fit_criterion':
         self.inFitCriterion = 0
     elif name == 'issue':
         self.inIssue = 0
     elif name == 'rationale':
         self.inRationale = 0
     elif name == 'originator':
         self.inOriginator = 0
Example #18
0
    def setUpClass(cls):
        call([os.environ['CAIRIS_CFG_DIR'] + "/initdb.sh"])
        cairis.core.BorgFactory.initialise()

        f = open(os.environ['CAIRIS_SRC'] + '/test/dataflow.json')
        d = json.load(f)
        f.close()
        iEnvironments = d['environments']
        iep1 = EnvironmentParameters(iEnvironments[0]["theName"],
                                     iEnvironments[0]["theShortCode"],
                                     iEnvironments[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)

        iUseCases = d['use_cases']
        ucName = iUseCases[0]["theName"]
        ucAuthor = iUseCases[0]["theAuthor"]
        ucCode = iUseCases[0]["theCode"]
        ucDesc = iUseCases[0]["theDescription"]
        ucActor = iUseCases[0]["theActor"]
        ucEnv = iUseCases[0]["theEnvironments"][0]
        ucEnvName = ucEnv["theName"]
        ucPre = ucEnv["thePreconditions"]
        ucPost = ucEnv["thePostconditions"]
        ss = Steps()
        for ucStep in ucEnv["theFlow"]:
            ss.append(Step(ucStep["theDescription"]))
        ucep = UseCaseEnvironmentProperties(ucEnvName, ucPre, ss, ucPost)
        iuc = UseCaseParameters(ucName, ucAuthor, ucCode, [ucActor], ucDesc,
                                [], [ucep])
        b = Borg()
        b.dbProxy.addUseCase(iuc)

        for iAsset in d['assets']:
            iaeps = [
                AssetEnvironmentProperties(
                    iAsset["theEnvironmentProperties"][0][0],
                    iAsset["theEnvironmentProperties"][0][1],
                    iAsset["theEnvironmentProperties"][0][2])
            ]
            iap = AssetParameters(iAsset["theName"], iAsset["theShortCode"],
                                  iAsset["theDescription"],
                                  iAsset["theSignificance"], iAsset["theType"],
                                  "0", "N/A", [], [], iaeps)
            b.dbProxy.addAsset(iap)

        for iObstacle in d['obstacles']:
            ioep = ObstacleEnvironmentProperties(
                iObstacle["theEnvironmentProperties"][0],
                iObstacle["theEnvironmentProperties"][1],
                iObstacle["theEnvironmentProperties"][2],
                iObstacle["theEnvironmentProperties"][3])
            iop = ObstacleParameters(iObstacle["theName"],
                                     iObstacle["theOriginator"], [], [ioep])
            b.dbProxy.addObstacle(iop)
Example #19
0
 def parameters(self):
   properties = ObstacleEnvironmentProperties(self.theEnvironmentName,'',self.theObstacleDefinition,self.theObstacleCategory,self.theAssociations,self.theSubAssociations,self.theConcerns)
   parameters = ObstacleParameters(self.theObstacleName,[],[properties])
   return parameters