Ejemplo n.º 1
0
  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())
    
    b.dbProxy.deleteCountermeasure(ocm.id())
Ejemplo n.º 2
0
  def add_countermeasure(self, countermeasure):
    """
    :type countermeasure: Countermeasure
    :rtype: int
    :raise ARMHTTPError:
    """
    countermeasure_params = CountermeasureParameters(
      cmName=countermeasure.name(),
      cmDesc=countermeasure.description(),
      cmType=countermeasure.type(),
      tags=countermeasure.tags(),
      cProps=countermeasure.environmentProperties()
    )

    try:
      if not self.check_existing_countermeasure(countermeasure.name()):
        new_id = self.db_proxy.addCountermeasure(countermeasure_params)
        return new_id
      else:
        self.close()
        raise OverwriteNotAllowedHTTPError(obj_name=countermeasure.name())
    except DatabaseProxyException as ex:
      self.close()
      raise ARMHTTPError(ex)
    except ARMException as ex:
      self.close()
      raise ARMHTTPError(ex)
Ejemplo n.º 3
0
  def update_countermeasure(self, countermeasure, name):
    countermeasure_params = CountermeasureParameters(
      cmName=countermeasure.name(),
      cmDesc=countermeasure.description(),
      cmType=countermeasure.type(),
      tags=countermeasure.tags(),
      cProps=countermeasure.environmentProperties()
    )

    try:
      cmId = self.db_proxy.getDimensionId(name,'countermeasure')
      countermeasure_params.setId(cmId)
      self.db_proxy.updateCountermeasure(countermeasure_params)
    except DatabaseProxyException as ex:
      self.close()
      raise ARMHTTPError(ex)
    except ARMException as ex:
      self.close()
      raise ARMHTTPError(ex)
Ejemplo n.º 4
0
  def update_countermeasure(self, countermeasure, name):
    found_countermeasure = self.get_countermeasure_by_name(name, simplify=False)

    countermeasure_params = CountermeasureParameters(
      cmName=countermeasure.name(),
      cmDesc=countermeasure.description(),
      cmType=countermeasure.type(),
      tags=countermeasure.tags(),
      cProps=countermeasure.environmentProperties()
    )
    countermeasure_params.setId(found_countermeasure.id())

    try:
      self.db_proxy.updateCountermeasure(countermeasure_params)
    except DatabaseProxyException as ex:
      self.close()
      raise ARMHTTPError(ex)
    except ARMException as ex:
      self.close()
      raise ARMHTTPError(ex)
Ejemplo n.º 5
0
  def update_countermeasure(self, countermeasure, name):
    countermeasure_params = CountermeasureParameters(
      cmName=countermeasure.name(),
      cmDesc=countermeasure.description(),
      cmType=countermeasure.type(),
      tags=countermeasure.tags(),
      cProps=countermeasure.environmentProperties()
    )

    try:
      cmId = self.db_proxy.getDimensionId(name,'countermeasure')
      countermeasure_params.setId(cmId)
      self.db_proxy.updateCountermeasure(countermeasure_params)
    except ObjectNotFound as ex:
      self.close()
      raise ObjectNotFoundHTTPError('The provided countermeasure name')
    except DatabaseProxyException as ex:
      self.close()
      raise ARMHTTPError(ex)
    except ARMException as ex:
      self.close()
      raise ARMHTTPError(ex)
Ejemplo n.º 6
0
  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())
Ejemplo n.º 7
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
Ejemplo n.º 8
0
 def parameters(self):
     return CountermeasureParameters(self.theCountermeasureName,
                                     self.theCountermeasureDescription,
                                     self.theCountermeasureType,
                                     self.theTags,
                                     self.theEnvironmentProperties)
Ejemplo n.º 9
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