def addObjectToDialog(self,objtId,listId,dialogParameters):                                                           
    listCtrl = self.FindWindowById(self.listId)
    listRow = listCtrl.GetItemCount()
    newObjt = ObjectFactory.build(objtId,dialogParameters)

    if newObjt.__class__.__name__ == 'DocumentReference':
      selectedDocName = self.docCtrl.GetStringSelection()
      if (newObjt.document() != selectedDocName):
        return    
    
    self.addObjectRow(listCtrl,listRow,newObjt)
    if newObjt.__class__.__name__ == 'ClassAssociation':
      label = newObjt.environment() + '/' + newObjt.headAsset() + '/' + newObjt.tailAsset() 
      self.objts[label] = newObjt
    elif newObjt.__class__.__name__ == 'GoalAssociation':
      label = newObjt.environment() + '/' + newObjt.goal() + '/' + newObjt.subGoal() 
      self.objts[label] = newObjt
    elif newObjt.__class__.__name__ == 'Dependency':
      label = newObjt.environment() + '/' + newObjt.depender() + '/' + newObjt.dependee() + '/' + newObjt.dependency()
      self.objts[label] = newObjt
    elif newObjt.__class__.__name__ == 'PersonaCharacteristic':
      label = newObjt.persona() + '/' + newObjt.behaviouralVariable() + '/' + newObjt.characteristic()
      self.objts[label] = newObjt
    elif newObjt.__class__.__name__ == 'TaskCharacteristic':
      label = newObjt.task() + '/' + newObjt.characteristic()
      self.objts[label] = newObjt
    else:
      self.objts[newObjt.name()] = newObjt
      self.selectedLabel = newObjt.name()
    def __init__(self, SceneManager: SceneManager):
        super(ObjectManager, self).__init__()

        self.id = 0
        self.SceneManager = SceneManager
        self.factory = factory.ObjectFactory(SceneManager)
        self.instansiateSignal.connect(self.Instantiate)
  def updateDialogObject(self,objtId,listId,dialogParameters):                                                           
    if (self.__class__.__name__ == 'UseCasesDialog'):
      objtToGo = self.objts[self.listCtrl.selectedLabel()]
    elif (self.__class__.__name__ != 'DependenciesDialog' and self.__class__.__name__ != 'PersonaCharacteristicsDialog' and self.__class__.__name__ != 'TaskCharacteristicsDialog' and self.__class__.__name__ != 'BehaviouralCharacteristicsDialog'):
      objtToGo = self.objts[self.selectedLabel]
    else:
      objtToGo = self.objts[self.deprecatedLabel()]
    label = ''
    if objtToGo.__class__.__name__ == 'ClassAssociation':
      label = objtToGo.environment() + '/' + objtToGo.headAsset() + '/' + objtToGo.tailAsset() 
    elif objtToGo.__class__.__name__ == 'GoalAssociation':
      label = objtToGo.environment() + '/' + objtToGo.goal() + '/' + objtToGo.subGoal() 
    elif objtToGo.__class__.__name__ == 'Dependency':
      label = objtToGo.environment() + '/' + objtToGo.depender() + '/' + objtToGo.dependee() + '/' + objtToGo.dependency()
    elif objtToGo.__class__.__name__ == 'PersonaCharacteristic':
      label = objtToGo.persona() + '/' + objtToGo.behaviouralVariable() + '/' + objtToGo.characteristic()
    elif objtToGo.__class__.__name__ == 'TaskCharacteristic':
      label = objtToGo.task() + '/' + objtToGo.characteristic()
    else:
      label = objtToGo.name()
    del self.objts[label]

    listCtrl = self.FindWindowById(self.listId)
    listCtrl.DeleteItem(self.selectedIdx)
    updatedObjt = ObjectFactory.build(objtId,dialogParameters)
    self.addObjectRow(listCtrl,self.selectedIdx,updatedObjt)
    if ((updatedObjt.__class__.__name__ == 'ClassAssociation') or (updatedObjt.__class__.__name__ == 'GoalAssociation') or (updatedObjt.__class__.__name__ == 'Dependency') or (updatedObjt.__class__.__name__ == 'PersonaCharacteristic') or (updatedObjt.__class__.__name__ == 'TaskCharacteristic')):
      self.objts[label] = updatedObjt
    else:
      self.objts[updatedObjt.name()] = updatedObjt
    def addObjectToDialog(self, objtId, listId, dialogParameters):
        listCtrl = self.FindWindowById(self.listId)
        listRow = listCtrl.GetItemCount()
        newObjt = ObjectFactory.build(objtId, dialogParameters)

        if newObjt.__class__.__name__ == 'DocumentReference':
            selectedDocName = self.docCtrl.GetStringSelection()
            if (newObjt.document() != selectedDocName):
                return

        self.addObjectRow(listCtrl, listRow, newObjt)
        if newObjt.__class__.__name__ == 'ClassAssociation':
            label = newObjt.environment() + '/' + newObjt.headAsset(
            ) + '/' + newObjt.tailAsset()
            self.objts[label] = newObjt
        elif newObjt.__class__.__name__ == 'GoalAssociation':
            label = newObjt.environment() + '/' + newObjt.goal(
            ) + '/' + newObjt.subGoal()
            self.objts[label] = newObjt
        elif newObjt.__class__.__name__ == 'Dependency':
            label = newObjt.environment() + '/' + newObjt.depender(
            ) + '/' + newObjt.dependee() + '/' + newObjt.dependency()
            self.objts[label] = newObjt
        elif newObjt.__class__.__name__ == 'PersonaCharacteristic':
            label = newObjt.persona() + '/' + newObjt.behaviouralVariable(
            ) + '/' + newObjt.characteristic()
            self.objts[label] = newObjt
        elif newObjt.__class__.__name__ == 'TaskCharacteristic':
            label = newObjt.task() + '/' + newObjt.characteristic()
            self.objts[label] = newObjt
        else:
            self.objts[newObjt.name()] = newObjt
            self.selectedLabel = newObjt.name()
