コード例 #1
0
    def OnAddEnvironment(self, evt):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            syProperties, pRationale = self.propertiesList.properties()
            properties = CountermeasureEnvironmentProperties(
                environmentName, self.reqList.dimensions(),
                self.targetList.targets(), syProperties, pRationale,
                self.costCombo.GetValue(), self.roleList.dimensions(),
                self.personaList.dimensions())
            self.theEnvironmentDictionary[environmentName] = properties
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = CountermeasureEnvironmentProperties(
                environmentName)

        self.reqList.setEnvironment(environmentName)
        self.reqList.DeleteAllItems()
        self.targetList.setEnvironment(environmentName)
        self.targetList.DeleteAllItems()
        self.propertiesList.setEnvironment(environmentName)
        self.propertiesList.DeleteAllItems()
        self.costCombo.SetValue('')
        self.roleList.setEnvironment(environmentName)
        self.roleList.DeleteAllItems()
        self.personaList.DeleteAllItems()

        self.reqList.Enable()
        self.targetList.Enable()
        self.propertiesList.Enable()
        self.costCombo.Enable()
        self.roleList.Enable()
コード例 #2
0
 def environmentProperties(self):
     if (self.theSelectedIdx != -1):
         environmentName = self.environmentList.GetItemText(
             self.theSelectedIdx)
         syProperties, pRationale = self.propertiesList.properties()
         properties = CountermeasureEnvironmentProperties(
             environmentName, self.reqList.dimensions(),
             self.targetList.targets(), syProperties, pRationale,
             self.costCombo.GetValue(), self.roleList.dimensions(),
             self.personaList.dimensions())
         self.theEnvironmentDictionary[environmentName] = properties
     for cname in self.environmentList.dimensions():
         p = self.theEnvironmentDictionary[cname]
         if (len(p.requirements()) == 0):
             exceptionText = 'No requirements selected for environment ' + p.name(
             )
             raise ARM.EnvironmentValidationError(exceptionText)
         if (len(p.targets()) == 0):
             exceptionText = 'No targets selected for environment ' + p.name(
             )
             raise ARM.EnvironmentValidationError(exceptionText)
         if (len(p.cost()) == 0):
             exceptionText = 'No cost selected for environment ' + p.name()
             raise ARM.EnvironmentValidationError(exceptionText)
         if (len(p.roles()) == 0):
             exceptionText = 'No roles selected for environment ' + p.name()
             raise ARM.EnvironmentValidationError(exceptionText)
     return self.theEnvironmentDictionary.values()
コード例 #3
0
  def prepare_new_countermeasure(self):
    new_countermeasure_props = [
      CountermeasureEnvironmentProperties(
        environmentName=self.existing_environment_name,
        requirements=self.existing_requirements,
        targets=self.existing_targets,
        properties=self.existing_properties,
        rationale=self.existing_rationale,
        cost=self.existing_cost,
        roles=self.existing_roles,
        personas=self.existing_personas)
    ]

    new_countermeasure = Countermeasure(
      cmId=-1,
      cmName='New countermeasure',
      cmDesc='New CM description',
      cmType='Information',
      tags=[],
      cProps=[]
    )
    new_countermeasure.theEnvironmentProperties = new_countermeasure_props
    new_countermeasure.theEnvironmentDictionary = {}
    delattr(new_countermeasure, 'theEnvironmentDictionary')
    return new_countermeasure
コード例 #4
0
ファイル: test_Countermeasure.py プロジェクト: we45/cairis
  def testCountermeasure(self):

    icep = CountermeasureEnvironmentProperties(self.iCountermeasures[0]["theEnvironmentProperties"][0][0],[self.iCountermeasures[0]["theEnvironmentProperties"][0][2]],[Target(self.iCountermeasures[0]["theEnvironmentProperties"][0][3],self.iCountermeasures[0]["theEnvironmentProperties"][0][4],"None")],[0,0,0,0,0,0,0,0],['None','None','None','None','None','None','None','None'],self.iCountermeasures[0]["theEnvironmentProperties"][0][1],[self.iCountermeasures[0]["theEnvironmentProperties"][0][5]])
    icm = CountermeasureParameters(self.iCountermeasures[0]["theName"],self.iCountermeasures[0]["theDescription"],self.iCountermeasures[0]["theType"],[],[icep])

    b = Borg()
    b.dbProxy.addCountermeasure(icm)
    ocms = b.dbProxy.getCountermeasures()
    ocm = ocms[self.iCountermeasures[0]["theName"]]
    self.assertEqual(icm.name(), ocm.name())
    self.assertEqual(icm.type(),ocm.type())
    self.assertEqual(icm.description(),ocm.description())

    icm.theName = 'Updated countermeasure'
    icm.setId(ocm.id())
    b.dbProxy.updateCountermeasure(icm)
    ocms = b.dbProxy.getCountermeasures()
    ocm = ocms['Updated countermeasure']
    self.assertEqual('Updated countermeasure', ocm.name())
    self.assertEqual(icm.type(),ocm.type())
    self.assertEqual(icm.description(),ocm.description())

    b.dbProxy.deleteCountermeasure(ocm.id())
