def parameters(self): parameters = DomainPropertyParameters(self.theName, self.theDescription, self.theType, self.theOriginator, self.theTags) parameters.setId(self.theId) return parameters
def add_domain_property(self, domain_property): """ :type domain_property: DomainProperty :rtype: int :raise ARMHTTPError: """ domain_property_params = DomainPropertyParameters( name=domain_property.name(), desc=domain_property.description(), dpType=domain_property.type(), dpOrig=domain_property.originator(), tags=domain_property.tags()) try: if not self.check_existing_domain_property(domain_property.name()): new_id = self.db_proxy.addDomainProperty( domain_property_params) return new_id else: self.close() raise OverwriteNotAllowedHTTPError( obj_name=domain_property.name()) except DatabaseProxyException as ex: self.close() raise ARMHTTPError(ex) except ARMException as ex: self.close() raise ARMHTTPError(ex)
def update_domain_property(self, domain_property, name): found_domain_property = self.get_domain_property_by_name( name, simplify=False) domain_property_params = DomainPropertyParameters( name=domain_property.name(), desc=domain_property.description(), dpType=domain_property.type(), dpOrig=domain_property.originator(), tags=domain_property.tags()) domain_property_params.setId(found_domain_property.id()) try: self.db_proxy.updateDomainProperty(domain_property_params) except DatabaseProxyException as ex: self.close() raise ARMHTTPError(ex) except ARMException as ex: self.close() raise ARMHTTPError(ex)
def update_domain_property(self, domain_property, name): found_domain_property = self.get_domain_property_by_name(name, simplify=False) domain_property_params = DomainPropertyParameters( name=domain_property.name(), desc=domain_property.description(), dpType=domain_property.type(), dpOrig=domain_property.originator(), tags=domain_property.tags() ) domain_property_params.setId(found_domain_property.id()) try: self.db_proxy.updateDomainProperty(domain_property_params) except DatabaseProxyException as ex: self.close() raise ARMHTTPError(ex) except ARMException as ex: self.close() raise ARMHTTPError(ex)
def update_object(self, domain_property, name): domain_property_params = DomainPropertyParameters( name=domain_property.name(), desc=domain_property.description(), dpType=domain_property.type(), dpOrig=domain_property.originator(), tags=domain_property.tags()) try: dpId = self.db_proxy.getDimensionId(name, 'domainproperty') domain_property_params.setId(dpId) self.db_proxy.updateDomainProperty(domain_property_params) except ObjectNotFound as ex: self.close() raise ObjectNotFoundHTTPError(ex) except DatabaseProxyException as ex: self.close() raise ARMHTTPError(ex) except ARMException as ex: self.close() raise ARMHTTPError(ex)
def update_domain_property(self, domain_property, name): domain_property_params = DomainPropertyParameters( name=domain_property.name(), desc=domain_property.description(), dpType=domain_property.type(), dpOrig=domain_property.originator(), tags=domain_property.tags() ) try: dpId = self.db_proxy.getDimensionId(name,'domainproperty') domain_property_params.setId(dpId) self.db_proxy.updateDomainProperty(domain_property_params) except ObjectNotFound as ex: self.close() raise ObjectNotFoundHTTPError(ex) except DatabaseProxyException as ex: self.close() raise ARMHTTPError(ex) except ARMException as ex: self.close() raise ARMHTTPError(ex)
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
def parameters(self): parameters = DomainPropertyParameters(self.theName,self.theDescription,self.theType,self.theOriginator,self.theTags) parameters.setId(self.theId) return parameters
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
def testDomainProperty(self): idp = DomainPropertyParameters(self.iDomainProperties[0]["theName"], self.iDomainProperties[0]["theDefinition"], self.iDomainProperties[0]["theType"],self.iDomainProperties[0]["theOriginator"],[]) b = Borg() b.dbProxy.addDomainProperty(idp) odps = b.dbProxy.getDomainProperties() odp = odps[self.iDomainProperties[0]["theName"]] self.assertEqual(idp.name(), odp.name()) self.assertEqual(idp.description(),odp.description()) self.assertEqual(idp.type(),odp.type()) self.assertEqual(idp.originator(),odp.originator()) idp.theName = 'Updated name' idp.setId(odp.id()) b.dbProxy.updateDomainProperty(idp) odps = b.dbProxy.getDomainProperties() odp = odps['Updated name'] self.assertEqual(odp.name(),'Updated name') self.assertEqual(idp.description(),odp.description()) self.assertEqual(idp.type(),odp.type()) self.assertEqual(idp.originator(),odp.originator()) b.dbProxy.deleteDomainProperty(odp.id())
def testDomainProperty(self): idp = DomainPropertyParameters( self.iDomainProperties[0]["theName"], self.iDomainProperties[0]["theDefinition"], self.iDomainProperties[0]["theType"], self.iDomainProperties[0]["theOriginator"], []) b = Borg() idp.theOriginator = '0' * 200 with self.assertRaises(AttributeTooBig): b.dbProxy.addDomainProperty(idp) idp.theOriginator = self.iDomainProperties[0]["theOriginator"] b.dbProxy.addDomainProperty(idp) odps = b.dbProxy.getDomainProperties() odp = odps[self.iDomainProperties[0]["theName"]] self.assertEqual(idp.name(), odp.name()) self.assertEqual(idp.description(), odp.description()) self.assertEqual(idp.type(), odp.type()) self.assertEqual(idp.originator(), odp.originator()) idp.theName = 'Updated name' idp.setId(odp.id()) b.dbProxy.updateDomainProperty(idp) odps = b.dbProxy.getDomainProperties() odp = odps['Updated name'] self.assertEqual(odp.name(), 'Updated name') self.assertEqual(idp.description(), odp.description()) self.assertEqual(idp.type(), odp.type()) self.assertEqual(idp.originator(), odp.originator()) b.dbProxy.deleteDomainProperty(odp.id())
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': p = UseCaseEnvironmentProperties(self.theEnvironmentName,unescape(self.thePreconditions),self.theSteps,unescape(self.thePostconditions)) 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