Exemple #5
0
 def updateDialogObject(self, objtId, listId, dialogParameters):
     objtToGo = self.traces[self.selectedIdx]
     del self.traces[self.selectedIdx]
     listCtrl = self.FindWindowById(self.listId)
     listCtrl.DeleteItem(self.selectedIdx)
     updatedObjt = ObjectFactory.build(-1, dialogParameters)
     self.addObjectRow(listCtrl, self.selectedIdx, updatedObjt)
     self.traces.insert(self.selectedIdx, updatedObjt)
Exemple #6
0
 def updateDialogObject(self,objtId,listId,dialogParameters):
   objtToGo = self.traces[self.selectedIdx]
   del self.traces[self.selectedIdx]
   listCtrl = self.FindWindowById(self.listId)
   listCtrl.DeleteItem(self.selectedIdx)
   updatedObjt = ObjectFactory.build(-1,dialogParameters)
   self.addObjectRow(listCtrl,self.selectedIdx,updatedObjt)
   self.traces.insert(self.selectedIdx,updatedObjt)
 def object(self):
     row = self.typedEntries[self.theSelectedIdx]
     p = None
     if (self.theDimensionName == 'vulnerability'):
         vulName = row[0]
         vulDesc = row[1] + '\n\n' + row[2]
         vulType = row[3]
         p = VulnerabilityParameters(vulName, vulDesc, vulType, [])
     else:
         thrName = row[0]
         thrMethod = row[1] + '\n\n' + row[2]
         thrType = row[3]
         p = ThreatParameters(thrName, thrType, thrMethod, [])
     return ObjectFactory.build(-1, p)
Exemple #8
0
 def object(self):
     row = self.typedEntries[self.theSelectedIdx]
     p = None
     if self.theDimensionName == "vulnerability":
         vulName = row[0]
         vulDesc = row[1] + "\n\n" + row[2]
         vulType = row[3]
         p = VulnerabilityParameters(vulName, vulDesc, vulType, [])
     else:
         thrName = row[0]
         thrMethod = row[1] + "\n\n" + row[2]
         thrType = row[3]
         p = ThreatParameters(thrName, thrType, thrMethod, [])
     return ObjectFactory.build(-1, p)
    def updateDialogObject(self, objtId, listId, dialogParameters):
        if (self.__class__.__name__ == 'UseCasesDialog'):
            objtToGo = self.objts[self.listCtrl.selectedLabel()]
        elif (self.__class__.__name__ != 'DependenciesDialog'
              and self.__class__.__name__ != 'PersonaCharacteristicsDialog'
              and self.__class__.__name__ != 'TaskCharacteristicsDialog' and
              self.__class__.__name__ != 'BehaviouralCharacteristicsDialog'):
            objtToGo = self.objts[self.selectedLabel]
        else:
            objtToGo = self.objts[self.deprecatedLabel()]
        label = ''
        if objtToGo.__class__.__name__ == 'ClassAssociation':
            label = objtToGo.environment() + '/' + objtToGo.headAsset(
            ) + '/' + objtToGo.tailAsset()
        elif objtToGo.__class__.__name__ == 'GoalAssociation':
            label = objtToGo.environment() + '/' + objtToGo.goal(
            ) + '/' + objtToGo.subGoal()
        elif objtToGo.__class__.__name__ == 'Dependency':
            label = objtToGo.environment() + '/' + objtToGo.depender(
            ) + '/' + objtToGo.dependee() + '/' + objtToGo.dependency()
        elif objtToGo.__class__.__name__ == 'PersonaCharacteristic':
            label = objtToGo.persona() + '/' + objtToGo.behaviouralVariable(
            ) + '/' + objtToGo.characteristic()
        elif objtToGo.__class__.__name__ == 'TaskCharacteristic':
            label = objtToGo.task() + '/' + objtToGo.characteristic()
        else:
            label = objtToGo.name()
        del self.objts[label]

        listCtrl = self.FindWindowById(self.listId)
        listCtrl.DeleteItem(self.selectedIdx)
        updatedObjt = ObjectFactory.build(objtId, dialogParameters)
        self.addObjectRow(listCtrl, self.selectedIdx, updatedObjt)
        if ((updatedObjt.__class__.__name__ == 'ClassAssociation')
                or (updatedObjt.__class__.__name__ == 'GoalAssociation')
                or (updatedObjt.__class__.__name__ == 'Dependency')
                or (updatedObjt.__class__.__name__ == 'PersonaCharacteristic')
                or (updatedObjt.__class__.__name__ == 'TaskCharacteristic')):
            self.objts[label] = updatedObjt
        else:
            self.objts[updatedObjt.name()] = updatedObjt
