예제 #1
0
 def onInheritEnvironment(self, evt):
     from DimensionNameDialog import DimensionNameDialog
     dimensions = self.dbProxy.getEnvironmentNames()
     dlg = DimensionNameDialog(self, 'environment', dimensions,
                               'Inherit from ')
     if (dlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
         self.theInheritedEnvironment = dlg.dimensionName()
         adddlg = DimensionNameDialog(self, 'environment', dimensions,
                                      'Add')
         if (adddlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
             idx = self.GetItemCount()
             self.InsertStringItem(idx, adddlg.dimensionName())
예제 #2
0
 def onRemovePattern(self,evt):
   countermeasure = self.theParentDialog.objts[self.theParentDialog.selectedLabel]
   cmId = countermeasure.id()
   try:
     b = Borg()
     dbProxy = b.dbProxy
     patterns = dbProxy.countermeasurePatterns(cmId)
     cDlg = DimensionNameDialog(self,'securitypattern',patterns,'Select')
     if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
       patternName = cDlg.dimensionName()
       patternId = dbProxy.getDimensionId(patternName,'securitypattern')
       spDeps = dbProxy.reportDependencies('securitypattern',cmId)
       if (len(spDeps) > 0):
         dlg = DependentsDialog(self,spDeps,'securitypattern')
         retValue = dlg.ShowModal()
         dlg.Destroy()
         if (retValue != DEPENDENTS_BUTTONCONFIRM_ID):
           cDlg.Destroy()
           return
         else:
           dbProxy.deleteDependencies(spDeps)
       dbProxy.deleteSituatedPattern(cmId,patternName)
     cDlg.Destroy()
   except ARMException,errorText:
     dlg = wx.MessageDialog(self,str(errorText),'Generate countermeasure asset',wx.OK | wx.ICON_ERROR)
     dlg.ShowModal()
     dlg.Destroy()
     return
예제 #3
0
 def onTurnToGoal(self, evt):
     b = Borg()
     p = b.dbProxy
     environments = p.getDimensionNames('environment', False)
     cDlg = DimensionNameDialog(self, 'environment', environments, 'Select')
     if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
         environmentName = cDlg.dimensionName()
         pos = self.GetGridCursorRow()
         table = self.GetTable()
         goalName = table.GetValue(pos, NAME_POS)
         goalDef = table.GetValue(pos, DESCRIPTION_POS)
         goalCat = 'Maintain'
         goalPri = table.GetValue(pos, PRIORITY_POS)
         goalFc = table.GetValue(pos, FITCRITERION_POS)
         goalIssue = table.GetValue(pos, RATIONALE_POS)
         goalOrig = table.GetValue(pos, ORIGINATOR_POS)
         goalAssets = [self.modCombo.GetValue()]
         dlg = ReqToGoalDialog(self, goalName, goalDef, goalCat, goalPri,
                               goalFc, goalIssue, goalOrig, goalAssets,
                               environmentName)
         if (dlg.ShowModal() == GOAL_BUTTONCOMMIT_ID):
             b = Borg()
             p = b.dbProxy
             p.addGoal(dlg.parameters())
             self.DeleteRows(pos)
         dlg.Destroy()
예제 #4
0
 def onAddDimension(self,evt):
   dimensions = self.dbProxy.getDimensionNames(self.theDimensionTable)
   from DimensionNameDialog import DimensionNameDialog
   dlg = DimensionNameDialog(self,self.theDimensionTable,dimensions,'Add')
   if (dlg.ShowModal() == armid.DIMNAME_BUTTONACTION_ID):
     for additionalDimension in dlg.dimensionNames():
       self.Append(additionalDimension)
예제 #5
0
 def onSelectSituate(self, evt):
     countermeasure = self.theParentDialog.objts[
         self.theParentDialog.selectedLabel]
     cmId = countermeasure.id()
     try:
         b = Borg()
         dbProxy = b.dbProxy
         patterns = dbProxy.getDimensionNames('securitypattern')
         cDlg = DimensionNameDialog(self, 'securitypattern', patterns,
                                    'Select')
         if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
             patternName = cDlg.dimensionName()
             patternId = dbProxy.getDimensionId(patternName,
                                                'securitypattern')
             spDlg = SecurityPatternEnvironmentDialog(
                 self, patternId, countermeasure.environments())
             if (spDlg.ShowModal() == SPENVIRONMENT_BUTTONCOMMIT_ID):
                 self.situatePattern(patternId, spDlg.assetEnvironments())
             spDlg.Destroy()
             dbProxy.addTrace('countermeasure_securitypattern', cmId,
                              patternId)
         cDlg.Destroy()
     except ARMException, errorText:
         dlg = wx.MessageDialog(self, str(errorText),
                                'Generate countermeasure asset',
                                wx.OK | wx.ICON_ERROR)
         dlg.ShowModal()
         dlg.Destroy()
         return
예제 #6
0
 def onAdd(self, evt):
     try:
         riskDict = self.dbProxy.getDimensionNames('risk')
         if (len(riskDict) == 0):
             dlg = wx.MessageDialog(
                 self, 'Cannot mitigate for non-existing risks',
                 'Add response', wx.OK)
             dlg.ShowModal()
             dlg.Destroy()
             return
         responseTypes = ['Accept', 'Transfer', 'Mitigate']
         from DimensionNameDialog import DimensionNameDialog
         rtDlg = DimensionNameDialog(self, 'response', responseTypes,
                                     'Select', (300, 200))
         if (rtDlg.ShowModal() == armid.DIMNAME_BUTTONACTION_ID):
             responseType = rtDlg.dimensionName()
             responsePanel = MitigateEnvironmentPanel
             if (responseType == 'Accept'):
                 responsePanel = AcceptEnvironmentPanel
             elif (responseType == 'Transfer'):
                 responsePanel = TransferEnvironmentPanel
             addParameters = ResponseDialogParameters(
                 armid.RESPONSE_ID, 'Add response', ResponseDialog,
                 armid.RESPONSE_BUTTONCOMMIT_ID, self.dbProxy.addResponse,
                 True, responsePanel, responseType)
             self.addObject(addParameters)
         rtDlg.Destroy()
     except ARM.ARMException, errorText:
         dlg = wx.MessageDialog(self, str(errorText), 'Add response',
                                wx.OK | wx.ICON_ERROR)
         dlg.ShowModal()
         dlg.Destroy()
         return
예제 #7
0
 def onAddDimension(self,evt):
   targetList = self.dbProxy.targetNames(self.theRiskList.GetItems())
   from DimensionNameDialog import DimensionNameDialog
   dlg = DimensionNameDialog(self,'Target',targetList,'Add')
   if (dlg.ShowModal() == armid.DIMNAME_BUTTONACTION_ID):
     additionalDimension = dlg.dimensionName()
     self.Append(additionalDimension)
     self.theSelectedValue = additionalDimension
예제 #8
0
 def onListAlphabet(self,evt):
   b = Borg()
   codes = b.dbProxy.getDimensionNames('code',False)
   cDlg = DimensionNameDialog(self,'code',codes,'Select')
   if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
     codeName = cDlg.dimensionName()
     self.addCode(codeName)
   cDlg.Destroy()
예제 #9
0
 def onAddDimension(self,evt):
   currentDimensions = self.dimensions()
   dimensions = self.dbProxy.riskEnvironmentNames(self.theCurrentRisk)
   remainingDimensions = [x for x in dimensions if x not in currentDimensions]
   from DimensionNameDialog import DimensionNameDialog
   dlg = DimensionNameDialog(self,self.theDimensionTable,remainingDimensions,'Add')
   if (dlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
     for additionalDimension in dlg.dimensionNames():
       idx = self.GetItemCount()
       self.InsertStringItem(idx,additionalDimension)
예제 #10
0
 def onReassociate(self, evt):
     b = Borg()
     p = b.dbProxy
     dimensions = p.getDimensionNames('asset')
     dlg = DimensionNameDialog(self, 'asset', dimensions, 'Select')
     if (dlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
         selectedAsset = dlg.dimensionName()
         reqTable = self.GetTable()
         selectedReq = reqTable.om.reqs[self.GetGridCursorRow()]
         p.reassociateAsset(selectedAsset, self.envCombo.GetValue(),
                            selectedReq.id())
         self.modCombo.SetStringSelection(selectedAsset)
     dlg.Destroy()
     self.envCombo.SetValue('')
     self.setTable(self.modCombo, self.envCombo)
     self.thePanel.refresh()
예제 #11
0
 def onAssociateSituated(self,evt):
   countermeasure = self.theParentDialog.objts[self.theParentDialog.selectedLabel]
   cmId = countermeasure.id()
   try:
     b = Borg()
     dbProxy = b.dbProxy
     patterns = dbProxy.candidateCountermeasurePatterns(cmId)
     cDlg = DimensionNameDialog(self,'securitypattern',patterns,'Select')
     if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
       patternName = cDlg.dimensionName()
       dbProxy.associateCountermeasureToPattern(cmId,patternName)
     cDlg.Destroy()
   except ARMException,errorText:
     dlg = wx.MessageDialog(self,str(errorText),'Generate countermeasure asset',wx.OK | wx.ICON_ERROR)
     dlg.ShowModal()
     dlg.Destroy()
     return
예제 #12
0
 def onSituate(self,evt):
   cvObjt = self.theParentDialog.objts[self.theParentDialog.selectedLabel]
   cvName = cvObjt.name()
   try:
     environments = self.dbProxy.getDimensionNames('environment',False)
     cDlg = DimensionNameDialog(self,'environment',environments,'Select')
     if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
       envName = cDlg.dimensionName()
       dlg = WeaknessAnalysisDialog(self,cvName,envName)
       if (dlg.ShowModal() == WEAKNESSANALYSIS_BUTTONCOMMIT_ID):
         self.situateComponentView(cvName,envName,dlg.targets(),dlg.goalObstacles())
       dlg.Destroy()
     cDlg.Destroy()
   except ARMException,errorText:
     dlg = wx.MessageDialog(self,str(errorText),'Situate component view',wx.OK | wx.ICON_ERROR)
     dlg.ShowModal()
     dlg.Destroy()
     return
예제 #13
0
 def onSelectGenerateFromTemplate(self,evt):
   countermeasure = self.theParentDialog.objts[self.theParentDialog.selectedLabel]
   cmId = countermeasure.id()
   try:
     b = Borg()
     dbProxy = b.dbProxy
     templateAssets = dbProxy.getDimensionNames('template_asset')
     cDlg = DimensionNameDialog(self,'template_asset',templateAssets,'Select')
     if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
       templateAssetName = cDlg.dimensionName()
       assetId = dbProxy.addAsset(cairis.core.AssetParametersFactory.buildFromTemplate(templateAssetName,countermeasure.environments()))
       dbProxy.addTrace('countermeasure_asset',cmId,assetId)
       cDlg.Destroy()
   except ARMException,errorText:
     dlg = wx.MessageDialog(self,str(errorText),'Generate countermeasure asset',wx.OK | wx.ICON_ERROR)
     dlg.ShowModal()
     dlg.Destroy()
     return
    def onAddDimension(self, evt):
        dimensions = self.dbProxy.getDimensionNames(self.theDimensionTable,
                                                    self.theCurrentEnvironment)
        from DimensionNameDialog import DimensionNameDialog
        dlg = DimensionNameDialog(self, self.theDimensionTable, dimensions,
                                  'Add')
        if (dlg.ShowModal() == armid.DIMNAME_BUTTONACTION_ID):
            newRoles = dlg.dimensionNames()
            for additionalDimension in newRoles:
                idx = self.GetItemCount()
                self.InsertStringItem(idx, additionalDimension)

            tpDict = self.dbProxy.roleTasks(self.theCurrentEnvironment,
                                            newRoles)

            noOfPersonas = self.thePersonaList.GetItemCount()
            if (noOfPersonas > 0):
                currentKeys = set([])
                for x in range(noOfPersonas):
                    listedTask = self.thePersonaList.GetItem(x, 0)
                    listedPersona = self.thePersonaList.GetItem(x, 1)
                    listedTuple = (listedTask.GetText(),
                                   listedPersona.GetText())
                    currentKeys.add(listedTuple)
                for personaDetails in tpDict.iteritems():
                    key = personaDetails[0]
                    value = personaDetails[1]
                    if ((key[0], key[1]) not in currentKeys):
                        self.thePersonaList.InsertStringItem(0, key[0])
                        self.thePersonaList.SetStringItem(0, 1, key[1])
                        self.thePersonaList.SetStringItem(0, 2, value[0])
                        self.thePersonaList.SetStringItem(0, 3, value[1])
                        self.thePersonaList.SetStringItem(0, 4, value[2])
                        self.thePersonaList.SetStringItem(0, 5, value[3])
            else:
                for personaDetails in tpDict.iteritems():
                    key = personaDetails[0]
                    value = personaDetails[1]
                    self.thePersonaList.InsertStringItem(0, key[0])
                    self.thePersonaList.SetStringItem(0, 1, key[1])
                    self.thePersonaList.SetStringItem(0, 2, value[0])
                    self.thePersonaList.SetStringItem(0, 3, value[1])
                    self.thePersonaList.SetStringItem(0, 4, value[2])
                    self.thePersonaList.SetStringItem(0, 5, value[3])
예제 #15
0
 def onUseCaseContribution(self,evt):
   ucName = self.GetItemText(self.theSelectedIdx)
   ucs  = self.dbProxy.getUseCaseContributions(ucName)
   ucKeys = ucs.keys()
   ucKeys.append('[New Contribution]')
   rsDlg = DimensionNameDialog(self,'usecase_contribution',ucKeys,'Select')
   if (rsDlg.ShowModal() == armid.DIMNAME_BUTTONACTION_ID):
     synName = rsDlg.dimensionName()
     rType = 'reference'
     if (synName != '[New Contribution]'):
       rc,rType = ucs[synName]
     else:
       rc = ReferenceContribution(ucName,'','','')
     dlg = UseCaseContributionDialog(self,rc,rType)
     if (dlg.ShowModal() == armid.REFERENCECONTRIBUTION_BUTTONCOMMIT_ID):
       if (rc.meansEnd() == ''):
         self.dbProxy.addUseCaseContribution(dlg.parameters())
       else:
         self.dbProxy.updateUseCaseContribution(dlg.parameters())
예제 #16
0
  def onSelectGenerate(self,evt):
    objt = self.theParentDialog.objts[self.theParentDialog.selectedLabel]
#    objtId = objt.id()
    try:
      b = Borg()
      dbProxy = b.dbProxy
      domains = dbProxy.getDimensionNames('domain',False)
      cDlg = DimensionNameDialog(self,'domain',domains,'Select')
      if (cDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
        domainName = cDlg.dimensionName()
        GoalRequirementFactory.build(objt,domainName,self.theParentDialog.theMainWindow)
# Change domain in panel
# Add requirement
# add goalrequirement_goalassociation
    except ARMException,errorText:
      dlg = wx.MessageDialog(self,str(errorText),'Generate goal requirement',wx.OK | wx.ICON_ERROR)
      dlg.ShowModal()
      dlg.Destroy()
      return
예제 #17
0
 def onSituate(self, evt):
     tAsset = self.theParentDialog.objts[self.theParentDialog.selectedLabel]
     taId = tAsset.id()
     taName = tAsset.name()
     try:
         b = Borg()
         dbProxy = b.dbProxy
         envs = dbProxy.getEnvironmentNames()
         cDlg = DimensionNameDialog(self, 'environment', envs, 'Select')
         if (cDlg.ShowModal() == armid.DIMNAME_BUTTONACTION_ID):
             sitEnvs = cDlg.dimensionNames()
             assetId = dbProxy.addAsset(
                 AssetParametersFactory.buildFromTemplate(taName, sitEnvs))
             # NB: we don't add anything to asset_template_asset, as we only use this table when the derived asset is part of a situated pattern
             cDlg.Destroy()
     except ARMException, errorText:
         dlg = wx.MessageDialog(self, str(errorText),
                                'Situate template asset',
                                wx.OK | wx.ICON_ERROR)
         dlg.ShowModal()
         dlg.Destroy()
         return
예제 #18
0
 def onAdd(self, evt):
     dims = self.dbProxy.getDimensionNames(self.theDimensionName, False)
     dlg = DimensionNameDialog(self, self.theDimensionName, dims, 'Select',
                               (300, 200))
     if (dlg.ShowModal() == armid.DIMNAME_BUTTONACTION_ID):
         self.dimList.Append(dlg.dimensionName())