コード例 #5
0
ファイル: CountermeasureDAO.py プロジェクト: adamrbu/cairis
 def convert_props(self, real_props=None, fake_props=None):
   new_props = []
   if real_props is not None:
     if len(real_props) > 0:
       for real_prop in real_props:
         assert isinstance(real_prop, CountermeasureEnvironmentProperties)
         ctList = []
         for ctc in real_prop.personas():
           ctList.append(CountermeasureTaskCharacteristics(ctc[0],ctc[1],ctc[2],ctc[3],ctc[4],ctc[5]))
         real_prop.thePersonas = ctList
         assert len(real_prop.theProperties) == len(real_prop.theRationale)
         new_attrs = []
         for idx in range(0, len(real_prop.theProperties)):
           attr_name = self.rev_attr_dict.get(idx)
           attr_value = self.prop_dict[real_prop.theProperties[idx]]
           attr_rationale = real_prop.theRationale[idx]
           new_attr = SecurityAttribute(attr_name, attr_value, attr_rationale)
           new_attrs.append(new_attr)
         real_prop.theProperties = new_attrs
         new_targets = []
         for idx in range(0, len(real_prop.theTargets)):
           tName = real_prop.theTargets[idx].name()
           tEff = real_prop.theTargets[idx].effectiveness()
           tRat = real_prop.theTargets[idx].rationale()
           new_targets.append(CountermeasureTarget(tName,tEff,tRat))
         real_prop.theTargets = new_targets
         new_props.append(real_prop)
     return new_props
   elif fake_props is not None:
     if len(fake_props) > 0:
       for fake_prop in fake_props:
         check_required_keys(fake_prop, CountermeasureEnvironmentPropertiesModel.required)
         ctList = []
         for ctc in fake_prop['thePersonas']:
           ctList.append([ctc['theTask'],ctc['thePersona'],ctc['theDuration'],ctc['theFrequency'],ctc['theDemands'],ctc['theGoalConflict']])
         fake_prop['thePersonas'] = ctList
         new_ndprops = array([0]*8).astype(numpy.core.int32)
         new_ratios = ['None']*8
         for idx in range(0, len(fake_prop['theProperties'])):
           new_attr = fake_prop['theProperties'][idx]
           check_required_keys(new_attr, SecurityAttribute.required)
           attr_id = self.attr_dict.get(new_attr['name'], -1)
           if -1 < attr_id < len(self.attr_dict):
             attr_value = self.rev_prop_dict[new_attr['value']]
             attr_rationale = new_attr['rationale']
             new_ndprops[attr_id] = attr_value
             new_ratios[attr_id] = attr_rationale
         fake_prop['theProperties'] = new_ndprops
         fake_prop['theRationale'] = new_ratios
         new_targets = []
         for idx in range(0, len(fake_prop['theTargets'])):
           tName = fake_prop['theTargets'][idx]['theName']
           tEff = fake_prop['theTargets'][idx]['theEffectiveness']
           tRat = fake_prop['theTargets'][idx]['theRationale']
           new_targets.append(CountermeasureTarget(tName,tEff,tRat))
         fake_prop['theTargets'] = new_targets
         check_required_keys(fake_prop, CountermeasureEnvironmentPropertiesModel.required)
         new_prop = CountermeasureEnvironmentProperties(
                      environmentName=fake_prop['theEnvironmentName'],
                      requirements=fake_prop['theRequirements'],
                      targets=fake_prop['theTargets'],
                      properties=fake_prop['theProperties'],
                      rationale=fake_prop['theRationale'],
                      cost=fake_prop['theCost'],
                      roles=fake_prop['theRoles'],
                      personas=fake_prop['thePersonas']
                    )
         new_props.append(new_prop)
     return new_props
   else:
     self.close()
     raise MissingParameterHTTPError(param_names=['real_props', 'fake_props'])
コード例 #6
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
コード例 #7
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