Example #1
0
  def fakeToRealAp(self,ap):
    apName = ap["theName"]
    apSyn = ap["theSynopsis"]
    theComponents = []
    for c in ap["theComponents"]:
      cName = c["theName"]
      cDesc = c["theDescription"]
      cInts = []
      for i in c["theInterfaces"]:
        cInts.append((i["theName"],i["theType"],i["theAccessRight"],i["thePrivilege"]))
      cStructs = []
      for cs in c["theStructure"]:
        cStructs.append((cs["theHeadAsset"],cs["theHeadAdornment"],cs["theHeadNav"],cs["theHeadNry"],cs["theHeadRole"],cs["theTailRole"],cs["theTailNry"],cs["theTailNav"],cs["theTailAdornment"],cs["theTailAsset"]))
      cReqs = []
      cGoals = []
      for i in c["theGoals"]:
        cGoals.append(i)

      cGoalAssocs = []
      for cga in c["theGoalAssociations"]:
        cGoalAssocs.append((cga["theGoalName"],cga["theSubGoalName"],cga["theRefType"],'None'))
      theComponents.append(ComponentParameters(cName,cDesc,cInts,cStructs,cReqs,cGoals,cGoalAssocs))
    theConnectors = []
    for conn in ap["theConnectors"]:
      theConnectors.append(ConnectorParameters(conn["theConnectorName"],apName,conn["theFromComponent"],conn["theFromRole"],conn["theFromInterface"],conn["theToComponent"],conn["theToInterface"],conn["theToRole"],conn["theAssetName"],conn["theProtocol"],conn["theAccessRight"]))

    cvParams = ComponentViewParameters(apName,apSyn,[],[],[],[],[],theComponents,theConnectors)
    return cvParams
  def testComponentView(self):

    cvName = self.iComponentViews[0]["theName"]
    cvSyn = self.iComponentViews[0]["theSynopsis"]
    theComponents = []
    for c in self.iComponentViews[0]["theComponents"]:
      cName = c["theName"]
      cDesc = c["theDescription"]
      cInts = []
      for i in c["theInterfaces"]:
        cInts.append((i["theName"],i["theType"],i["theAccessRight"],i["thePrivilege"]))
      cStructs = []
      for cs in c["theStructure"]:
        cStructs.append((cs["theHeadAsset"],cs["theHeadAdornment"],cs["theHeadNav"],cs["theHeadNry"],cs["theHeadRole"],cs["theTailRole"],cs["theTailNry"],cs["theTailNav"],cs["theTailAdornment"],cs["theTailAsset"]))
      cReqs = []
      cGoals = []
      for i in c["theGoals"]:
        cGoals.append(i)

      cGoalAssocs = []
      for cga in c["theGoalAssociations"]:
        cGoalAssocs.append((cga["theGoalName"],cga["theSubGoalName"],cga["theRefType"],'None'))
      theComponents.append(ComponentParameters(cName,cDesc,cInts,cStructs,cReqs,cGoals,cGoalAssocs))

    theConnectors = []
    for conn in self.iComponentViews[0]["theConnectors"]:
      theConnectors.append(ConnectorParameters(conn["theConnectorName"],cvName,conn["theFromComponent"],conn["theFromRole"],conn["theFromInterface"],conn["theToComponent"],conn["theToInterface"],conn["theToRole"],conn["theAssetName"],conn["theProtocol"],conn["theAccessRight"]))
 
    icvp = ComponentViewParameters(cvName,cvSyn,self.theMetricTypes,self.theRoles,self.theAssets,self.theRequirements,self.theGoals,theComponents,theConnectors)
    b = Borg()
    b.dbProxy.addComponentView(icvp)

    ocvps = b.dbProxy.getComponentViews()
    ocvp = ocvps[cvName]

    self.assertEqual(icvp.name(), ocvp.name())
    self.assertEqual(icvp.synopsis(), ocvp.synopsis())

    self.assertEqual(b.dbProxy.componentAttackSurface('Policy Manager'),3.0)
    cg = b.dbProxy.componentGoalModel('Policy Manager')

    icvp.setId(ocvp.id())
    icvp.theSynopsis = 'revised synopsis'
    b.dbProxy.updateComponentView(icvp)
    ocvps = b.dbProxy.getComponentViews()
    ocvp = ocvps[cvName]

    self.assertEqual(icvp.name(), ocvp.name())
    self.assertEqual(ocvp.synopsis(), 'revised synopsis')


    b.dbProxy.deleteComponentView(ocvp.id())
  def testComponentView(self):

    cvName = self.iComponentViews[0]["theName"]
    cvSyn = self.iComponentViews[0]["theSynopsis"]
    theComponents = []
    for c in self.iComponentViews[0]["theComponents"]:
      cName = c["theName"]
      cDesc = c["theDescription"]
      cInts = []
      for i in c["theInterfaces"]:
        cInts.append((i["theName"],i["theType"],i["theAccessRight"],i["thePrivilege"]))
      cStructs = []
      for cs in c["theStructure"]:
        cStructs.append((cs["theHeadAsset"],cs["theHeadAdornment"],cs["theHeadNav"],cs["theHeadNry"],cs["theHeadRole"],cs["theTailRole"],cs["theTailNry"],cs["theTailNav"],cs["theTailAdornment"],cs["theTailAsset"]))
      cReqs = []
      cGoals = []
      for i in c["theGoals"]:
        cGoals.append(i)

      cGoalAssocs = []
      for cga in c["theGoalAssociations"]:
        cGoalAssocs.append((cga["theGoalName"],cga["theSubGoalName"],cga["theRefType"],'None'))
      theComponents.append(ComponentParameters(cName,cDesc,cInts,cStructs,cReqs,cGoals,cGoalAssocs))

    theConnectors = []
    for conn in self.iComponentViews[0]["theConnectors"]:
      theConnectors.append(ConnectorParameters(conn["theConnectorName"],cvName,conn["theFromComponent"],conn["theFromRole"],conn["theFromInterface"],conn["theToComponent"],conn["theToInterface"],conn["theToRole"],conn["theAssetName"],conn["theProtocol"],conn["theAccessRight"]))
 
    icvp = ComponentViewParameters(cvName,cvSyn,self.theMetricTypes,self.theRoles,self.theAssets,self.theRequirements,self.theGoals,theComponents,theConnectors)
    b = Borg()
    b.dbProxy.addComponentView(icvp)

    ocvps = b.dbProxy.getComponentViews()
    ocvp = ocvps[cvName]

    self.assertEqual(icvp.name(), ocvp.name())
    self.assertEqual(icvp.synopsis(), ocvp.synopsis())

    self.assertEqual(b.dbProxy.componentAttackSurface('Policy Manager'),3.0)
    cg = b.dbProxy.componentGoalModel('Policy Manager')

    icvp.setId(ocvp.id())
    icvp.theSynopsis = 'revised synopsis'
    b.dbProxy.updateComponentView(icvp)
    ocvps = b.dbProxy.getComponentViews()
    ocvp = ocvps[cvName]

    self.assertEqual(icvp.name(), ocvp.name())
    self.assertEqual(ocvp.synopsis(), 'revised synopsis')


    b.dbProxy.deleteComponentView(ocvp.id())
 def endElement(self, name):
     if (name == 'component'):
         p = ComponentParameters(self.theName, self.theDescription,
                                 self.theInterfaces, self.theStructure,
                                 self.theComponentRequirements,
                                 self.theComponentGoals,
                                 self.theComponentGoalAssociations)
         self.theComponents.append(p)
         self.resetComponentAttributes()
     elif name == 'role':
         p = RoleParameters(self.theName, self.theType, self.theShortCode,
                            self.theDescription, [])
         self.theRoles.append(p)
         self.resetRoleAttributes()
     elif name == 'asset':
         spDict = {}
         spDict['confidentiality'] = 0
         spDict['integrity'] = 0
         spDict['availability'] = 0
         spDict['accountability'] = 0
         spDict['anonymity'] = 0
         spDict['pseudonymity'] = 0
         spDict['unlinkability'] = 0
         spDict['unobservability'] = 0
         srDict = {}
         srDict['confidentiality'] = 'None'
         srDict['integrity'] = 'None'
         srDict['availability'] = 'None'
         srDict['accountability'] = 'None'
         srDict['anonymity'] = 'None'
         srDict['pseudonymity'] = 'None'
         srDict['unlinkability'] = 'None'
         srDict['unobservability'] = 'None'
         for sp in self.theSecurityProperties:
             spName = sp[0]
             spValue = a2i(sp[1])
             spRationale = sp[2]
             if spName in spDict:
                 spDict[spName] = spValue
             if spName in srDict:
                 srDict[spName] = spRationale
         spValues = []
         spValues.append(spDict['confidentiality'])
         spValues.append(spDict['integrity'])
         spValues.append(spDict['availability'])
         spValues.append(spDict['accountability'])
         spValues.append(spDict['anonymity'])
         spValues.append(spDict['pseudonymity'])
         spValues.append(spDict['unlinkability'])
         spValues.append(spDict['unobservability'])
         srValues = []
         srValues.append(srDict['confidentiality'])
         srValues.append(srDict['integrity'])
         srValues.append(srDict['availability'])
         srValues.append(srDict['accountability'])
         srValues.append(srDict['anonymity'])
         srValues.append(srDict['pseudonymity'])
         srValues.append(srDict['unlinkability'])
         srValues.append(srDict['unobservability'])
         p = TemplateAssetParameters(
             self.theName, self.theShortCode, self.theDescription,
             self.theSignificance, self.theAssetType, self.theSurfaceType,
             self.theAccessRight, spValues, srValues, self.theTags,
             self.theInterfaces)
         self.theAssets.append(p)
         self.resetAssetAttributes()
     elif name == 'security_property':
         self.theSecurityProperties.append(
             (self.thePropertyName, self.thePropertyValue,
              self.theRationale))
         self.resetSecurityPropertyAttributes()
     elif name == 'structure':
         self.theStructure.append(
             (self.theHeadName, self.theHeadAdornment, self.theHeadNav,
              self.theHeadNry, self.theHeadRole, self.theTailRole,
              self.theTailNry, self.theTailNav, self.theTailAdornment,
              self.theTailName))
         self.resetStructure()
     elif name == 'requirement':
         p = TemplateRequirementParameters(self.theReqName, self.theAsset,
                                           self.theType,
                                           self.theDescription,
                                           self.theRationale,
                                           self.theFitCriterion)
         self.theRequirements.append(p)
         self.resetRequirementAttributes()
     elif name == 'goal':
         p = TemplateGoalParameters(self.theName, self.theDefinition,
                                    self.theRationale, self.theConcerns,
                                    self.theResponsibilities)
         self.theGoals.append(p)
         self.resetGoalAttributes()
     elif name == 'connector':
         p = ConnectorParameters(self.theName, self.theViewName,
                                 self.theFromName, self.theFromRole,
                                 self.theFromInterface, self.theToName,
                                 self.theToInterface, self.theToRole,
                                 self.theConnectorAsset,
                                 self.theProtocolName, self.theAccessRight)
         self.theConnectors.append(p)
         self.resetConnectorAttributes()
     elif name == 'component_goal_association':
         self.theComponentGoalAssociations.append(
             (self.theGoalName, self.theSubGoalName, self.theRefType,
              self.theRationale))
         self.resetComponentGoalAssociationAttributes()
     elif name == 'description':
         self.inDescription = 0
     elif name == 'definition':
         self.inDefinition = 0
     elif name == 'synopsis':
         self.inSynopsis = 0
     elif name == 'rationale':
         self.inRationale = 0
     elif name == 'significance':
         self.inSignificance = 0
     elif name == 'fit_criterion':
         self.inFitCriterion = 0
     elif name == 'access_right' or name == 'protocol' or name == 'privilege' or name == 'surface_type':
         p = ValueTypeParameters(self.theName, self.theDescription, name,
                                 '', self.theScore, self.theRationale)
         self.theMetricTypes.append(p)
         self.resetValueTypeAttributes()
     elif name == 'architectural_pattern':
         self.theViewParameters = ComponentViewParameters(
             self.theViewName, self.theSynopsis, self.theMetricTypes,
             self.theRoles, self.theAssets, self.theRequirements,
             self.theGoals, self.theComponents, self.theConnectors)
Example #5
0
 def parameters(self):
   parameters = ComponentViewParameters(self.theName,self.theSynopsis,[],[],[],[],[],self.theComponents,self.theConnectors)
   parameters.setId(self.theComponentViewId)
   return parameters
Example #6
0
 def parameters(self):
   parameters = ComponentViewParameters(self.theName,self.theSynopsis,[],[],[],[],[],self.theComponents,self.theConnectors)
   parameters.setId(self.theComponentViewId)
   return parameters