Exemple #10
0
 def addObjectToDialog(self, objtId, listId, dialogParameters):
     listCtrl = self.FindWindowById(self.listId)
     listRow = listCtrl.GetItemCount()
     newObjt = ObjectFactory.build(objtId, dialogParameters)
     self.addObjectRow(listCtrl, listRow, newObjt)
     self.traces.append(newObjt)
Exemple #11
0
 def addObjectToDialog(self,objtId,listId,dialogParameters):
   listCtrl = self.FindWindowById(self.listId)
   listRow = listCtrl.GetItemCount()
   newObjt = ObjectFactory.build(objtId,dialogParameters)
   self.addObjectRow(listCtrl,listRow,newObjt)
   self.traces.append(newObjt)
Exemple #12
0
class RiskDialog(wx.Dialog):
    def __init__(self, parent, parameters):
        wx.Dialog.__init__(self,
                           parent,
                           parameters.id(),
                           parameters.label(),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX
                           | wx.THICK_FRAME | wx.RESIZE_BORDER,
                           size=(400, 450))

        self.theRiskId = -1
        self.theMisuseCase = None
        self.theThreatName = ''
        self.theVulnerabilityName = ''
        self.theTags = []
        self.panel = 0
        self.buildControls(parameters)
        self.commitVerb = 'Create'

    def buildControls(self, parameters):
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.panel = RiskPanel(self)
        self.panel.buildControls(parameters.createFlag())
        mainSizer.Add(self.panel, 1, wx.EXPAND)
        self.SetSizer(mainSizer)
        wx.EVT_BUTTON(self, armid.RISK_BUTTONCOMMIT_ID, self.onCommit)
        wx.EVT_BUTTON(self, armid.RISK_BUTTONMISUSECASE_ID, self.onMisuseCase)

    def load(self, risk):
        self.theRiskId = risk.id()
        self.theMisuseCase = risk.misuseCase()
        self.panel.loadControls(risk)
        self.commitVerb = 'Edit'
        if (self.theMisuseCase != None):
            mcButton = self.FindWindowById(armid.RISK_BUTTONMISUSECASE_ID)
            mcButton.SetLabel('Edit Misuse Case')

    def onMisuseCase(self, evt):
        nameCtrl = self.FindWindowById(armid.RISK_TEXTNAME_ID)
        threatCtrl = self.FindWindowById(armid.RISK_COMBOTHREAT_ID)
        vulCtrl = self.FindWindowById(armid.RISK_COMBOVULNERABILITY_ID)

        riskName = nameCtrl.GetValue()
        if (self.commitVerb == 'Create'):
            b = Borg()
            try:
                b.dbProxy.nameCheck(riskName, 'risk')
            except ARM.ARMException, errorText:
                dlg = wx.MessageDialog(self, str(errorText), 'Add Misuse Case',
                                       wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
                return

        threatName = threatCtrl.GetStringSelection()
        vulnerabilityName = vulCtrl.GetStringSelection()

        commitLabel = self.commitVerb + ' risk'
        if len(riskName) == 0:
            dlg = wx.MessageDialog(self, 'No risk name entered', commitLabel,
                                   wx.OK)
            dlg.ShowModal()
            dlg.Destroy()
            return
        if len(threatName) == 0:
            dlg = wx.MessageDialog(self, 'No threat selected', commitLabel,
                                   wx.OK)
            dlg.ShowModal()
            dlg.Destroy()
            return
        elif (len(vulnerabilityName) == 0):
            dlg = wx.MessageDialog(self, 'No vulnerability selected',
                                   commitLabel, wx.OK)
            dlg.ShowModal()
            dlg.Destroy()
            return

        isCreate = False
        if (self.theMisuseCase == None):
            isCreate = True
        dlg = MisuseCaseDialog(self, isCreate)
        if (self.theMisuseCase != None):
            self.theMisuseCase.theThreatName = threatName
            self.theMisuseCase.theVulnerabilityName = vulnerabilityName
            dlg.loadMisuseCase(self.theMisuseCase)
        else:
            dlg.loadRiskComponents(riskName, threatName, vulnerabilityName)
        if (dlg.ShowModal() == armid.MISUSECASE_BUTTONCOMMIT_ID):
            if (self.theMisuseCase != None):
                self.theMisuseCase = ObjectFactory.build(
                    self.theMisuseCase.id(), dlg.parameters())
            else:
                self.theMisuseCase = ObjectFactory.build(-1, dlg.parameters())
            mcButton = self.FindWindowById(armid.RISK_BUTTONMISUSECASE_ID)
            mcButton.SetLabel('Edit Misuse Case')