def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent,
                          armid.COUNTERMEASURE_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.COUNTERMEASURE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)

        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        costBox = wx.StaticBox(self, -1, 'Cost')
        costBoxSizer = wx.StaticBoxSizer(costBox, wx.HORIZONTAL)
        environmentDimSizer.Add(costBoxSizer, 0, wx.EXPAND)
        self.costCombo = wx.ComboBox(self,
                                     armid.COUNTERMEASURE_COMBOCOST_ID,
                                     "",
                                     choices=['Low', 'Medium', 'High'],
                                     style=wx.CB_READONLY)
        costBoxSizer.Add(self.costCombo, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.HORIZONTAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = CountermeasureEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.reqList = self.notebook.FindWindowById(
            armid.COUNTERMEASURE_LISTREQUIREMENTS_ID)
        self.targetList = self.notebook.FindWindowById(
            armid.COUNTERMEASURE_LISTTARGETS_ID)
        self.propertiesList = self.notebook.FindWindowById(
            armid.COUNTERMEASURE_LISTPROPERTIES_ID)
        self.personaList = self.notebook.FindWindowById(
            armid.COUNTERMEASURE_LISTPERSONAS_ID)
        self.roleList = self.notebook.FindWindowById(
            armid.COUNTERMEASURE_LISTROLES_ID)

        self.reqList.Disable()
        self.targetList.Disable()
        self.propertiesList.Disable()
        self.costCombo.Disable()
        self.roleList.Disable()

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
예제 #2
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,ASSET_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theAssetId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,ASSETENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    dimBox = wx.StaticBox(self)
    environmentDimSizer = wx.StaticBoxSizer(dimBox,wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = AssetEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.propertiesList = self.notebook.FindWindowById(ASSETENVIRONMENT_LISTPROPERTIES_ID)
    self.associationCtrl = self.notebook.FindWindowById(ASSET_LISTASSOCIATIONS_ID)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

    self.propertiesList.Disable()
    self.associationCtrl.Disable()
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.PERSONA_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.thePersonaName = ''

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.PERSONA_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = PersonaEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.directCtrl = self.notebook.FindWindowById(armid.PERSONA_CHECKDIRECT_ID)
    self.roleList = self.notebook.FindWindowById(armid.PERSONA_LISTROLES_ID)
    self.descriptionCtrl = self.notebook.FindWindowById(armid.PERSONA_TEXTNARRATIVE_ID)
    self.directCtrl.Disable()
    self.descriptionCtrl.Disable()
    self.roleList.Disable() 
예제 #4
0
    def __init__(self, parent, goalDef, goalCat, goalPri, goalFc, goalIssue,
                 goalAssets, defaultEnv):
        wx.Panel.__init__(self, parent, GOAL_PANELENVIRONMENT_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theGoalId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1
        self.theGoalDefinition = goalDef
        self.theGoalCategory = goalCat
        self.theGoalPriority = goalPri
        self.theGoalFitCriterion = goalFc
        self.theGoalIssue = goalIssue
        self.theGoalAssets = goalAssets

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self,
                                                   GOAL_LISTENVIRONMENTS_ID,
                                                   self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = ReqToGoalNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.SetSizer(mainSizer)

        self.goalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTGOALREFINEMENTS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTSUBGOALREFINEMENTS_ID)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()

        self.theEnvironmentDictionary[defaultEnv] = GoalEnvironmentProperties(
            defaultEnv)
        self.environmentList.Select(0)
        self.goalAssociationCtrl.setEnvironment(defaultEnv)
        self.goalAssociationCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment(defaultEnv)
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
예제 #5
0
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, GOAL_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theGoalId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self,
                                                   GOAL_LISTENVIRONMENTS_ID,
                                                   self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = GoalEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.SetSizer(mainSizer)

        self.labelCtrl = self.notebook.FindWindowById(GOAL_TEXTLABEL_ID)
        self.definitionCtrl = self.notebook.FindWindowById(
            GOAL_TEXTDEFINITION_ID)
        self.categoryCtrl = self.notebook.FindWindowById(GOAL_COMBOCATEGORY_ID)
        self.priorityCtrl = self.notebook.FindWindowById(GOAL_COMBOPRIORITY_ID)
        self.fitCriterionCtrl = self.notebook.FindWindowById(
            GOAL_TEXTFITCRITERION_ID)
        self.issueCtrl = self.notebook.FindWindowById(GOAL_TEXTISSUE_ID)
        self.goalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTGOALREFINEMENTS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTSUBGOALREFINEMENTS_ID)
        self.cCtrl = self.notebook.FindWindowById(GOAL_LISTCONCERNS_ID)
        self.caCtrl = self.notebook.FindWindowById(
            GOAL_LISTCONCERNASSOCIATIONS_ID)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.definitionCtrl.Disable()
        self.categoryCtrl.Disable()
        self.priorityCtrl.Disable()
        self.fitCriterionCtrl.Disable()
        self.issueCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.cCtrl.Disable()
        self.caCtrl.Disable()
예제 #6
0
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, TASK_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theTaskId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self,
                                                   TASK_LISTENVIRONMENTS_ID,
                                                   self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbBoxSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbBoxSizer, 1, wx.EXPAND)
        self.notebook = TaskEnvironmentNotebook(self, self.dbProxy)
        nbBoxSizer.Add(self.notebook, 1, wx.EXPAND)

        self.dependenciesCtrl = self.notebook.FindWindowById(
            TASK_TEXTDEPENDENCIES_ID)
        self.personaList = self.notebook.FindWindowById(TASK_LISTPERSONAS_ID)
        self.assetList = self.notebook.FindWindowById(TASK_LISTASSETS_ID)
        self.caList = self.notebook.FindWindowById(
            TASK_LISTCONCERNASSOCIATIONS_ID)
        self.narrativeCtrl = self.notebook.FindWindowById(
            TASK_TEXTNARRATIVE_ID)
        self.consequencesCtrl = self.notebook.FindWindowById(
            TASK_TEXTCONSEQUENCES_ID)
        self.benefitsCtrl = self.notebook.FindWindowById(TASK_TEXTBENEFITS_ID)

        self.SetSizer(mainSizer)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
        self.dependenciesCtrl.Disable()
        self.personaList.Disable()
        self.assetList.Disable()
        self.caList.Disable()
        self.narrativeCtrl.Disable()
        self.consequencesCtrl.Disable()
        self.benefitsCtrl.Disable()

        self.theDimMenu = wx.Menu()
        self.theDimMenu.Append(DIMLIST_MENUADD_ID, 'Add Goal')
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
        wx.EVT_MENU(self.theDimMenu, DIMLIST_MENUADD_ID, self.onAddGoal)
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, armid.MISUSECASE_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1
        self.theSelectedRisk = ''
        self.theSelectedThreat = ''
        self.theSelectedVulnerability = ''

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.MISUSECASE_LISTENVIRONMENTS_ID, self.dbProxy)
        self.environmentList.Unbind(wx.EVT_RIGHT_DOWN)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = MisuseCaseNotebook(self)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.SetSizer(mainSizer)

        self.objectiveCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTOBJECTIVE_ID)
        self.attackerList = self.notebook.FindWindowById(
            armid.MISUSECASE_LISTATTACKERS_ID)
        self.assetList = self.notebook.FindWindowById(
            armid.MISUSECASE_LISTASSETS_ID)
        self.threatCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTTHREAT_ID)
        self.lhoodCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTLIKELIHOOD_ID)
        self.vulCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTVULNERABILITY_ID)
        self.sevCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTSEVERITY_ID)
        self.ratingCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTSCORE_ID)
        self.narrativeCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTNARRATIVE_ID)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.narrativeCtrl.Disable()
예제 #8
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,THREAT_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theThreatId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,THREATENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)

    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    lhoodBox = wx.StaticBox(self)
    lhoodSizer = wx.StaticBoxSizer(lhoodBox,wx.HORIZONTAL)
    environmentDimSizer.Add(lhoodSizer,0,wx.EXPAND)
    lhoodSizer.Add(wx.StaticText(self,-1,'Likelihood'))
    lhoodList = ['Incredible','Improbable','Remote','Occasional','Probable','Frequent']
    self.lhoodCtrl = wx.ComboBox(self,THREATENVIRONMENT_COMBOLIKELIHOOD_ID,choices=lhoodList,size=wx.DefaultSize,style=wx.CB_READONLY)
    lhoodSizer.Add(self.lhoodCtrl,1,wx.EXPAND) 

    aaSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(aaSizer,1,wx.EXPAND)
    self.attackerList = DimensionListCtrl(self,THREATENVIRONMENT_LISTATTACKERS_ID,wx.DefaultSize,'Attacker','attacker',self.dbProxy)
    attackerBox = wx.StaticBox(self)
    attackerSizer = wx.StaticBoxSizer(attackerBox,wx.HORIZONTAL)
    attackerSizer.Add(self.attackerList,1,wx.EXPAND)
    aaSizer.Add(attackerSizer,1,wx.EXPAND)

    self.assetList = DimensionListCtrl(self,THREATENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
    assetBox = wx.StaticBox(self)
    assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
    assetSizer.Add(self.assetList,1,wx.EXPAND)
    aaSizer.Add(assetSizer,1,wx.EXPAND)

    propertiesBox = wx.StaticBox(self)
    propertiesSizer = wx.StaticBoxSizer(propertiesBox,wx.HORIZONTAL)
    environmentDimSizer.Add(propertiesSizer,1,wx.EXPAND)
    values = self.dbProxy.getDimensionNames('threat_value')
    valueLookup = ValueDictionary(values)
    self.propertiesList = PropertiesListCtrl(self,THREATENVIRONMENT_LISTPROPERTIES_ID,valueLookup)
    propertiesSizer.Add(self.propertiesList,1,wx.EXPAND)
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent,
                          armid.VULNERABILITY_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theVulId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.VULNERABILITYENVIRONMENT_LISTENVIRONMENTS_ID,
            self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)

        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        sevBox = wx.StaticBox(self)
        sevSizer = wx.StaticBoxSizer(sevBox, wx.HORIZONTAL)
        environmentDimSizer.Add(sevSizer, 0, wx.EXPAND)
        sevSizer.Add(wx.StaticText(self, -1, 'Severity'))
        sevList = ['Negligible', 'Marginal', 'Critical', 'Catastrophic']
        self.sevCtrl = wx.ComboBox(
            self,
            armid.VULNERABILITYENVIRONMENT_COMBOSEVERITY_ID,
            choices=sevList,
            size=wx.DefaultSize,
            style=wx.CB_READONLY)
        sevSizer.Add(self.sevCtrl, 1, wx.EXPAND)

        aSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentDimSizer.Add(aSizer, 1, wx.EXPAND)
        self.assetList = DimensionListCtrl(
            self, armid.VULNERABILITYENVIRONMENT_LISTASSETS_ID, wx.DefaultSize,
            'Asset', 'asset', self.dbProxy)
        assetBox = wx.StaticBox(self)
        assetSizer = wx.StaticBoxSizer(assetBox, wx.HORIZONTAL)
        assetSizer.Add(self.assetList, 1, wx.EXPAND)
        aSizer.Add(assetSizer, 1, wx.EXPAND)

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
예제 #10
0
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, OBSTACLE_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theObstacleId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, OBSTACLE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = ObstacleEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.labelCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTLABEL_ID)
        self.probCtrl = self.notebook.FindWindowById(
            OBSTACLE_TEXTPROBABILITY_ID)
        self.categoryCtrl = self.notebook.FindWindowById(
            OBSTACLE_COMBOCATEGORY_ID)
        self.definitionCtrl = self.notebook.FindWindowById(
            OBSTACLE_TEXTDEFINITION_ID)
        self.goalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTGOALS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTSUBGOALS_ID)
        self.concernsCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTCONCERNS_ID)

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.categoryCtrl.Disable()
        self.definitionCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.concernsCtrl.Disable()
예제 #11
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.TRANSFER_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.TRANSFER_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    roleBox = wx.StaticBox(self,-1)
    roleBoxSizer = wx.StaticBoxSizer(roleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(roleBoxSizer,0,wx.EXPAND)
    self.roleList = RoleCostListCtrl(self,armid.TRANSFER_LISTROLES_ID)
    roleBoxSizer.Add(self.roleList,1,wx.EXPAND)

    rationaleBox = wx.StaticBox(self,-1,'Rationale')
    rationaleBoxSizer = wx.StaticBoxSizer(rationaleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(rationaleBoxSizer,1,wx.EXPAND)
    self.rationaleCtrl = wx.TextCtrl(self,armid.TRANSFER_TEXTRATIONALE_ID,'',style=wx.TE_MULTILINE)
    rationaleBoxSizer.Add(self.rationaleCtrl,1,wx.EXPAND)
    self.roleList.Disable()
    self.rationaleCtrl.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
예제 #12
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.ACCEPT_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.ACCEPT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    costBox = wx.StaticBox(self,-1,'Cost')
    costBoxSizer = wx.StaticBoxSizer(costBox,wx.HORIZONTAL)
    environmentDimSizer.Add(costBoxSizer,0,wx.EXPAND)
    self.costCombo = wx.ComboBox(self,armid.ACCEPT_COMBOCOST_ID,"",choices=['Low','Medium','High'],style=wx.CB_READONLY)
    costBoxSizer.Add(self.costCombo,0,wx.EXPAND)
   
    rationaleBox = wx.StaticBox(self,-1,'Rationale')
    rationaleBoxSizer = wx.StaticBoxSizer(rationaleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(rationaleBoxSizer,1,wx.EXPAND)
    self.rationaleCtrl = wx.TextCtrl(self,armid.ACCEPT_TEXTRATIONALE_ID,'',style=wx.TE_MULTILINE)
    rationaleBoxSizer.Add(self.rationaleCtrl,1,wx.EXPAND)
    self.costCombo.Disable() 
    self.rationaleCtrl.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
예제 #13
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, armid.USECASE_PANELENVIRONMENT_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theUseCaseId = None
        self.theUseCaseName = ''
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.USECASE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbBoxSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbBoxSizer, 1, wx.EXPAND)
        self.notebook = UseCaseEnvironmentNotebook(self, self.dbProxy)
        nbBoxSizer.Add(self.notebook, 1, wx.EXPAND)

        self.preCondCtrl = self.notebook.FindWindowById(
            armid.USECASE_TEXTPRECONDITION_ID)
        self.postCondCtrl = self.notebook.FindWindowById(
            armid.USECASE_TEXTPOSTCONDITION_ID)
        self.stepsCtrl = self.notebook.FindWindowById(
            armid.USECASE_PANELFLOW_ID)

        self.SetSizer(mainSizer)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
예제 #14
0
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, ATTACKER_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theAttackerId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, ATTACKERENVIRONMENT_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)
        rmSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentDimSizer.Add(rmSizer, 1, wx.EXPAND)
        self.roleList = DimensionListCtrl(self,
                                          ATTACKERENVIRONMENT_LISTROLES_ID,
                                          wx.DefaultSize, 'Role', 'role',
                                          self.dbProxy)
        roleBox = wx.StaticBox(self)
        roleSizer = wx.StaticBoxSizer(roleBox, wx.HORIZONTAL)
        roleSizer.Add(self.roleList, 1, wx.EXPAND)
        rmSizer.Add(roleSizer, 1, wx.EXPAND)

        self.motiveList = DimensionListCtrl(
            self, ATTACKERENVIRONMENT_LISTMOTIVES_ID, wx.DefaultSize, 'Motive',
            'motivation', self.dbProxy)
        motiveBox = wx.StaticBox(self)
        motiveSizer = wx.StaticBoxSizer(motiveBox, wx.HORIZONTAL)
        motiveSizer.Add(self.motiveList, 1, wx.EXPAND)
        rmSizer.Add(motiveSizer, 1, wx.EXPAND)
        capBox = wx.StaticBox(self)
        capSizer = wx.StaticBoxSizer(capBox, wx.HORIZONTAL)
        environmentDimSizer.Add(capSizer, 1, wx.EXPAND)
        self.capabilitiesList = CapabilitiesListCtrl(
            self, ATTACKERENVIRONMENT_LISTCAPABILITIES_ID, self.dbProxy)
        capSizer.Add(self.capabilitiesList, 1, wx.EXPAND)
        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
예제 #15
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,THREAT_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theThreatId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,THREATENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)

    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    lhoodBox = wx.StaticBox(self)
    lhoodSizer = wx.StaticBoxSizer(lhoodBox,wx.HORIZONTAL)
    environmentDimSizer.Add(lhoodSizer,0,wx.EXPAND)
    lhoodSizer.Add(wx.StaticText(self,-1,'Likelihood'))
    lhoodList = ['Incredible','Improbable','Remote','Occasional','Probable','Frequent']
    self.lhoodCtrl = wx.ComboBox(self,THREATENVIRONMENT_COMBOLIKELIHOOD_ID,choices=lhoodList,size=wx.DefaultSize,style=wx.CB_READONLY)
    lhoodSizer.Add(self.lhoodCtrl,1,wx.EXPAND) 

    aaSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(aaSizer,1,wx.EXPAND)
    self.attackerList = DimensionListCtrl(self,THREATENVIRONMENT_LISTATTACKERS_ID,wx.DefaultSize,'Attacker','attacker',self.dbProxy)
    attackerBox = wx.StaticBox(self)
    attackerSizer = wx.StaticBoxSizer(attackerBox,wx.HORIZONTAL)
    attackerSizer.Add(self.attackerList,1,wx.EXPAND)
    aaSizer.Add(attackerSizer,1,wx.EXPAND)

    self.assetList = DimensionListCtrl(self,THREATENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
    assetBox = wx.StaticBox(self)
    assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
    assetSizer.Add(self.assetList,1,wx.EXPAND)
    aaSizer.Add(assetSizer,1,wx.EXPAND)

    propertiesBox = wx.StaticBox(self)
    propertiesSizer = wx.StaticBoxSizer(propertiesBox,wx.HORIZONTAL)
    environmentDimSizer.Add(propertiesSizer,1,wx.EXPAND)
    values = self.dbProxy.getDimensionNames('threat_value')
    valueLookup = ValueDictionary(values)
    self.propertiesList = PropertiesListCtrl(self,THREATENVIRONMENT_LISTPROPERTIES_ID,valueLookup)
    propertiesSizer.Add(self.propertiesList,1,wx.EXPAND)
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
  def __init__(self,parent,goalDef,goalCat,goalPri,goalFc,goalIssue,goalAssets,defaultEnv):
    wx.Panel.__init__(self,parent,armid.GOAL_PANELENVIRONMENT_ID)
    b = Borg()
    self.dbProxy = b.dbProxy
    self.theGoalId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.theGoalDefinition = goalDef
    self.theGoalCategory = goalCat
    self.theGoalPriority = goalPri
    self.theGoalFitCriterion = goalFc
    self.theGoalIssue = goalIssue
    self.theGoalAssets = goalAssets

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.GOAL_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = ReqToGoalNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)

    self.goalAssociationCtrl = self.notebook.FindWindowById(armid.GOAL_LISTGOALREFINEMENTS_ID)
    self.subGoalAssociationCtrl = self.notebook.FindWindowById(armid.GOAL_LISTSUBGOALREFINEMENTS_ID)

    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()

    self.theEnvironmentDictionary[defaultEnv] = GoalEnvironmentProperties(defaultEnv)
    self.environmentList.Select(0)
    self.goalAssociationCtrl.setEnvironment(defaultEnv)
    self.goalAssociationCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment(defaultEnv)
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()
예제 #17
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,GOAL_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theGoalId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,GOAL_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = GoalEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)

    self.labelCtrl = self.notebook.FindWindowById(GOAL_TEXTLABEL_ID)
    self.definitionCtrl = self.notebook.FindWindowById(GOAL_TEXTDEFINITION_ID)
    self.categoryCtrl = self.notebook.FindWindowById(GOAL_COMBOCATEGORY_ID)
    self.priorityCtrl = self.notebook.FindWindowById(GOAL_COMBOPRIORITY_ID)
    self.fitCriterionCtrl = self.notebook.FindWindowById(GOAL_TEXTFITCRITERION_ID)
    self.issueCtrl = self.notebook.FindWindowById(GOAL_TEXTISSUE_ID)
    self.goalAssociationCtrl = self.notebook.FindWindowById(GOAL_LISTGOALREFINEMENTS_ID)
    self.subGoalAssociationCtrl = self.notebook.FindWindowById(GOAL_LISTSUBGOALREFINEMENTS_ID)
    self.cCtrl = self.notebook.FindWindowById(GOAL_LISTCONCERNS_ID)
    self.caCtrl = self.notebook.FindWindowById(GOAL_LISTCONCERNASSOCIATIONS_ID)

    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.definitionCtrl.Disable()
    self.categoryCtrl.Disable()
    self.priorityCtrl.Disable()
    self.fitCriterionCtrl.Disable()
    self.issueCtrl.Disable()
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()
    self.cCtrl.Disable()
    self.caCtrl.Disable()
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.COUNTERMEASURE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.COUNTERMEASURE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)


    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
 
    costBox = wx.StaticBox(self,-1,'Cost')
    costBoxSizer = wx.StaticBoxSizer(costBox,wx.HORIZONTAL)
    environmentDimSizer.Add(costBoxSizer,0,wx.EXPAND)
    self.costCombo = wx.ComboBox(self,armid.COUNTERMEASURE_COMBOCOST_ID,"",choices=['Low','Medium','High'],style=wx.CB_READONLY)
    costBoxSizer.Add(self.costCombo,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = CountermeasureEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.reqList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTREQUIREMENTS_ID)
    self.targetList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTTARGETS_ID)
    self.propertiesList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTPROPERTIES_ID)
    self.personaList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTPERSONAS_ID)
    self.roleList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTROLES_ID)

    self.reqList.Disable()
    self.targetList.Disable()
    self.propertiesList.Disable()
    self.costCombo.Disable()
    self.roleList.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
예제 #19
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,TASK_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theTaskId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,TASK_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbBoxSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbBoxSizer,1,wx.EXPAND)
    self.notebook = TaskEnvironmentNotebook(self,self.dbProxy)
    nbBoxSizer.Add(self.notebook,1,wx.EXPAND)

    self.dependenciesCtrl = self.notebook.FindWindowById(TASK_TEXTDEPENDENCIES_ID)
    self.personaList = self.notebook.FindWindowById(TASK_LISTPERSONAS_ID)
    self.assetList = self.notebook.FindWindowById(TASK_LISTASSETS_ID)
    self.caList = self.notebook.FindWindowById(TASK_LISTCONCERNASSOCIATIONS_ID)
    self.narrativeCtrl = self.notebook.FindWindowById(TASK_TEXTNARRATIVE_ID)
    self.consequencesCtrl = self.notebook.FindWindowById(TASK_TEXTCONSEQUENCES_ID)
    self.benefitsCtrl = self.notebook.FindWindowById(TASK_TEXTBENEFITS_ID)

    self.SetSizer(mainSizer)

    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.dependenciesCtrl.Disable()
    self.personaList.Disable() 
    self.assetList.Disable() 
    self.caList.Disable()
    self.narrativeCtrl.Disable()
    self.consequencesCtrl.Disable()
    self.benefitsCtrl.Disable()

    self.theDimMenu = wx.Menu()
    self.theDimMenu.Append(DIMLIST_MENUADD_ID,'Add Goal')
    self.Bind(wx.EVT_RIGHT_DOWN,self.OnRightDown)
    wx.EVT_MENU(self.theDimMenu,DIMLIST_MENUADD_ID,self.onAddGoal)
예제 #20
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.MITIGATE_PANELENVIRONMENT_ID)
    self.theResponsePanel = parent
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.MITIGATE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    typeBox = wx.StaticBox(self,-1,'Type')
    typeBoxSizer = wx.StaticBoxSizer(typeBox,wx.HORIZONTAL)
    environmentDimSizer.Add(typeBoxSizer,0,wx.EXPAND)
    self.typeCombo = wx.ComboBox(self,armid.MITIGATE_COMBOTYPE_ID,"",choices=['Deter','Prevent','Detect','React'],style=wx.CB_READONLY)
    typeBoxSizer.Add(self.typeCombo,1,wx.EXPAND)
   
    pointBox = wx.StaticBox(self,-1,'Detection Point')
    pointBoxSizer = wx.StaticBoxSizer(pointBox,wx.HORIZONTAL)
    environmentDimSizer.Add(pointBoxSizer,0,wx.EXPAND)
    self.pointCombo = wx.ComboBox(self,armid.MITIGATE_COMBODETECTIONPOINT_ID,"",choices=['Before','At','After'],style=wx.CB_READONLY)
    pointBoxSizer.Add(self.pointCombo,1,wx.EXPAND)


    dmBox = wx.StaticBox(self,-1,)
    dmBoxSizer = wx.StaticBoxSizer(dmBox,wx.HORIZONTAL)
    environmentDimSizer.Add(dmBoxSizer,1,wx.EXPAND)
    self.dmList = DimensionListCtrl(self,armid.MITIGATE_LISTDETMECH_ID,wx.DefaultSize,'Detection Mechanism','detection_mechanism',self.dbProxy,listStyle=wx.LC_REPORT)
    dmBoxSizer.Add(self.dmList,1,wx.EXPAND)

    self.typeCombo.Disable()
    self.pointCombo.Disable() 
    self.dmList.Disable()
    
    self.SetSizer(mainSizer)
    self.typeCombo.Bind(wx.EVT_COMBOBOX,self.onTypeChange)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,MISUSECASE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.theSelectedRisk = ''
    self.theSelectedThreat = ''
    self.theSelectedVulnerability = ''

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,MISUSECASE_LISTENVIRONMENTS_ID,self.dbProxy)
    self.environmentList.Unbind(wx.EVT_RIGHT_DOWN)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = MisuseCaseNotebook(self)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)

    self.objectiveCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTOBJECTIVE_ID)
    self.attackerList = self.notebook.FindWindowById(MISUSECASE_LISTATTACKERS_ID)
    self.assetList = self.notebook.FindWindowById(MISUSECASE_LISTASSETS_ID)
    self.threatCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTTHREAT_ID)
    self.lhoodCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTLIKELIHOOD_ID)
    self.vulCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTVULNERABILITY_ID)
    self.sevCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTSEVERITY_ID)
    self.ratingCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTSCORE_ID)
    self.narrativeCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTNARRATIVE_ID)


    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.narrativeCtrl.Disable()
예제 #22
0
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,OBSTACLE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theObstacleId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,OBSTACLE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = ObstacleEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.labelCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTLABEL_ID)
    self.probCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTPROBABILITY_ID)
    self.categoryCtrl = self.notebook.FindWindowById(OBSTACLE_COMBOCATEGORY_ID)
    self.definitionCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTDEFINITION_ID)
    self.goalAssociationCtrl = self.notebook.FindWindowById(OBSTACLE_LISTGOALS_ID)
    self.subGoalAssociationCtrl = self.notebook.FindWindowById(OBSTACLE_LISTSUBGOALS_ID)
    self.concernsCtrl = self.notebook.FindWindowById(OBSTACLE_LISTCONCERNS_ID)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.categoryCtrl.Disable()
    self.definitionCtrl.Disable()
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()
    self.concernsCtrl.Disable()
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, USECASE_PANELENVIRONMENT_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theUseCaseId = None
        self.theUseCaseName = ""
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self, USECASE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbBoxSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbBoxSizer, 1, wx.EXPAND)
        self.notebook = UseCaseEnvironmentNotebook(self, self.dbProxy)
        nbBoxSizer.Add(self.notebook, 1, wx.EXPAND)

        self.preCondCtrl = self.notebook.FindWindowById(USECASE_TEXTPRECONDITION_ID)
        self.postCondCtrl = self.notebook.FindWindowById(USECASE_TEXTPOSTCONDITION_ID)
        self.stepsCtrl = self.notebook.FindWindowById(USECASE_PANELFLOW_ID)

        self.SetSizer(mainSizer)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM, self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnDeleteEnvironment)
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnEnvironmentDeselected)
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.ATTACKER_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theAttackerId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.ATTACKERENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
    rmSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(rmSizer,1,wx.EXPAND)
    self.roleList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTROLES_ID,wx.DefaultSize,'Role','role',self.dbProxy)
    roleBox = wx.StaticBox(self)
    roleSizer = wx.StaticBoxSizer(roleBox,wx.HORIZONTAL)
    roleSizer.Add(self.roleList,1,wx.EXPAND)
    rmSizer.Add(roleSizer,1,wx.EXPAND)

    self.motiveList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTMOTIVES_ID,wx.DefaultSize,'Motive','motivation',self.dbProxy)
    motiveBox = wx.StaticBox(self)
    motiveSizer = wx.StaticBoxSizer(motiveBox,wx.HORIZONTAL)
    motiveSizer.Add(self.motiveList,1,wx.EXPAND)
    rmSizer.Add(motiveSizer,1,wx.EXPAND)
    capBox = wx.StaticBox(self)
    capSizer = wx.StaticBoxSizer(capBox,wx.HORIZONTAL)
    environmentDimSizer.Add(capSizer,1,wx.EXPAND)
    self.capabilitiesList = CapabilitiesListCtrl(self,armid.ATTACKERENVIRONMENT_LISTCAPABILITIES_ID,self.dbProxy)
    capSizer.Add(self.capabilitiesList,1,wx.EXPAND)
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.VULNERABILITY_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theVulId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)

    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    sevBox = wx.StaticBox(self)
    sevSizer = wx.StaticBoxSizer(sevBox,wx.HORIZONTAL)
    environmentDimSizer.Add(sevSizer,0,wx.EXPAND)
    sevSizer.Add(wx.StaticText(self,-1,'Severity'))
    sevList = ['Negligible','Marginal','Critical','Catastrophic']
    self.sevCtrl = wx.ComboBox(self,armid.VULNERABILITYENVIRONMENT_COMBOSEVERITY_ID,choices=sevList,size=wx.DefaultSize,style=wx.CB_READONLY)
    sevSizer.Add(self.sevCtrl,1,wx.EXPAND) 

    aSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(aSizer,1,wx.EXPAND)
    self.assetList = DimensionListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
    assetBox = wx.StaticBox(self)
    assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
    assetSizer.Add(self.assetList,1,wx.EXPAND)
    aSizer.Add(assetSizer,1,wx.EXPAND)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
예제 #26
0
class AttackerEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, ATTACKER_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theAttackerId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, ATTACKERENVIRONMENT_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)
        rmSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentDimSizer.Add(rmSizer, 1, wx.EXPAND)
        self.roleList = DimensionListCtrl(self,
                                          ATTACKERENVIRONMENT_LISTROLES_ID,
                                          wx.DefaultSize, 'Role', 'role',
                                          self.dbProxy)
        roleBox = wx.StaticBox(self)
        roleSizer = wx.StaticBoxSizer(roleBox, wx.HORIZONTAL)
        roleSizer.Add(self.roleList, 1, wx.EXPAND)
        rmSizer.Add(roleSizer, 1, wx.EXPAND)

        self.motiveList = DimensionListCtrl(
            self, ATTACKERENVIRONMENT_LISTMOTIVES_ID, wx.DefaultSize, 'Motive',
            'motivation', self.dbProxy)
        motiveBox = wx.StaticBox(self)
        motiveSizer = wx.StaticBoxSizer(motiveBox, wx.HORIZONTAL)
        motiveSizer.Add(self.motiveList, 1, wx.EXPAND)
        rmSizer.Add(motiveSizer, 1, wx.EXPAND)
        capBox = wx.StaticBox(self)
        capSizer = wx.StaticBoxSizer(capBox, wx.HORIZONTAL)
        environmentDimSizer.Add(capSizer, 1, wx.EXPAND)
        self.capabilitiesList = CapabilitiesListCtrl(
            self, ATTACKERENVIRONMENT_LISTCAPABILITIES_ID, self.dbProxy)
        capSizer.Add(self.capabilitiesList, 1, wx.EXPAND)
        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

    def loadControls(self, attacker):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theAttackerId = attacker.id()
        environmentNames = []
        for cp in attacker.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in attacker.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]
        self.roleList.setEnvironment(environmentName)
        self.roleList.load(p.roles())
        self.motiveList.setEnvironment(environmentName)
        self.motiveList.load(p.motives())
        self.capabilitiesList.setEnvironment(environmentName)
        self.capabilitiesList.load(p.capabilities())
        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]
        self.roleList.setEnvironment(environmentName)
        self.roleList.load(p.roles())
        self.motiveList.setEnvironment(environmentName)
        self.motiveList.load(p.motives())
        self.capabilitiesList.setEnvironment(environmentName)
        self.capabilitiesList.load(p.capabilities())

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = AttackerEnvironmentProperties(
                environmentName, self.roleList.dimensions(),
                self.motiveList.dimensions(),
                self.capabilitiesList.capabilities())

        self.roleList.setEnvironment('')
        self.roleList.DeleteAllItems()
        self.motiveList.setEnvironment('')
        self.motiveList.DeleteAllItems()
        self.capabilitiesList.setEnvironment('')
        self.capabilitiesList.DeleteAllItems()
        self.theSelectedIdx = -1

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = AttackerEnvironmentProperties(
                environmentName, [], [], [])
        self.environmentList.Select(self.theSelectedIdx)
        self.capabilitiesList.setEnvironment(environmentName)
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if (inheritedEnv != '' and self.theAttackerId != None):
            p = self.dbProxy.inheritedAttackerProperties(
                self.theAttackerId, inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.roleList.setEnvironment(environmentName)
            self.roleList.load(p.roles())
            self.motiveList.setEnvironment(environmentName)
            self.motiveList.load(p.motives())
            self.capabilitiesList.setEnvironment(environmentName)
            self.capabilitiesList.load(p.capabilities())

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            self.theEnvironmentDictionary[
                environmentName] = AttackerEnvironmentProperties(
                    environmentName, self.roleList.dimensions(),
                    self.motiveList.dimensions(),
                    self.capabilitiesList.capabilities())
        return self.theEnvironmentDictionary.values()
class VulnerabilityEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent,
                          armid.VULNERABILITY_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theVulId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.VULNERABILITYENVIRONMENT_LISTENVIRONMENTS_ID,
            self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)

        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        sevBox = wx.StaticBox(self)
        sevSizer = wx.StaticBoxSizer(sevBox, wx.HORIZONTAL)
        environmentDimSizer.Add(sevSizer, 0, wx.EXPAND)
        sevSizer.Add(wx.StaticText(self, -1, 'Severity'))
        sevList = ['Negligible', 'Marginal', 'Critical', 'Catastrophic']
        self.sevCtrl = wx.ComboBox(
            self,
            armid.VULNERABILITYENVIRONMENT_COMBOSEVERITY_ID,
            choices=sevList,
            size=wx.DefaultSize,
            style=wx.CB_READONLY)
        sevSizer.Add(self.sevCtrl, 1, wx.EXPAND)

        aSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentDimSizer.Add(aSizer, 1, wx.EXPAND)
        self.assetList = DimensionListCtrl(
            self, armid.VULNERABILITYENVIRONMENT_LISTASSETS_ID, wx.DefaultSize,
            'Asset', 'asset', self.dbProxy)
        assetBox = wx.StaticBox(self)
        assetSizer = wx.StaticBoxSizer(assetBox, wx.HORIZONTAL)
        assetSizer.Add(self.assetList, 1, wx.EXPAND)
        aSizer.Add(assetSizer, 1, wx.EXPAND)

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

    def loadControls(self, vulnerability):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theVulId = vulnerability.id()
        # We load the environment name control before anything else.  Weird stuff happens if we don't do this.  Don't ask me why!!!
        environmentNames = []
        if (len(vulnerability.environmentProperties()) > 0):
            for cp in vulnerability.environmentProperties():
                environmentNames.append(cp.name())
            self.environmentList.load(environmentNames)
            for cp in vulnerability.environmentProperties():
                environmentName = cp.name()
                self.theEnvironmentDictionary[environmentName] = cp
            environmentName = environmentNames[0]
            p = self.theEnvironmentDictionary[environmentName]
            self.sevCtrl.SetStringSelection(p.severity())
            self.assetList.setEnvironment(environmentName)
            self.assetList.load(p.assets())
            self.environmentList.Select(0)

        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]
        self.sevCtrl.SetStringSelection(p.severity())
        self.assetList.setEnvironment(environmentName)
        self.assetList.load(p.assets())

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = VulnerabilityEnvironmentProperties(
                environmentName, self.sevCtrl.GetValue(),
                self.assetList.dimensions())
        self.sevCtrl.SetValue('')
        self.assetList.setEnvironment('')
        self.assetList.DeleteAllItems()
        self.theSelectedIdx = -1

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = VulnerabilityEnvironmentProperties(
                environmentName, '', [])
        self.environmentList.Select(self.theSelectedIdx)
        self.assetList.setEnvironment(environmentName)
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if (inheritedEnv != '' and self.theVulId != None):
            p = self.dbProxy.inheritedVulnerabilityProperties(
                self.theVulId, inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.sevCtrl.SetStringSelection(p.severity())
            self.assetList.setEnvironment(environmentName)
            self.assetList.load(p.assets())

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            self.theEnvironmentDictionary[
                environmentName] = VulnerabilityEnvironmentProperties(
                    environmentName, self.sevCtrl.GetValue(),
                    self.assetList.dimensions())
        return self.theEnvironmentDictionary.values()
class CountermeasureEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.COUNTERMEASURE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.COUNTERMEASURE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)


    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
 
    costBox = wx.StaticBox(self,-1,'Cost')
    costBoxSizer = wx.StaticBoxSizer(costBox,wx.HORIZONTAL)
    environmentDimSizer.Add(costBoxSizer,0,wx.EXPAND)
    self.costCombo = wx.ComboBox(self,armid.COUNTERMEASURE_COMBOCOST_ID,"",choices=['Low','Medium','High'],style=wx.CB_READONLY)
    costBoxSizer.Add(self.costCombo,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = CountermeasureEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.reqList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTREQUIREMENTS_ID)
    self.targetList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTTARGETS_ID)
    self.propertiesList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTPROPERTIES_ID)
    self.personaList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTPERSONAS_ID)
    self.roleList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTROLES_ID)

    self.reqList.Disable()
    self.targetList.Disable()
    self.propertiesList.Disable()
    self.costCombo.Disable()
    self.roleList.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def loadControls(self,countermeasure):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in countermeasure.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in countermeasure.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.reqList.setEnvironment(environmentName)
    self.reqList.load(p.requirements())
    self.targetList.setEnvironment(environmentName)
    self.targetList.load(p.targets())
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())
    self.costCombo.SetStringSelection(p.cost())
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.personaList.load(p.personas())

    self.environmentList.Select(0)

    self.reqList.Enable()
    self.targetList.Enable()
    self.propertiesList.Enable()
    self.costCombo.Enable()
    self.roleList.Enable()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.reqList.setEnvironment(environmentName)
    self.reqList.load(p.requirements())
    self.targetList.setEnvironment(environmentName)
    self.targetList.load(p.targets())
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())
    self.costCombo.SetStringSelection(p.cost())
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.personaList.load(p.personas())
    self.reqList.Enable()
    self.targetList.Enable()
    self.propertiesList.Enable()
    self.costCombo.Enable()
    self.roleList.Enable()
    self.personaList.Enable()


  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    syProperties, pRationale = self.propertiesList.properties() 
    properties = CountermeasureEnvironmentProperties(environmentName,self.reqList.dimensions(),self.targetList.targets(),syProperties,pRationale,self.costCombo.GetValue(),self.roleList.dimensions(),self.personaList.dimensions())
    self.theEnvironmentDictionary[environmentName] = properties

    self.reqList.setEnvironment('')
    self.reqList.DeleteAllItems()
    self.targetList.setEnvironment('')
    self.targetList.DeleteAllItems()
    self.propertiesList.setEnvironment('')
    self.propertiesList.DeleteAllItems()
    self.costCombo.SetValue('')
    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems()
    self.personaList.DeleteAllItems()

    self.theSelectedIdx = -1
    self.reqList.Disable()
    self.targetList.Disable()
    self.propertiesList.Disable()
    self.costCombo.Disable()
    self.roleList.Disable()

  def OnAddEnvironment(self,evt):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      syProperties,pRationale = self.propertiesList.properties()
      properties = CountermeasureEnvironmentProperties(environmentName,self.reqList.dimensions(),self.targetList.targets(),syProperties,pRationale,self.costCombo.GetValue(),self.roleList.dimensions(),self.personaList.dimensions())
      self.theEnvironmentDictionary[environmentName] = properties
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = CountermeasureEnvironmentProperties(environmentName)

    self.reqList.setEnvironment(environmentName)
    self.reqList.DeleteAllItems()
    self.targetList.setEnvironment(environmentName)
    self.targetList.DeleteAllItems()
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.DeleteAllItems()
    self.costCombo.SetValue('')
    self.roleList.setEnvironment(environmentName)
    self.roleList.DeleteAllItems()
    self.personaList.DeleteAllItems()

    self.reqList.Enable()
    self.targetList.Enable()
    self.propertiesList.Enable()
    self.costCombo.Enable()
    self.roleList.Enable()

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      syProperties,pRationale = self.propertiesList.properties()
      properties = CountermeasureEnvironmentProperties(environmentName,self.reqList.dimensions(),self.targetList.targets(),syProperties,pRationale,self.costCombo.GetValue(),self.roleList.dimensions(),self.personaList.dimensions())
      self.theEnvironmentDictionary[environmentName] = properties
    for cname in self.environmentList.dimensions():
      p = self.theEnvironmentDictionary[cname]
      if (len(p.requirements()) == 0):
        exceptionText = 'No requirements selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
      if (len(p.targets()) == 0):
        exceptionText = 'No targets selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
      if (len(p.cost()) == 0):
        exceptionText = 'No cost selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
      if (len(p.roles()) == 0):
        exceptionText = 'No roles selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
    return self.theEnvironmentDictionary.values() 
class ReqToGoalEnvironmentPanel(wx.Panel):
  def __init__(self,parent,goalDef,goalCat,goalPri,goalFc,goalIssue,goalAssets,defaultEnv):
    wx.Panel.__init__(self,parent,armid.GOAL_PANELENVIRONMENT_ID)
    b = Borg()
    self.dbProxy = b.dbProxy
    self.theGoalId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.theGoalDefinition = goalDef
    self.theGoalCategory = goalCat
    self.theGoalPriority = goalPri
    self.theGoalFitCriterion = goalFc
    self.theGoalIssue = goalIssue
    self.theGoalAssets = goalAssets

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.GOAL_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = ReqToGoalNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)

    self.goalAssociationCtrl = self.notebook.FindWindowById(armid.GOAL_LISTGOALREFINEMENTS_ID)
    self.subGoalAssociationCtrl = self.notebook.FindWindowById(armid.GOAL_LISTSUBGOALREFINEMENTS_ID)

    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()

    self.theEnvironmentDictionary[defaultEnv] = GoalEnvironmentProperties(defaultEnv)
    self.environmentList.Select(0)
    self.goalAssociationCtrl.setEnvironment(defaultEnv)
    self.goalAssociationCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment(defaultEnv)
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]

    self.goalAssociationCtrl.setEnvironment(environmentName)
    self.goalAssociationCtrl.load(p.goalRefinements())
    self.subGoalAssociationCtrl.setEnvironment(environmentName)
    self.subGoalAssociationCtrl.load(p.subGoalRefinements())
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = GoalEnvironmentProperties(environmentName,'',self.theGoalDefinition,self.theGoalCategory,self.theGoalPriority,self.theGoalFitCriterion,self.theGoalIssue,self.goalAssociationCtrl.dimensions(),self.subGoalAssociationCtrl.dimensions(),self.theGoalAssets,[])
    self.goalAssociationCtrl.DeleteAllItems()
    self.goalAssociationCtrl.setEnvironment('')
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment('')
    self.theSelectedIdx = -1
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = GoalEnvironmentProperties(environmentName)
    self.environmentList.Select(self.theSelectedIdx)
    self.goalAssociationCtrl.setEnvironment(environmentName)
    self.goalAssociationCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment(environmentName)
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theGoalId != None):
      p = self.dbProxy.inheritedGoalProperties(self.theGoalId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.goalAssociationCtrl.setEnvironment(environmentName)
      self.goalAssociationCtrl.load(p.goalRefinements())
      self.subGoalAssociationCtrl.setEnvironment(environmentName)
      self.subGoalAssociationCtrl.load(p.subGoalRefinements())

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1
    self.goalAssociationCtrl.DeleteAllItems()
    self.goalAssociationCtrl.setEnvironment('')
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment('')
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      self.theEnvironmentDictionary[environmentName] = GoalEnvironmentProperties(environmentName,'',self.theGoalDefinition,self.theGoalCategory,self.theGoalPriority,self.theGoalFitCriterion,self.theGoalIssue,self.goalAssociationCtrl.dimensions(),self.subGoalAssociationCtrl.dimensions(),self.theGoalAssets,[])
    return self.theEnvironmentDictionary.values() 
예제 #30
0
class TransferEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.TRANSFER_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.TRANSFER_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    roleBox = wx.StaticBox(self,-1)
    roleBoxSizer = wx.StaticBoxSizer(roleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(roleBoxSizer,0,wx.EXPAND)
    self.roleList = RoleCostListCtrl(self,armid.TRANSFER_LISTROLES_ID)
    roleBoxSizer.Add(self.roleList,1,wx.EXPAND)

    rationaleBox = wx.StaticBox(self,-1,'Rationale')
    rationaleBoxSizer = wx.StaticBoxSizer(rationaleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(rationaleBoxSizer,1,wx.EXPAND)
    self.rationaleCtrl = wx.TextCtrl(self,armid.TRANSFER_TEXTRATIONALE_ID,'',style=wx.TE_MULTILINE)
    rationaleBoxSizer.Add(self.rationaleCtrl,1,wx.EXPAND)
    self.roleList.Disable()
    self.rationaleCtrl.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def loadControls(self,accept):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in accept.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in accept.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.rationaleCtrl.SetValue(p.description()) 
    self.environmentList.Select(0)
    self.roleList.Enable()
    self.rationaleCtrl.Enable()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.rationaleCtrl.SetValue(p.description()) 
    self.roleList.Enable() 
    self.rationaleCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = TransferEnvironmentProperties(environmentName,self.rationaleCtrl.GetValue(),self.roleList.roles())
    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems()
    self.rationaleCtrl.SetValue('') 
    self.theSelectedIdx = -1
    self.roleList.Disable() 
    self.rationaleCtrl.Disable()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = TransferEnvironmentProperties(environmentName)
    self.roleList.setEnvironment(environmentName)
    self.roleList.DeleteAllItems()
    self.rationaleCtrl.SetValue('') 
    self.environmentList.Select(self.theSelectedIdx)
    self.roleList.Enable() 
    self.rationaleCtrl.Enable()

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      properties = TransferEnvironmentProperties(environmentName,self.rationaleCtrl.GetValue(),self.roleList.roles())
      self.theEnvironmentDictionary[environmentName] = properties
 
    for cName in self.theEnvironmentDictionary:
      p = self.theEnvironmentDictionary[cName]
      if (len(p.description()) == 0):
        exceptionText = 'No description entered for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
      if (len(p.roles()) == 0):
        exceptionText = 'No roles selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
    return self.theEnvironmentDictionary.values() 
예제 #31
0
class TaskEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,TASK_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theTaskId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,TASK_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbBoxSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbBoxSizer,1,wx.EXPAND)
    self.notebook = TaskEnvironmentNotebook(self,self.dbProxy)
    nbBoxSizer.Add(self.notebook,1,wx.EXPAND)

    self.dependenciesCtrl = self.notebook.FindWindowById(TASK_TEXTDEPENDENCIES_ID)
    self.personaList = self.notebook.FindWindowById(TASK_LISTPERSONAS_ID)
    self.assetList = self.notebook.FindWindowById(TASK_LISTASSETS_ID)
    self.caList = self.notebook.FindWindowById(TASK_LISTCONCERNASSOCIATIONS_ID)
    self.narrativeCtrl = self.notebook.FindWindowById(TASK_TEXTNARRATIVE_ID)
    self.consequencesCtrl = self.notebook.FindWindowById(TASK_TEXTCONSEQUENCES_ID)
    self.benefitsCtrl = self.notebook.FindWindowById(TASK_TEXTBENEFITS_ID)

    self.SetSizer(mainSizer)

    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.dependenciesCtrl.Disable()
    self.personaList.Disable() 
    self.assetList.Disable() 
    self.caList.Disable()
    self.narrativeCtrl.Disable()
    self.consequencesCtrl.Disable()
    self.benefitsCtrl.Disable()

    self.theDimMenu = wx.Menu()
    self.theDimMenu.Append(DIMLIST_MENUADD_ID,'Add Goal')
    self.Bind(wx.EVT_RIGHT_DOWN,self.OnRightDown)
    wx.EVT_MENU(self.theDimMenu,DIMLIST_MENUADD_ID,self.onAddGoal)

  def OnRightDown(self,evt):
    self.PopupMenu(self.theDimMenu)

  def onAddGoal(self,evt):
    print 'goal'



  def loadControls(self,task):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theTaskId = task.id()
    environmentNames = []
    for cp in task.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in task.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]

    self.dependenciesCtrl.SetValue(p.dependencies())
    self.personaList.setEnvironment(environmentName)
    self.assetList.setEnvironment(environmentName)
    self.caList.setEnvironment(environmentName)   
    self.narrativeCtrl.setEnvironment(environmentName)
    self.personaList.load(p.personas()) 
    self.assetList.load(p.assets()) 
    self.caList.load(p.concernAssociations()) 
    self.narrativeCtrl.SetValue(p.narrative())
    self.consequencesCtrl.SetValue(p.consequences())
    self.benefitsCtrl.SetValue(p.benefits())
    self.narrativeCtrl.setCodes(p.codes('narrative'))
    self.consequencesCtrl.setCodes(p.codes('consequences'))
    self.benefitsCtrl.setCodes(p.codes('benefits'))

    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.dependenciesCtrl.Enable()
    self.personaList.Enable() 
    self.assetList.Enable() 
    self.caList.Enable()
    self.narrativeCtrl.Enable()
    self.consequencesCtrl.Enable()
    self.benefitsCtrl.Enable()
    self.theSelectedIdx = 0
    self.narrativeCtrl.setTask(task.name())

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]

    self.dependenciesCtrl.SetValue(p.dependencies())
    self.personaList.setEnvironment(environmentName)
    self.assetList.setEnvironment(environmentName)
    self.caList.setEnvironment(environmentName)
    self.personaList.load(p.personas()) 
    self.assetList.load(p.assets()) 
    self.caList.load(p.concernAssociations()) 
    self.narrativeCtrl.SetValue(p.narrative())
    self.consequencesCtrl.SetValue(p.consequences())
    self.benefitsCtrl.SetValue(p.benefits())
    self.narrativeCtrl.setCodes(p.codes('narrative'))
    self.consequencesCtrl.setCodes(p.codes('consequences'))
    self.benefitsCtrl.setCodes(p.codes('benefits'))
    self.dependenciesCtrl.Enable()
    self.personaList.Enable() 
    self.assetList.Enable() 
    self.caList.Enable()
    self.narrativeCtrl.Enable()
    self.consequencesCtrl.Enable()
    self.benefitsCtrl.Enable()
    self.narrativeCtrl.setEnvironment(environmentName)

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)

    envCodebook = {'narrative':self.narrativeCtrl.codes(),'consequences':self.consequencesCtrl.codes(),'benefits':self.benefitsCtrl.codes()}
    self.theEnvironmentDictionary[environmentName] = TaskEnvironmentProperties(environmentName,self.dependenciesCtrl.GetValue(),self.personaList.dimensions(),self.assetList.dimensions(),self.caList.dimensions(),self.narrativeCtrl.GetValue(),self.consequencesCtrl.GetValue(),self.benefitsCtrl.GetValue(),envCodebook)
    self.dependenciesCtrl.SetValue('')
    self.personaList.setEnvironment('')
    self.assetList.setEnvironment('')
    self.caList.setEnvironment('')
    self.narrativeCtrl.setEnvironment('')
    self.personaList.DeleteAllItems() 
    self.assetList.DeleteAllItems() 
    self.caList.DeleteAllItems() 
    self.narrativeCtrl.SetValue('')
    self.consequencesCtrl.SetValue('')
    self.benefitsCtrl.SetValue('')
    self.narrativeCtrl.setCodes({})
    self.consequencesCtrl.setCodes({})
    self.benefitsCtrl.setCodes({})
    self.theSelectedIdx = -1
    self.dependenciesCtrl.Disable()
    self.personaList.Disable() 
    self.assetList.Disable() 
    self.caList.Disable() 
    self.narrativeCtrl.Disable()
    self.consequencesCtrl.Disable()
    self.benefitsCtrl.Disable()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = TaskEnvironmentProperties(environmentName)
    self.environmentList.Select(self.theSelectedIdx)
    self.personaList.setEnvironment(environmentName)
    self.assetList.setEnvironment(environmentName)
    self.caList.setEnvironment(environmentName)
    self.narrativeCtrl.setEnvironment(environmentName)
    self.personaList.DeleteAllItems() 
    self.assetList.DeleteAllItems() 
    self.caList.DeleteAllItems() 
    self.dependenciesCtrl.SetValue('')
    self.narrativeCtrl.SetValue('')
    self.consequencesCtrl.SetValue('')
    self.benefitsCtrl.SetValue('')
    self.narrativeCtrl.setCodes({})
    self.consequencesCtrl.setCodes({})
    self.benefitsCtrl.setCodes({})
    self.dependenciesCtrl.Enable()
    self.personaList.Enable() 
    self.assetList.Enable() 
    self.caList.Enable() 
    self.narrativeCtrl.Enable()
    self.consequencesCtrl.Enable()
    self.benefitsCtrl.Enable()
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theTaskId != None):
      p = self.dbProxy.inheritedTaskProperties(self.theTaskId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.dependenciesCtrl.SetValue(p.dependencies())
      self.personaList.setEnvironment(environmentName)
      self.assetList.setEnvironment(environmentName)
      self.caList.setEnvironment(environmentName)
      self.narrativeCtrl.setEnvironment(environmentName)
      self.personaList.load(p.personas()) 
      self.assetList.load(p.assets()) 
      self.caList.load(p.concernAssociations()) 
      self.narrativeCtrl.SetValue(p.narrative())
      self.consequencesCtrl.SetValue(p.consequences())
      self.benefitsCtrl.SetValue(p.benefits())
      self.narrativeCtrl.setCodes(p.codes('narrative'))
      self.consequencesCtrl.setCodes(p.codes('consequences'))
      self.benefitsCtrl.setCodes(p.codes('benefits'))

      self.dependenciesCtrl.Enable()
      self.personaList.Enable() 
      self.assetList.Enable() 
      self.caList.Enable() 
      self.narrativeCtrl.Enable()
      self.consequencesCtrl.Enable()
      self.benefitsCtrl.Enable()

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1
    self.dependenciesCtrl.SetValue('')
    self.personaList.setEnvironment('')
    self.assetList.setEnvironment('')
    self.caList.setEnvironment('')
    self.narrativeCtrl.setEnvironment('')
    self.personaList.DeleteAllItems() 
    self.assetList.DeleteAllItems() 
    self.caList.DeleteAllItems() 
    self.narrativeCtrl.SetValue('')
    self.consequencesCtrl.SetValue('')
    self.benefitsCtrl.SetValue('')
    self.narrativeCtrl.setCodes({})
    self.consequencesCtrl.setCodes({})
    self.benefitsCtrl.setCodes({})
    self.dependenciesCtrl.Disable()
    self.personaList.Disable() 
    self.assetList.Disable() 
    self.caList.Disable() 
    self.narrativeCtrl.Disable()
    self.consequencesCtrl.Disable()
    self.benefitsCtrl.Disable()


  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      envCodebook = {'narrative':self.narrativeCtrl.codes(),'consequences':self.consequencesCtrl.codes(),'benefits':self.benefitsCtrl.codes()}
      self.theEnvironmentDictionary[environmentName] = TaskEnvironmentProperties(environmentName,self.dependenciesCtrl.GetValue(),self.personaList.dimensions(),self.assetList.dimensions(),self.caList.dimensions(),self.narrativeCtrl.GetValue(),self.consequencesCtrl.GetValue(),self.benefitsCtrl.GetValue(),envCodebook)
    return self.theEnvironmentDictionary.values() 
예제 #32
0
class TaskEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, TASK_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theTaskId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self,
                                                   TASK_LISTENVIRONMENTS_ID,
                                                   self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbBoxSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbBoxSizer, 1, wx.EXPAND)
        self.notebook = TaskEnvironmentNotebook(self, self.dbProxy)
        nbBoxSizer.Add(self.notebook, 1, wx.EXPAND)

        self.dependenciesCtrl = self.notebook.FindWindowById(
            TASK_TEXTDEPENDENCIES_ID)
        self.personaList = self.notebook.FindWindowById(TASK_LISTPERSONAS_ID)
        self.assetList = self.notebook.FindWindowById(TASK_LISTASSETS_ID)
        self.caList = self.notebook.FindWindowById(
            TASK_LISTCONCERNASSOCIATIONS_ID)
        self.narrativeCtrl = self.notebook.FindWindowById(
            TASK_TEXTNARRATIVE_ID)
        self.consequencesCtrl = self.notebook.FindWindowById(
            TASK_TEXTCONSEQUENCES_ID)
        self.benefitsCtrl = self.notebook.FindWindowById(TASK_TEXTBENEFITS_ID)

        self.SetSizer(mainSizer)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
        self.dependenciesCtrl.Disable()
        self.personaList.Disable()
        self.assetList.Disable()
        self.caList.Disable()
        self.narrativeCtrl.Disable()
        self.consequencesCtrl.Disable()
        self.benefitsCtrl.Disable()

        self.theDimMenu = wx.Menu()
        self.theDimMenu.Append(DIMLIST_MENUADD_ID, 'Add Goal')
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
        wx.EVT_MENU(self.theDimMenu, DIMLIST_MENUADD_ID, self.onAddGoal)

    def OnRightDown(self, evt):
        self.PopupMenu(self.theDimMenu)

    def onAddGoal(self, evt):
        print 'goal'

    def loadControls(self, task):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theTaskId = task.id()
        environmentNames = []
        for cp in task.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in task.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.dependenciesCtrl.SetValue(p.dependencies())
        self.personaList.setEnvironment(environmentName)
        self.assetList.setEnvironment(environmentName)
        self.caList.setEnvironment(environmentName)
        self.narrativeCtrl.setEnvironment(environmentName)
        self.personaList.load(p.personas())
        self.assetList.load(p.assets())
        self.caList.load(p.concernAssociations())
        self.narrativeCtrl.SetValue(p.narrative())
        self.consequencesCtrl.SetValue(p.consequences())
        self.benefitsCtrl.SetValue(p.benefits())
        self.narrativeCtrl.setCodes(p.codes('narrative'))
        self.consequencesCtrl.setCodes(p.codes('consequences'))
        self.benefitsCtrl.setCodes(p.codes('benefits'))

        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.dependenciesCtrl.Enable()
        self.personaList.Enable()
        self.assetList.Enable()
        self.caList.Enable()
        self.narrativeCtrl.Enable()
        self.consequencesCtrl.Enable()
        self.benefitsCtrl.Enable()
        self.theSelectedIdx = 0
        self.narrativeCtrl.setTask(task.name())

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]

        self.dependenciesCtrl.SetValue(p.dependencies())
        self.personaList.setEnvironment(environmentName)
        self.assetList.setEnvironment(environmentName)
        self.caList.setEnvironment(environmentName)
        self.personaList.load(p.personas())
        self.assetList.load(p.assets())
        self.caList.load(p.concernAssociations())
        self.narrativeCtrl.SetValue(p.narrative())
        self.consequencesCtrl.SetValue(p.consequences())
        self.benefitsCtrl.SetValue(p.benefits())
        self.narrativeCtrl.setCodes(p.codes('narrative'))
        self.consequencesCtrl.setCodes(p.codes('consequences'))
        self.benefitsCtrl.setCodes(p.codes('benefits'))
        self.dependenciesCtrl.Enable()
        self.personaList.Enable()
        self.assetList.Enable()
        self.caList.Enable()
        self.narrativeCtrl.Enable()
        self.consequencesCtrl.Enable()
        self.benefitsCtrl.Enable()
        self.narrativeCtrl.setEnvironment(environmentName)

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)

        envCodebook = {
            'narrative': self.narrativeCtrl.codes(),
            'consequences': self.consequencesCtrl.codes(),
            'benefits': self.benefitsCtrl.codes()
        }
        self.theEnvironmentDictionary[
            environmentName] = TaskEnvironmentProperties(
                environmentName, self.dependenciesCtrl.GetValue(),
                self.personaList.dimensions(), self.assetList.dimensions(),
                self.caList.dimensions(), self.narrativeCtrl.GetValue(),
                self.consequencesCtrl.GetValue(), self.benefitsCtrl.GetValue(),
                envCodebook)
        self.dependenciesCtrl.SetValue('')
        self.personaList.setEnvironment('')
        self.assetList.setEnvironment('')
        self.caList.setEnvironment('')
        self.narrativeCtrl.setEnvironment('')
        self.personaList.DeleteAllItems()
        self.assetList.DeleteAllItems()
        self.caList.DeleteAllItems()
        self.narrativeCtrl.SetValue('')
        self.consequencesCtrl.SetValue('')
        self.benefitsCtrl.SetValue('')
        self.narrativeCtrl.setCodes({})
        self.consequencesCtrl.setCodes({})
        self.benefitsCtrl.setCodes({})
        self.theSelectedIdx = -1
        self.dependenciesCtrl.Disable()
        self.personaList.Disable()
        self.assetList.Disable()
        self.caList.Disable()
        self.narrativeCtrl.Disable()
        self.consequencesCtrl.Disable()
        self.benefitsCtrl.Disable()

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = TaskEnvironmentProperties(environmentName)
        self.environmentList.Select(self.theSelectedIdx)
        self.personaList.setEnvironment(environmentName)
        self.assetList.setEnvironment(environmentName)
        self.caList.setEnvironment(environmentName)
        self.narrativeCtrl.setEnvironment(environmentName)
        self.personaList.DeleteAllItems()
        self.assetList.DeleteAllItems()
        self.caList.DeleteAllItems()
        self.dependenciesCtrl.SetValue('')
        self.narrativeCtrl.SetValue('')
        self.consequencesCtrl.SetValue('')
        self.benefitsCtrl.SetValue('')
        self.narrativeCtrl.setCodes({})
        self.consequencesCtrl.setCodes({})
        self.benefitsCtrl.setCodes({})
        self.dependenciesCtrl.Enable()
        self.personaList.Enable()
        self.assetList.Enable()
        self.caList.Enable()
        self.narrativeCtrl.Enable()
        self.consequencesCtrl.Enable()
        self.benefitsCtrl.Enable()
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if (inheritedEnv != '' and self.theTaskId != None):
            p = self.dbProxy.inheritedTaskProperties(self.theTaskId,
                                                     inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.dependenciesCtrl.SetValue(p.dependencies())
            self.personaList.setEnvironment(environmentName)
            self.assetList.setEnvironment(environmentName)
            self.caList.setEnvironment(environmentName)
            self.narrativeCtrl.setEnvironment(environmentName)
            self.personaList.load(p.personas())
            self.assetList.load(p.assets())
            self.caList.load(p.concernAssociations())
            self.narrativeCtrl.SetValue(p.narrative())
            self.consequencesCtrl.SetValue(p.consequences())
            self.benefitsCtrl.SetValue(p.benefits())
            self.narrativeCtrl.setCodes(p.codes('narrative'))
            self.consequencesCtrl.setCodes(p.codes('consequences'))
            self.benefitsCtrl.setCodes(p.codes('benefits'))

            self.dependenciesCtrl.Enable()
            self.personaList.Enable()
            self.assetList.Enable()
            self.caList.Enable()
            self.narrativeCtrl.Enable()
            self.consequencesCtrl.Enable()
            self.benefitsCtrl.Enable()

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1
        self.dependenciesCtrl.SetValue('')
        self.personaList.setEnvironment('')
        self.assetList.setEnvironment('')
        self.caList.setEnvironment('')
        self.narrativeCtrl.setEnvironment('')
        self.personaList.DeleteAllItems()
        self.assetList.DeleteAllItems()
        self.caList.DeleteAllItems()
        self.narrativeCtrl.SetValue('')
        self.consequencesCtrl.SetValue('')
        self.benefitsCtrl.SetValue('')
        self.narrativeCtrl.setCodes({})
        self.consequencesCtrl.setCodes({})
        self.benefitsCtrl.setCodes({})
        self.dependenciesCtrl.Disable()
        self.personaList.Disable()
        self.assetList.Disable()
        self.caList.Disable()
        self.narrativeCtrl.Disable()
        self.consequencesCtrl.Disable()
        self.benefitsCtrl.Disable()

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            envCodebook = {
                'narrative': self.narrativeCtrl.codes(),
                'consequences': self.consequencesCtrl.codes(),
                'benefits': self.benefitsCtrl.codes()
            }
            self.theEnvironmentDictionary[
                environmentName] = TaskEnvironmentProperties(
                    environmentName, self.dependenciesCtrl.GetValue(),
                    self.personaList.dimensions(), self.assetList.dimensions(),
                    self.caList.dimensions(), self.narrativeCtrl.GetValue(),
                    self.consequencesCtrl.GetValue(),
                    self.benefitsCtrl.GetValue(), envCodebook)
        return self.theEnvironmentDictionary.values()
예제 #33
0
 def __init__(self,parent,winId,dp):
   EnvironmentListCtrl.__init__(self,parent,winId,dp)
   self.theCurrentRisk = ''
예제 #34
0
class ObstacleEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,OBSTACLE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theObstacleId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,OBSTACLE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = ObstacleEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.labelCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTLABEL_ID)
    self.probCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTPROBABILITY_ID)
    self.categoryCtrl = self.notebook.FindWindowById(OBSTACLE_COMBOCATEGORY_ID)
    self.definitionCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTDEFINITION_ID)
    self.goalAssociationCtrl = self.notebook.FindWindowById(OBSTACLE_LISTGOALS_ID)
    self.subGoalAssociationCtrl = self.notebook.FindWindowById(OBSTACLE_LISTSUBGOALS_ID)
    self.concernsCtrl = self.notebook.FindWindowById(OBSTACLE_LISTCONCERNS_ID)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.categoryCtrl.Disable()
    self.definitionCtrl.Disable()
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()
    self.concernsCtrl.Disable()


  def loadControls(self,obstacle):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theObstacleId = obstacle.id()
    environmentNames = []
    for cp in obstacle.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in obstacle.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]

    self.labelCtrl.SetValue(p.label())
    self.probCtrl.SetValue(str(p.probability()))
    self.categoryCtrl.SetValue(p.category())
    self.definitionCtrl.SetValue(p.definition())
    self.goalAssociationCtrl.setEnvironment(environmentName)
    self.goalAssociationCtrl.load(p.goalRefinements())
    self.subGoalAssociationCtrl.setEnvironment(environmentName)
    self.concernsCtrl.setEnvironment(environmentName)
    self.subGoalAssociationCtrl.load(p.subGoalRefinements())
    self.concernsCtrl.load(p.concerns())

    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

    self.categoryCtrl.Enable()
    self.definitionCtrl.Enable()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()
    self.concernsCtrl.Enable()
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]

    self.labelCtrl.SetValue(p.label())
    self.probCtrl.SetValue(str(p.probability()))
    self.categoryCtrl.SetValue(p.category())
    self.definitionCtrl.SetValue(p.definition())
    self.goalAssociationCtrl.setEnvironment(environmentName)
    self.goalAssociationCtrl.load(p.goalRefinements())
    self.subGoalAssociationCtrl.setEnvironment(environmentName)
    self.concernsCtrl.setEnvironment(environmentName)
    self.subGoalAssociationCtrl.load(p.subGoalRefinements())
    self.concernsCtrl.load(p.concerns())

    self.categoryCtrl.Enable()
    self.definitionCtrl.Enable()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()
    self.concernsCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = ObstacleEnvironmentProperties(environmentName,self.labelCtrl.GetValue(),self.definitionCtrl.GetValue(),self.categoryCtrl.GetValue(),self.goalAssociationCtrl.dimensions(),self.subGoalAssociationCtrl.dimensions(),self.concernsCtrl.dimensions())
    self.labelCtrl.SetValue('')
    self.probCtrl.SetValue('')
    self.categoryCtrl.SetValue('')
    self.definitionCtrl.SetValue('')
    self.goalAssociationCtrl.DeleteAllItems()
    self.goalAssociationCtrl.setEnvironment('')
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.concernsCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment('')
    self.concernsCtrl.setEnvironment('')
    self.theSelectedIdx = -1
    self.categoryCtrl.Disable()
    self.definitionCtrl.Disable()
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()
    self.concernsCtrl.Disable()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = ObstacleEnvironmentProperties(environmentName)
    self.environmentList.Select(self.theSelectedIdx)
    self.labelCtrl.SetValue('')
    self.probCtrl.SetValue('')
    self.categoryCtrl.SetValue('')
    self.definitionCtrl.SetValue('None')
    self.goalAssociationCtrl.setEnvironment(environmentName)
    self.goalAssociationCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment(environmentName)
    self.concernsCtrl.setEnvironment(environmentName)
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.concernsCtrl.DeleteAllItems()
    self.categoryCtrl.Enable()
    self.definitionCtrl.Enable()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()
    self.concernsCtrl.Enable()
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theObstacleId != None):
      p = self.dbProxy.inheritedObstacleProperties(self.theObstacleId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.labelCtrl.SetValue(p.label())
      self.labelCtrl.SetValue(str(p.probability()))
      self.categoryCtrl.SetValue(p.category())
      self.definitionCtrl.SetValue(p.definition())
      self.goalAssociationCtrl.setEnvironment(environmentName)
      self.goalAssociationCtrl.load(p.goalRefinements())
      self.subGoalAssociationCtrl.setEnvironment(environmentName)
      self.concernsCtrl.setEnvironment(environmentName)
      self.subGoalAssociationCtrl.load(p.subGoalRefinements())
      self.concernsCtrl.load(p.concerns())

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1
    self.labelCtrl.SetValue('')
    self.probCtrl.SetValue('')
    self.categoryCtrl.SetValue('')
    self.definitionCtrl.SetValue('')
    self.goalAssociationCtrl.DeleteAllItems()
    self.goalAssociationCtrl.setEnvironment('')
    self.subGoalAssociationCtrl.DeleteAllItems()
    self.subGoalAssociationCtrl.setEnvironment('')
    self.concernsCtrl.DeleteAllItems()
    self.concernsCtrl.setEnvironment('')
    self.categoryCtrl.Disable()
    self.definitionCtrl.Disable()
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()
    self.concernsCtrl.Disable()


  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      self.theEnvironmentDictionary[environmentName] = ObstacleEnvironmentProperties(environmentName,self.labelCtrl.GetValue(),self.definitionCtrl.GetValue(),self.categoryCtrl.GetValue(),self.goalAssociationCtrl.dimensions(),self.subGoalAssociationCtrl.dimensions(),self.concernsCtrl.dimensions())
    return self.theEnvironmentDictionary.values() 
예제 #35
0
class AssetEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,ASSET_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theAssetId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,ASSETENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    dimBox = wx.StaticBox(self)
    environmentDimSizer = wx.StaticBoxSizer(dimBox,wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = AssetEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.propertiesList = self.notebook.FindWindowById(ASSETENVIRONMENT_LISTPROPERTIES_ID)
    self.associationCtrl = self.notebook.FindWindowById(ASSET_LISTASSOCIATIONS_ID)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

    self.propertiesList.Disable()
    self.associationCtrl.Disable()

  def loadControls(self,asset):
    self.theAssetId = asset.id()
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    noOfProperties = len(asset.environmentProperties())
    if (noOfProperties > 0):
      environmentNames = []
      for cp in asset.environmentProperties():
        environmentNames.append(cp.name())
      self.environmentList.load(environmentNames)

      for cp in asset.environmentProperties():
        environmentName = cp.name()
        self.theEnvironmentDictionary[environmentName] = cp
        environmentNames.append(environmentName) 
      environmentName = environmentNames[0]
      p = self.theEnvironmentDictionary[environmentName]
      self.propertiesList.setEnvironment(environmentName)
      self.propertiesList.load(p.properties(),p.rationale()) 
      self.associationCtrl.setEnvironment(environmentName)
      self.associationCtrl.load(p.associations()) 
      self.environmentList.Select(0)

    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

    self.propertiesList.Enable()
    self.associationCtrl.Enable()
    if (noOfProperties > 0):
      self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())
    self.associationCtrl.setEnvironment(environmentName)
    self.associationCtrl.load(p.associations()) 
    self.propertiesList.Enable()
    self.associationCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    syProperties,pRationale = self.propertiesList.properties()
    self.theEnvironmentDictionary[environmentName] = AssetEnvironmentProperties(environmentName,syProperties,pRationale,self.associationCtrl.dimensions())
    self.propertiesList.setEnvironment('')
    self.propertiesList.DeleteAllItems() 
    self.associationCtrl.setEnvironment('')
    self.associationCtrl.DeleteAllItems() 
    self.propertiesList.Disable()
    self.associationCtrl.Disable()

    self.theSelectedIdx = -1

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AssetEnvironmentProperties(environmentName,[0,0,0,0,0,0,0,0],['None','None','None','None','None','None','None','None'])
    self.environmentList.Select(self.theSelectedIdx)
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.DeleteAllItems()
    self.associationCtrl.setEnvironment(environmentName)
    self.associationCtrl.DeleteAllItems()
    self.propertiesList.Enable()
    self.associationCtrl.Enable()
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theAssetId != None):
      p = self.dbProxy.inheritedAssetProperties(self.theAssetId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.propertiesList.setEnvironment(environmentName)
      self.propertiesList.load(p.properties(),p.rationale()) 
      self.associationCtrl.setEnvironment(environmentName)
      self.associationCtrl.load(p.associations())


  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1
    self.propertiesList.setEnvironment('')
    self.propertiesList.DeleteAllItems()
    self.associationCtrl.setEnvironment('')
    self.associationCtrl.DeleteAllItems()
    self.propertiesList.Disable()
    self.associationCtrl.Disable()

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      syProperties,pRationale = self.propertiesList.properties()
      self.theEnvironmentDictionary[environmentName] = AssetEnvironmentProperties(environmentName,syProperties,pRationale,self.associationCtrl.dimensions())
    return self.theEnvironmentDictionary.values() 
예제 #36
0
class ThreatEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, armid.THREAT_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theThreatId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.THREATENVIRONMENT_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)

        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        lhoodBox = wx.StaticBox(self)
        lhoodSizer = wx.StaticBoxSizer(lhoodBox, wx.HORIZONTAL)
        environmentDimSizer.Add(lhoodSizer, 0, wx.EXPAND)
        lhoodSizer.Add(wx.StaticText(self, -1, 'Likelihood'))
        lhoodList = [
            'Incredible', 'Improbable', 'Remote', 'Occasional', 'Probable',
            'Frequent'
        ]
        self.lhoodCtrl = wx.ComboBox(
            self,
            armid.THREATENVIRONMENT_COMBOLIKELIHOOD_ID,
            choices=lhoodList,
            size=wx.DefaultSize,
            style=wx.CB_READONLY)
        lhoodSizer.Add(self.lhoodCtrl, 1, wx.EXPAND)

        aaSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentDimSizer.Add(aaSizer, 1, wx.EXPAND)
        self.attackerList = DimensionListCtrl(
            self, armid.THREATENVIRONMENT_LISTATTACKERS_ID, wx.DefaultSize,
            'Attacker', 'attacker', self.dbProxy)
        attackerBox = wx.StaticBox(self)
        attackerSizer = wx.StaticBoxSizer(attackerBox, wx.HORIZONTAL)
        attackerSizer.Add(self.attackerList, 1, wx.EXPAND)
        aaSizer.Add(attackerSizer, 1, wx.EXPAND)

        self.assetList = DimensionListCtrl(
            self, armid.THREATENVIRONMENT_LISTASSETS_ID, wx.DefaultSize,
            'Asset', 'asset', self.dbProxy)
        assetBox = wx.StaticBox(self)
        assetSizer = wx.StaticBoxSizer(assetBox, wx.HORIZONTAL)
        assetSizer.Add(self.assetList, 1, wx.EXPAND)
        aaSizer.Add(assetSizer, 1, wx.EXPAND)

        propertiesBox = wx.StaticBox(self)
        propertiesSizer = wx.StaticBoxSizer(propertiesBox, wx.HORIZONTAL)
        environmentDimSizer.Add(propertiesSizer, 1, wx.EXPAND)
        values = self.dbProxy.getDimensionNames('threat_value')
        valueLookup = ValueDictionary(values)
        self.propertiesList = PropertiesListCtrl(
            self, armid.THREATENVIRONMENT_LISTPROPERTIES_ID, valueLookup)
        propertiesSizer.Add(self.propertiesList, 1, wx.EXPAND)
        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

    def loadControls(self, threat):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theThreatId = threat.id()
        # We load the environment name control before anything else.  Weird stuff happens if we don't do this.  Don't ask me why!!!
        environmentNames = []
        if (len(threat.environmentProperties()) > 0):
            for cp in threat.environmentProperties():
                environmentNames.append(cp.name())
            self.environmentList.load(environmentNames)
            for cp in threat.environmentProperties():
                environmentName = cp.name()
                self.theEnvironmentDictionary[environmentName] = cp
            environmentName = environmentNames[0]
            p = self.theEnvironmentDictionary[environmentName]
            self.lhoodCtrl.SetStringSelection(p.likelihood())
            self.attackerList.setEnvironment(environmentName)
            self.attackerList.load(p.attackers())
            self.assetList.setEnvironment(environmentName)
            self.assetList.load(p.assets())
            self.propertiesList.setEnvironment(environmentName)
            self.propertiesList.load(p.properties(), p.rationale())
            self.environmentList.Select(0)

        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]
        self.lhoodCtrl.SetStringSelection(p.likelihood())
        self.attackerList.setEnvironment(environmentName)
        self.attackerList.load(p.attackers())
        self.assetList.setEnvironment(environmentName)
        self.assetList.load(p.assets())
        self.propertiesList.setEnvironment(environmentName)
        self.propertiesList.load(p.properties(), p.rationale())

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        syProperties, pRationale = self.propertiesList.properties()
        self.theEnvironmentDictionary[
            environmentName] = ThreatEnvironmentProperties(
                environmentName, self.lhoodCtrl.GetValue(),
                self.assetList.dimensions(), self.attackerList.dimensions(),
                syProperties, pRationale)
        self.lhoodCtrl.SetValue('')
        self.attackerList.setEnvironment('')
        self.attackerList.DeleteAllItems()
        self.assetList.setEnvironment('')
        self.assetList.DeleteAllItems()
        self.propertiesList.setEnvironment('')
        self.propertiesList.DeleteAllItems()
        self.theSelectedIdx = -1

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = ThreatEnvironmentProperties(
                environmentName, '', [], [], [0, 0, 0, 0, 0, 0, 0, 0], [
                    'None', 'None', 'None', 'None', 'None', 'None', 'None',
                    'None'
                ])
        self.environmentList.Select(self.theSelectedIdx)
        self.attackerList.setEnvironment(environmentName)
        self.assetList.setEnvironment(environmentName)
        self.propertiesList.setEnvironment(environmentName)
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if (inheritedEnv != '' and self.theThreatId != None):
            p = self.dbProxy.inheritedThreatProperties(self.theThreatId,
                                                       inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.lhoodCtrl.SetStringSelection(p.likelihood())
            self.attackerList.setEnvironment(environmentName)
            self.attackerList.load(p.attackers())
            self.assetList.setEnvironment(environmentName)
            self.assetList.load(p.assets())
            self.propertiesList.setEnvironment(environmentName)
            self.propertiesList.load(p.properties(), p.rationale())

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            syProperties, pRationale = self.propertiesList.properties()
            self.theEnvironmentDictionary[
                environmentName] = ThreatEnvironmentProperties(
                    environmentName, self.lhoodCtrl.GetValue(),
                    self.assetList.dimensions(),
                    self.attackerList.dimensions(), syProperties, pRationale)
        return self.theEnvironmentDictionary.values()
class MisuseCaseEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,MISUSECASE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.theSelectedRisk = ''
    self.theSelectedThreat = ''
    self.theSelectedVulnerability = ''

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,MISUSECASE_LISTENVIRONMENTS_ID,self.dbProxy)
    self.environmentList.Unbind(wx.EVT_RIGHT_DOWN)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = MisuseCaseNotebook(self)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)

    self.objectiveCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTOBJECTIVE_ID)
    self.attackerList = self.notebook.FindWindowById(MISUSECASE_LISTATTACKERS_ID)
    self.assetList = self.notebook.FindWindowById(MISUSECASE_LISTASSETS_ID)
    self.threatCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTTHREAT_ID)
    self.lhoodCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTLIKELIHOOD_ID)
    self.vulCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTVULNERABILITY_ID)
    self.sevCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTSEVERITY_ID)
    self.ratingCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTSCORE_ID)
    self.narrativeCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTNARRATIVE_ID)


    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.narrativeCtrl.Disable()



  def unloadMCComponents(self):
    self.ratingCtrl.SetValue('')
    self.threatCtrl.SetValue('')
    self.lhoodCtrl.SetValue('')
    self.vulCtrl.SetValue('')
    self.sevCtrl.SetValue('')
    self.attackerList.DeleteAllItems()
    self.assetList.DeleteAllItems()
    self.objectiveCtrl.SetValue('')
    

  def loadMCComponents(self): 
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.ratingCtrl.SetValue(self.dbProxy.riskRating(self.theSelectedThreat,self.theSelectedVulnerability,environmentName) )

    self.threatCtrl.SetValue(self.theSelectedThreat)
    threatId = self.dbProxy.getDimensionId(self.theSelectedThreat,'threat')
    environmentId = self.dbProxy.getDimensionId(environmentName,'environment')
    self.lhoodCtrl.SetValue(self.dbProxy.threatLikelihood(threatId,environmentId))

    self.vulCtrl.SetValue(self.theSelectedVulnerability)
    vulId = self.dbProxy.getDimensionId(self.theSelectedVulnerability,'vulnerability')
    self.sevCtrl.SetValue(self.dbProxy.vulnerabilitySeverity(vulId,environmentId))

    self.attackerList.DeleteAllItems()
    attackers = self.dbProxy.threatAttackers(threatId,environmentId)
    attackerSet = set(attackers)
    for atidx,attacker in enumerate(attackerSet):
      self.attackerList.InsertStringItem(atidx,attacker)

    
    threatenedAssets = self.dbProxy.threatenedAssets(threatId,environmentId)
    vulnerableAssets = self.dbProxy.vulnerableAssets(vulId,environmentId)

    objectiveText = 'Exploit vulnerabilities in '
    for idx,vulAsset in enumerate(vulnerableAssets):
      objectiveText += vulAsset
      if (idx != (len(vulnerableAssets) -1)):
        objectiveText += ','
    objectiveText += ' to threaten '
    for idx,thrAsset in enumerate(threatenedAssets):
      objectiveText += thrAsset
      if (idx != (len(threatenedAssets) -1)):
        objectiveText += ','
    objectiveText += '.'
    self.objectiveCtrl.SetValue(objectiveText)

    self.assetList.DeleteAllItems()
    assetSet = set(threatenedAssets + vulnerableAssets)
    for asidx,asset in enumerate(assetSet):
      self.assetList.InsertStringItem(asidx,asset)


  def loadMisuseCase(self,mc):
    self.theSelectedRisk = mc.risk()
    self.theSelectedThreat = mc.threat()
    self.theSelectedVulnerability = mc.vulnerability()

    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in mc.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in mc.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]

    self.narrativeCtrl.SetValue(p.narrative())
    self.environmentList.Select(0)
    self.loadMCComponents()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.narrativeCtrl.Enable()
    self.theSelectedIdx = 0

  def loadRiskComponents(self,threatName,vulName):
    self.theSelectedThreat = threatName
    self.theSelectedVulnerability = vulName
    self.environmentList.Unbind(wx.EVT_LIST_INSERT_ITEM)
    self.environmentList.Unbind(wx.EVT_LIST_DELETE_ITEM)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environments = self.dbProxy.threatVulnerabilityEnvironmentNames(threatName,vulName)
    for environmentName in environments:
      self.theEnvironmentDictionary[environmentName] = MisuseCaseEnvironmentProperties(environmentName)
    self.environmentList.load(environments)
    self.environmentList.Select(0)
    self.theSelectedIdx = 0
    self.loadMCComponents()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)


  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.narrativeCtrl.SetValue(p.narrative())
    self.loadMCComponents()
    self.narrativeCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = MisuseCaseEnvironmentProperties(environmentName,self.narrativeCtrl.GetValue())
    self.narrativeCtrl.SetValue('')
    self.narrativeCtrl.Disable()
    self.unloadMCComponents()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = MisuseCaseEnvironmentProperties(environmentName)
    self.environmentList.Select(self.theSelectedIdx)
    self.loadMCComponents()
    self.narrativeCtrl.Enable()

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1
    self.narrativeCtrl.SetValue('')
    self.narrativeCtrl.Disable()
    self.unloadMCComponents()


  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      self.theEnvironmentDictionary[environmentName] = MisuseCaseEnvironmentProperties(environmentName,self.narrativeCtrl.GetValue())
    return self.theEnvironmentDictionary.values() 
class AttackerEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.ATTACKER_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theAttackerId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.ATTACKERENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
    rmSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(rmSizer,1,wx.EXPAND)
    self.roleList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTROLES_ID,wx.DefaultSize,'Role','role',self.dbProxy)
    roleBox = wx.StaticBox(self)
    roleSizer = wx.StaticBoxSizer(roleBox,wx.HORIZONTAL)
    roleSizer.Add(self.roleList,1,wx.EXPAND)
    rmSizer.Add(roleSizer,1,wx.EXPAND)

    self.motiveList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTMOTIVES_ID,wx.DefaultSize,'Motive','motivation',self.dbProxy)
    motiveBox = wx.StaticBox(self)
    motiveSizer = wx.StaticBoxSizer(motiveBox,wx.HORIZONTAL)
    motiveSizer.Add(self.motiveList,1,wx.EXPAND)
    rmSizer.Add(motiveSizer,1,wx.EXPAND)
    capBox = wx.StaticBox(self)
    capSizer = wx.StaticBoxSizer(capBox,wx.HORIZONTAL)
    environmentDimSizer.Add(capSizer,1,wx.EXPAND)
    self.capabilitiesList = CapabilitiesListCtrl(self,armid.ATTACKERENVIRONMENT_LISTCAPABILITIES_ID,self.dbProxy)
    capSizer.Add(self.capabilitiesList,1,wx.EXPAND)
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)


  def loadControls(self,attacker):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theAttackerId = attacker.id()
    environmentNames = []
    for cp in attacker.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in attacker.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 
    self.motiveList.setEnvironment(environmentName)
    self.motiveList.load(p.motives()) 
    self.capabilitiesList.setEnvironment(environmentName)
    self.capabilitiesList.load(p.capabilities())
    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 
    self.motiveList.setEnvironment(environmentName)
    self.motiveList.load(p.motives()) 
    self.capabilitiesList.setEnvironment(environmentName)
    self.capabilitiesList.load(p.capabilities())

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AttackerEnvironmentProperties(environmentName,self.roleList.dimensions(),self.motiveList.dimensions(),self.capabilitiesList.capabilities())

    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems() 
    self.motiveList.setEnvironment('')
    self.motiveList.DeleteAllItems() 
    self.capabilitiesList.setEnvironment('')
    self.capabilitiesList.DeleteAllItems()
    self.theSelectedIdx = -1

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AttackerEnvironmentProperties(environmentName,[],[],[])
    self.environmentList.Select(self.theSelectedIdx)
    self.capabilitiesList.setEnvironment(environmentName)
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theAttackerId != None):
      p = self.dbProxy.inheritedAttackerProperties(self.theAttackerId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.roleList.setEnvironment(environmentName)
      self.roleList.load(p.roles()) 
      self.motiveList.setEnvironment(environmentName)
      self.motiveList.load(p.motives()) 
      self.capabilitiesList.setEnvironment(environmentName)
      self.capabilitiesList.load(p.capabilities())


  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      self.theEnvironmentDictionary[environmentName] = AttackerEnvironmentProperties(environmentName,self.roleList.dimensions(),self.motiveList.dimensions(),self.capabilitiesList.capabilities())
    return self.theEnvironmentDictionary.values() 
예제 #39
0
class GoalEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, GOAL_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theGoalId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self,
                                                   GOAL_LISTENVIRONMENTS_ID,
                                                   self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = GoalEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.SetSizer(mainSizer)

        self.labelCtrl = self.notebook.FindWindowById(GOAL_TEXTLABEL_ID)
        self.definitionCtrl = self.notebook.FindWindowById(
            GOAL_TEXTDEFINITION_ID)
        self.categoryCtrl = self.notebook.FindWindowById(GOAL_COMBOCATEGORY_ID)
        self.priorityCtrl = self.notebook.FindWindowById(GOAL_COMBOPRIORITY_ID)
        self.fitCriterionCtrl = self.notebook.FindWindowById(
            GOAL_TEXTFITCRITERION_ID)
        self.issueCtrl = self.notebook.FindWindowById(GOAL_TEXTISSUE_ID)
        self.goalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTGOALREFINEMENTS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTSUBGOALREFINEMENTS_ID)
        self.cCtrl = self.notebook.FindWindowById(GOAL_LISTCONCERNS_ID)
        self.caCtrl = self.notebook.FindWindowById(
            GOAL_LISTCONCERNASSOCIATIONS_ID)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.definitionCtrl.Disable()
        self.categoryCtrl.Disable()
        self.priorityCtrl.Disable()
        self.fitCriterionCtrl.Disable()
        self.issueCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.cCtrl.Disable()
        self.caCtrl.Disable()

    def loadControls(self, goal):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theGoalId = goal.id()
        environmentNames = []
        for cp in goal.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in goal.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.labelCtrl.SetValue(p.label())
        self.definitionCtrl.SetValue(p.definition())
        self.categoryCtrl.SetValue(p.category())
        self.priorityCtrl.SetValue(p.priority())
        self.fitCriterionCtrl.SetValue(p.fitCriterion())
        self.issueCtrl.SetValue(p.issue())
        self.goalAssociationCtrl.setEnvironment(environmentName)
        self.goalAssociationCtrl.load(p.goalRefinements())
        self.subGoalAssociationCtrl.setEnvironment(environmentName)
        self.subGoalAssociationCtrl.load(p.subGoalRefinements())
        self.cCtrl.setEnvironment(environmentName)
        self.cCtrl.load(p.concerns())
        self.caCtrl.setEnvironment(environmentName)
        self.caCtrl.load(p.concernAssociations())

        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)

        self.definitionCtrl.Enable()
        self.categoryCtrl.Enable()
        self.priorityCtrl.Enable()
        self.fitCriterionCtrl.Enable()
        self.issueCtrl.Enable()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
        self.cCtrl.Enable()
        self.caCtrl.Enable()
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]

        self.labelCtrl.SetValue(p.label())
        self.definitionCtrl.SetValue(p.definition())
        self.categoryCtrl.SetValue(p.category())
        self.priorityCtrl.SetValue(p.priority())
        self.fitCriterionCtrl.SetValue(p.fitCriterion())
        self.issueCtrl.SetValue(p.issue())
        self.goalAssociationCtrl.setEnvironment(environmentName)
        self.goalAssociationCtrl.load(p.goalRefinements())
        self.subGoalAssociationCtrl.setEnvironment(environmentName)
        self.subGoalAssociationCtrl.load(p.subGoalRefinements())
        self.cCtrl.setEnvironment(environmentName)
        self.cCtrl.load(p.concerns())
        self.caCtrl.setEnvironment(environmentName)
        self.caCtrl.load(p.concernAssociations())
        self.definitionCtrl.Enable()
        self.categoryCtrl.Enable()
        self.priorityCtrl.Enable()
        self.fitCriterionCtrl.Enable()
        self.issueCtrl.Enable()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
        self.cCtrl.Enable()
        self.caCtrl.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = GoalEnvironmentProperties(
                environmentName, self.labelCtrl.GetValue(),
                self.definitionCtrl.GetValue(), self.categoryCtrl.GetValue(),
                self.priorityCtrl.GetValue(), self.fitCriterionCtrl.GetValue(),
                self.issueCtrl.GetValue(),
                self.goalAssociationCtrl.dimensions(),
                self.subGoalAssociationCtrl.dimensions(),
                self.cCtrl.dimensions(), self.caCtrl.dimensions())
        self.labelCtrl.SetValue('')
        self.definitionCtrl.SetValue('')
        self.categoryCtrl.SetValue('')
        self.priorityCtrl.SetValue('')
        self.fitCriterionCtrl.SetValue('')
        self.issueCtrl.SetValue('')
        self.goalAssociationCtrl.DeleteAllItems()
        self.goalAssociationCtrl.setEnvironment('')
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment('')
        self.cCtrl.DeleteAllItems()
        self.caCtrl.DeleteAllItems()
        self.cCtrl.setEnvironment('')
        self.caCtrl.setEnvironment('')
        self.theSelectedIdx = -1
        self.definitionCtrl.Disable()
        self.categoryCtrl.Disable()
        self.priorityCtrl.Disable()
        self.fitCriterionCtrl.Disable()
        self.issueCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.cCtrl.Disable()
        self.caCtrl.Disable()

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = GoalEnvironmentProperties(environmentName)
        self.environmentList.Select(self.theSelectedIdx)
        self.labelCtrl.SetValue('')
        self.definitionCtrl.SetValue('None')
        self.categoryCtrl.SetValue('')
        self.priorityCtrl.SetValue('')
        self.fitCriterionCtrl.SetValue('None')
        self.issueCtrl.SetValue('None')
        self.goalAssociationCtrl.setEnvironment(environmentName)
        self.goalAssociationCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment(environmentName)
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.cCtrl.setEnvironment(environmentName)
        self.cCtrl.DeleteAllItems()
        self.caCtrl.setEnvironment(environmentName)
        self.caCtrl.DeleteAllItems()
        self.definitionCtrl.Enable()
        self.categoryCtrl.Enable()
        self.priorityCtrl.Enable()
        self.fitCriterionCtrl.Enable()
        self.issueCtrl.Enable()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
        self.cCtrl.Enable()
        self.caCtrl.Enable()
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if (inheritedEnv != '' and self.theGoalId != None):
            p = self.dbProxy.inheritedGoalProperties(self.theGoalId,
                                                     inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.labelCtrl.SetValue(p.label())
            self.definitionCtrl.SetValue(p.definition())
            self.categoryCtrl.SetValue(p.category())
            self.priorityCtrl.SetValue(p.priority())
            self.fitCriterionCtrl.SetValue(p.fitCriterion())
            self.issueCtrl.SetValue(p.issue())
            self.goalAssociationCtrl.setEnvironment(environmentName)
            self.goalAssociationCtrl.load(p.goalRefinements())
            self.subGoalAssociationCtrl.setEnvironment(environmentName)
            self.subGoalAssociationCtrl.load(p.subGoalRefinements())
            self.cCtrl.setEnvironment(environmentName)
            self.caCtrl.setEnvironment(environmentName)
            self.cCtrl.load(p.concerns())
            self.caCtrl.load(p.concernAssociations())

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1
        self.labelCtrl.SetValue('')
        self.definitionCtrl.SetValue('')
        self.categoryCtrl.SetValue('')
        self.priorityCtrl.SetValue('')
        self.fitCriterionCtrl.SetValue('')
        self.issueCtrl.SetValue('')
        self.goalAssociationCtrl.DeleteAllItems()
        self.goalAssociationCtrl.setEnvironment('')
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment('')
        self.cCtrl.DeleteAllItems()
        self.cCtrl.setEnvironment('')
        self.caCtrl.DeleteAllItems()
        self.caCtrl.setEnvironment('')
        self.definitionCtrl.Disable()
        self.categoryCtrl.Disable()
        self.priorityCtrl.Disable()
        self.fitCriterionCtrl.Disable()
        self.issueCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.cCtrl.Disable()
        self.caCtrl.Disable()

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            self.theEnvironmentDictionary[
                environmentName] = GoalEnvironmentProperties(
                    environmentName, self.labelCtrl.GetValue(),
                    self.definitionCtrl.GetValue(),
                    self.categoryCtrl.GetValue(), self.priorityCtrl.GetValue(),
                    self.fitCriterionCtrl.GetValue(),
                    self.issueCtrl.GetValue(),
                    self.goalAssociationCtrl.dimensions(),
                    self.subGoalAssociationCtrl.dimensions(),
                    self.cCtrl.dimensions(), self.caCtrl.dimensions())
        return self.theEnvironmentDictionary.values()
예제 #40
0
class PersonaEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, PERSONA_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1
        self.thePersonaName = ''

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, PERSONA_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.HORIZONTAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = PersonaEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.directCtrl = self.notebook.FindWindowById(PERSONA_CHECKDIRECT_ID)
        self.roleList = self.notebook.FindWindowById(PERSONA_LISTROLES_ID)
        self.descriptionCtrl = self.notebook.FindWindowById(
            PERSONA_TEXTNARRATIVE_ID)
        self.directCtrl.Disable()
        self.descriptionCtrl.Disable()
        self.roleList.Disable()

    def loadControls(self, persona):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.thePersonaName = persona.name()
        environmentNames = []
        for cp in persona.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in persona.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        if (p.directFlag() == 'True'):
            self.directCtrl.SetValue(True)
        else:
            self.directCtrl.SetValue(False)
        self.descriptionCtrl.Set(self.thePersonaName, 'Environment Narrative',
                                 p.narrative())
        self.descriptionCtrl.setCodes(p.codes('narrative'))
        self.roleList.setEnvironment(environmentName)
        self.roleList.load(p.roles())

        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.directCtrl.Enable()
        self.descriptionCtrl.Enable()
        self.roleList.Enable()
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]

        if (p.directFlag() == 'True'):
            self.directCtrl.SetValue(True)
        else:
            self.directCtrl.SetValue(False)
        self.descriptionCtrl.Set(self.thePersonaName, 'Environment Narrative',
                                 p.narrative())
        self.descriptionCtrl.setCodes(p.codes('narrative'))
        self.roleList.setEnvironment(environmentName)
        self.roleList.load(p.roles())
        self.directCtrl.Enable()
        self.descriptionCtrl.Enable()
        self.roleList.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        envCodebook = {'narrative': self.descriptionCtrl.codes()}
        self.theEnvironmentDictionary[
            environmentName] = PersonaEnvironmentProperties(
                environmentName, str(self.directCtrl.GetValue()),
                self.descriptionCtrl.GetValue(), self.roleList.dimensions())

        self.directCtrl.SetValue(False)
        self.descriptionCtrl.Set(self.thePersonaName, 'Environment Narrative',
                                 '')
        self.descriptionCtrl.setCodes({})
        self.roleList.setEnvironment('')
        self.roleList.DeleteAllItems()
        self.theSelectedIdx = -1
        self.directCtrl.Disable()
        self.descriptionCtrl.Disable()
        self.roleList.Disable()

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = PersonaEnvironmentProperties(environmentName)
        self.environmentList.Select(self.theSelectedIdx)
        self.directCtrl.SetValue(False)
        self.descriptionCtrl.Set(self.thePersonaName, 'Environment Narrative',
                                 '')
        self.descriptionCtrl.setCodes({})
        self.roleList.setEnvironment(environmentName)
        self.roleList.DeleteAllItems()
        self.directCtrl.Enable()
        self.descriptionCtrl.Enable()
        self.roleList.Enable()

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1
        self.directCtrl.SetValue(False)
        self.descriptionCtrl.Set(self.thePersonaName, 'Environment Narrative',
                                 '')
        self.descriptionCtrl.setCodes({})
        self.roleList.setEnvironment('')
        self.roleList.DeleteAllItems()
        self.theSelectedIdx = -1
        self.directCtrl.Disable()
        self.descriptionCtrl.Disable()
        self.roleList.Disable()

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            envCodebook = {'narrative': self.descriptionCtrl.codes()}
            self.theEnvironmentDictionary[
                environmentName] = PersonaEnvironmentProperties(
                    environmentName, str(self.directCtrl.GetValue()),
                    self.descriptionCtrl.GetValue(),
                    self.roleList.dimensions(), envCodebook)
        return self.theEnvironmentDictionary.values()
예제 #41
0
class ThreatEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,THREAT_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theThreatId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,THREATENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)

    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    lhoodBox = wx.StaticBox(self)
    lhoodSizer = wx.StaticBoxSizer(lhoodBox,wx.HORIZONTAL)
    environmentDimSizer.Add(lhoodSizer,0,wx.EXPAND)
    lhoodSizer.Add(wx.StaticText(self,-1,'Likelihood'))
    lhoodList = ['Incredible','Improbable','Remote','Occasional','Probable','Frequent']
    self.lhoodCtrl = wx.ComboBox(self,THREATENVIRONMENT_COMBOLIKELIHOOD_ID,choices=lhoodList,size=wx.DefaultSize,style=wx.CB_READONLY)
    lhoodSizer.Add(self.lhoodCtrl,1,wx.EXPAND) 

    aaSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(aaSizer,1,wx.EXPAND)
    self.attackerList = DimensionListCtrl(self,THREATENVIRONMENT_LISTATTACKERS_ID,wx.DefaultSize,'Attacker','attacker',self.dbProxy)
    attackerBox = wx.StaticBox(self)
    attackerSizer = wx.StaticBoxSizer(attackerBox,wx.HORIZONTAL)
    attackerSizer.Add(self.attackerList,1,wx.EXPAND)
    aaSizer.Add(attackerSizer,1,wx.EXPAND)

    self.assetList = DimensionListCtrl(self,THREATENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
    assetBox = wx.StaticBox(self)
    assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
    assetSizer.Add(self.assetList,1,wx.EXPAND)
    aaSizer.Add(assetSizer,1,wx.EXPAND)

    propertiesBox = wx.StaticBox(self)
    propertiesSizer = wx.StaticBoxSizer(propertiesBox,wx.HORIZONTAL)
    environmentDimSizer.Add(propertiesSizer,1,wx.EXPAND)
    values = self.dbProxy.getDimensionNames('threat_value')
    valueLookup = ValueDictionary(values)
    self.propertiesList = PropertiesListCtrl(self,THREATENVIRONMENT_LISTPROPERTIES_ID,valueLookup)
    propertiesSizer.Add(self.propertiesList,1,wx.EXPAND)
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)


  def loadControls(self,threat):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theThreatId = threat.id()
# We load the environment name control before anything else.  Weird stuff happens if we don't do this.  Don't ask me why!!!
    environmentNames = []
    if (len(threat.environmentProperties()) > 0):
      for cp in threat.environmentProperties():
        environmentNames.append(cp.name())
      self.environmentList.load(environmentNames)
      for cp in threat.environmentProperties():
        environmentName = cp.name()
        self.theEnvironmentDictionary[environmentName] = cp
      environmentName = environmentNames[0]
      p = self.theEnvironmentDictionary[environmentName]
      self.lhoodCtrl.SetStringSelection(p.likelihood())
      self.attackerList.setEnvironment(environmentName)
      self.attackerList.load(p.attackers()) 
      self.assetList.setEnvironment(environmentName)
      self.assetList.load(p.assets()) 
      self.propertiesList.setEnvironment(environmentName)
      self.propertiesList.load(p.properties(),p.rationale())
      self.environmentList.Select(0)

    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.lhoodCtrl.SetStringSelection(p.likelihood())
    self.attackerList.setEnvironment(environmentName)
    self.attackerList.load(p.attackers()) 
    self.assetList.setEnvironment(environmentName)
    self.assetList.load(p.assets()) 
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    syProperties,pRationale = self.propertiesList.properties()
    self.theEnvironmentDictionary[environmentName] = ThreatEnvironmentProperties(environmentName,self.lhoodCtrl.GetValue(),self.assetList.dimensions(),self.attackerList.dimensions(),syProperties,pRationale)
    self.lhoodCtrl.SetValue('')
    self.attackerList.setEnvironment('')
    self.attackerList.DeleteAllItems() 
    self.assetList.setEnvironment('')
    self.assetList.DeleteAllItems() 
    self.propertiesList.setEnvironment('')
    self.propertiesList.DeleteAllItems()
    self.theSelectedIdx = -1

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = ThreatEnvironmentProperties(environmentName,'',[],[],[0,0,0,0,0,0,0,0],['None','None','None','None','None','None','None','None'])
    self.environmentList.Select(self.theSelectedIdx)
    self.attackerList.setEnvironment(environmentName)
    self.assetList.setEnvironment(environmentName)
    self.propertiesList.setEnvironment(environmentName)
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theThreatId != None):
      p = self.dbProxy.inheritedThreatProperties(self.theThreatId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.lhoodCtrl.SetStringSelection(p.likelihood())
      self.attackerList.setEnvironment(environmentName)
      self.attackerList.load(p.attackers()) 
      self.assetList.setEnvironment(environmentName)
      self.assetList.load(p.assets()) 
      self.propertiesList.setEnvironment(environmentName)
      self.propertiesList.load(p.properties(),p.rationale())

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      syProperties,pRationale = self.propertiesList.properties() 
      self.theEnvironmentDictionary[environmentName] = ThreatEnvironmentProperties(environmentName,self.lhoodCtrl.GetValue(),self.assetList.dimensions(),self.attackerList.dimensions(),syProperties,pRationale)
    return self.theEnvironmentDictionary.values() 
예제 #42
0
class AcceptEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.ACCEPT_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.ACCEPT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    costBox = wx.StaticBox(self,-1,'Cost')
    costBoxSizer = wx.StaticBoxSizer(costBox,wx.HORIZONTAL)
    environmentDimSizer.Add(costBoxSizer,0,wx.EXPAND)
    self.costCombo = wx.ComboBox(self,armid.ACCEPT_COMBOCOST_ID,"",choices=['Low','Medium','High'],style=wx.CB_READONLY)
    costBoxSizer.Add(self.costCombo,0,wx.EXPAND)
   
    rationaleBox = wx.StaticBox(self,-1,'Rationale')
    rationaleBoxSizer = wx.StaticBoxSizer(rationaleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(rationaleBoxSizer,1,wx.EXPAND)
    self.rationaleCtrl = wx.TextCtrl(self,armid.ACCEPT_TEXTRATIONALE_ID,'',style=wx.TE_MULTILINE)
    rationaleBoxSizer.Add(self.rationaleCtrl,1,wx.EXPAND)
    self.costCombo.Disable() 
    self.rationaleCtrl.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def loadControls(self,accept):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in accept.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in accept.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.costCombo.SetStringSelection(p.cost())
    self.rationaleCtrl.SetValue(p.description()) 
    self.environmentList.Select(0)
    self.costCombo.Enable() 
    self.rationaleCtrl.Enable()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.costCombo.SetStringSelection(p.cost())
    self.rationaleCtrl.SetValue(p.description()) 
    self.costCombo.Enable() 
    self.rationaleCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AcceptEnvironmentProperties(environmentName,self.costCombo.GetValue(),self.rationaleCtrl.GetValue())
    self.costCombo.SetValue('')
    self.rationaleCtrl.SetValue('') 
    self.theSelectedIdx = -1
    self.costCombo.Disable() 
    self.rationaleCtrl.Disable()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AcceptEnvironmentProperties(environmentName)
    self.costCombo.SetValue('')
    self.rationaleCtrl.SetValue('') 
    self.environmentList.Select(self.theSelectedIdx)
    self.costCombo.Enable() 
    self.rationaleCtrl.Enable()

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      properties = AcceptEnvironmentProperties(environmentName,self.costCombo.GetValue(),self.rationaleCtrl.GetValue())
      self.theEnvironmentDictionary[environmentName] = properties

    for cName in self.theEnvironmentDictionary:
      p = self.theEnvironmentDictionary[cName]
      if (len(p.cost()) == 0):
        exceptionText = 'No cost selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
      if (len(p.description()) == 0):
        exceptionText = 'No rationale entered for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
    return self.theEnvironmentDictionary.values() 
class VulnerabilityEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.VULNERABILITY_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theVulId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)

    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    sevBox = wx.StaticBox(self)
    sevSizer = wx.StaticBoxSizer(sevBox,wx.HORIZONTAL)
    environmentDimSizer.Add(sevSizer,0,wx.EXPAND)
    sevSizer.Add(wx.StaticText(self,-1,'Severity'))
    sevList = ['Negligible','Marginal','Critical','Catastrophic']
    self.sevCtrl = wx.ComboBox(self,armid.VULNERABILITYENVIRONMENT_COMBOSEVERITY_ID,choices=sevList,size=wx.DefaultSize,style=wx.CB_READONLY)
    sevSizer.Add(self.sevCtrl,1,wx.EXPAND) 

    aSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(aSizer,1,wx.EXPAND)
    self.assetList = DimensionListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
    assetBox = wx.StaticBox(self)
    assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
    assetSizer.Add(self.assetList,1,wx.EXPAND)
    aSizer.Add(assetSizer,1,wx.EXPAND)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)


  def loadControls(self,vulnerability):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theVulId = vulnerability.id()
# We load the environment name control before anything else.  Weird stuff happens if we don't do this.  Don't ask me why!!!
    environmentNames = []
    if (len(vulnerability.environmentProperties()) > 0):
      for cp in vulnerability.environmentProperties():
        environmentNames.append(cp.name())
      self.environmentList.load(environmentNames)
      for cp in vulnerability.environmentProperties():
        environmentName = cp.name()
        self.theEnvironmentDictionary[environmentName] = cp
      environmentName = environmentNames[0]
      p = self.theEnvironmentDictionary[environmentName]
      self.sevCtrl.SetStringSelection(p.severity())
      self.assetList.setEnvironment(environmentName)
      self.assetList.load(p.assets()) 
      self.environmentList.Select(0)

    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.sevCtrl.SetStringSelection(p.severity())
    self.assetList.setEnvironment(environmentName)
    self.assetList.load(p.assets()) 
      
  

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = VulnerabilityEnvironmentProperties(environmentName,self.sevCtrl.GetValue(),self.assetList.dimensions())
    self.sevCtrl.SetValue('')
    self.assetList.setEnvironment('')
    self.assetList.DeleteAllItems() 
    self.theSelectedIdx = -1

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = VulnerabilityEnvironmentProperties(environmentName,'',[])
    self.environmentList.Select(self.theSelectedIdx)
    self.assetList.setEnvironment(environmentName)
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theVulId != None):
      p = self.dbProxy.inheritedVulnerabilityProperties(self.theVulId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.sevCtrl.SetStringSelection(p.severity())
      self.assetList.setEnvironment(environmentName)
      self.assetList.load(p.assets()) 

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      self.theEnvironmentDictionary[environmentName] = VulnerabilityEnvironmentProperties(environmentName,self.sevCtrl.GetValue(),self.assetList.dimensions())
    return self.theEnvironmentDictionary.values() 
class PersonaEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.PERSONA_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.thePersonaName = ''

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.PERSONA_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = PersonaEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.directCtrl = self.notebook.FindWindowById(armid.PERSONA_CHECKDIRECT_ID)
    self.roleList = self.notebook.FindWindowById(armid.PERSONA_LISTROLES_ID)
    self.descriptionCtrl = self.notebook.FindWindowById(armid.PERSONA_TEXTNARRATIVE_ID)
    self.directCtrl.Disable()
    self.descriptionCtrl.Disable()
    self.roleList.Disable() 


  def loadControls(self,persona):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.thePersonaName = persona.name()
    environmentNames = []
    for cp in persona.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in persona.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]

    if (p.directFlag() == 'True'):
      self.directCtrl.SetValue(True)
    else:
      self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative',p.narrative())
    self.descriptionCtrl.setCodes(p.codes('narrative'))
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 

    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.directCtrl.Enable()
    self.descriptionCtrl.Enable()
    self.roleList.Enable() 
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]

    if (p.directFlag() == 'True'):
      self.directCtrl.SetValue(True)
    else:
      self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative',p.narrative())
    self.descriptionCtrl.setCodes(p.codes('narrative'))
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 
    self.directCtrl.Enable()
    self.descriptionCtrl.Enable()
    self.roleList.Enable() 

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    envCodebook = {'narrative':self.descriptionCtrl.codes()}
    self.theEnvironmentDictionary[environmentName] = PersonaEnvironmentProperties(environmentName,str(self.directCtrl.GetValue()),self.descriptionCtrl.GetValue(),self.roleList.dimensions())

    self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative','')
    self.descriptionCtrl.setCodes({})
    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems() 
    self.theSelectedIdx = -1
    self.directCtrl.Disable()
    self.descriptionCtrl.Disable()
    self.roleList.Disable() 

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = PersonaEnvironmentProperties(environmentName)
    self.environmentList.Select(self.theSelectedIdx)
    self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative','')
    self.descriptionCtrl.setCodes({})
    self.roleList.setEnvironment(environmentName)
    self.roleList.DeleteAllItems() 
    self.directCtrl.Enable()
    self.descriptionCtrl.Enable()
    self.roleList.Enable() 

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1
    self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative','')
    self.descriptionCtrl.setCodes({})
    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems() 
    self.theSelectedIdx = -1
    self.directCtrl.Disable()
    self.descriptionCtrl.Disable()
    self.roleList.Disable() 


  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      envCodebook = {'narrative':self.descriptionCtrl.codes()}
      self.theEnvironmentDictionary[environmentName] = PersonaEnvironmentProperties(environmentName,str(self.directCtrl.GetValue()),self.descriptionCtrl.GetValue(),self.roleList.dimensions(),envCodebook)
    return self.theEnvironmentDictionary.values() 
예제 #45
0
class CountermeasureEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, COUNTERMEASURE_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, COUNTERMEASURE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)

        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        costBox = wx.StaticBox(self, -1, 'Cost')
        costBoxSizer = wx.StaticBoxSizer(costBox, wx.HORIZONTAL)
        environmentDimSizer.Add(costBoxSizer, 0, wx.EXPAND)
        self.costCombo = wx.ComboBox(self,
                                     COUNTERMEASURE_COMBOCOST_ID,
                                     "",
                                     choices=['Low', 'Medium', 'High'],
                                     style=wx.CB_READONLY)
        costBoxSizer.Add(self.costCombo, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.HORIZONTAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = CountermeasureEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.reqList = self.notebook.FindWindowById(
            COUNTERMEASURE_LISTREQUIREMENTS_ID)
        self.targetList = self.notebook.FindWindowById(
            COUNTERMEASURE_LISTTARGETS_ID)
        self.propertiesList = self.notebook.FindWindowById(
            COUNTERMEASURE_LISTPROPERTIES_ID)
        self.personaList = self.notebook.FindWindowById(
            COUNTERMEASURE_LISTPERSONAS_ID)
        self.roleList = self.notebook.FindWindowById(
            COUNTERMEASURE_LISTROLES_ID)

        self.reqList.Disable()
        self.targetList.Disable()
        self.propertiesList.Disable()
        self.costCombo.Disable()
        self.roleList.Disable()

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)

    def loadControls(self, countermeasure):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        environmentNames = []
        for cp in countermeasure.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in countermeasure.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.reqList.setEnvironment(environmentName)
        self.reqList.load(p.requirements())
        self.targetList.setEnvironment(environmentName)
        self.targetList.load(p.targets())
        self.propertiesList.setEnvironment(environmentName)
        self.propertiesList.load(p.properties(), p.rationale())
        self.costCombo.SetStringSelection(p.cost())
        self.roleList.setEnvironment(environmentName)
        self.roleList.load(p.roles())
        self.personaList.load(p.personas())

        self.environmentList.Select(0)

        self.reqList.Enable()
        self.targetList.Enable()
        self.propertiesList.Enable()
        self.costCombo.Enable()
        self.roleList.Enable()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]
        self.reqList.setEnvironment(environmentName)
        self.reqList.load(p.requirements())
        self.targetList.setEnvironment(environmentName)
        self.targetList.load(p.targets())
        self.propertiesList.setEnvironment(environmentName)
        self.propertiesList.load(p.properties(), p.rationale())
        self.costCombo.SetStringSelection(p.cost())
        self.roleList.setEnvironment(environmentName)
        self.roleList.load(p.roles())
        self.personaList.load(p.personas())
        self.reqList.Enable()
        self.targetList.Enable()
        self.propertiesList.Enable()
        self.costCombo.Enable()
        self.roleList.Enable()
        self.personaList.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        syProperties, pRationale = self.propertiesList.properties()
        properties = CountermeasureEnvironmentProperties(
            environmentName, self.reqList.dimensions(),
            self.targetList.targets(), syProperties, pRationale,
            self.costCombo.GetValue(), self.roleList.dimensions(),
            self.personaList.dimensions())
        self.theEnvironmentDictionary[environmentName] = properties

        self.reqList.setEnvironment('')
        self.reqList.DeleteAllItems()
        self.targetList.setEnvironment('')
        self.targetList.DeleteAllItems()
        self.propertiesList.setEnvironment('')
        self.propertiesList.DeleteAllItems()
        self.costCombo.SetValue('')
        self.roleList.setEnvironment('')
        self.roleList.DeleteAllItems()
        self.personaList.DeleteAllItems()

        self.theSelectedIdx = -1
        self.reqList.Disable()
        self.targetList.Disable()
        self.propertiesList.Disable()
        self.costCombo.Disable()
        self.roleList.Disable()

    def OnAddEnvironment(self, evt):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            syProperties, pRationale = self.propertiesList.properties()
            properties = CountermeasureEnvironmentProperties(
                environmentName, self.reqList.dimensions(),
                self.targetList.targets(), syProperties, pRationale,
                self.costCombo.GetValue(), self.roleList.dimensions(),
                self.personaList.dimensions())
            self.theEnvironmentDictionary[environmentName] = properties
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = CountermeasureEnvironmentProperties(
                environmentName)

        self.reqList.setEnvironment(environmentName)
        self.reqList.DeleteAllItems()
        self.targetList.setEnvironment(environmentName)
        self.targetList.DeleteAllItems()
        self.propertiesList.setEnvironment(environmentName)
        self.propertiesList.DeleteAllItems()
        self.costCombo.SetValue('')
        self.roleList.setEnvironment(environmentName)
        self.roleList.DeleteAllItems()
        self.personaList.DeleteAllItems()

        self.reqList.Enable()
        self.targetList.Enable()
        self.propertiesList.Enable()
        self.costCombo.Enable()
        self.roleList.Enable()

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            syProperties, pRationale = self.propertiesList.properties()
            properties = CountermeasureEnvironmentProperties(
                environmentName, self.reqList.dimensions(),
                self.targetList.targets(), syProperties, pRationale,
                self.costCombo.GetValue(), self.roleList.dimensions(),
                self.personaList.dimensions())
            self.theEnvironmentDictionary[environmentName] = properties
        for cname in self.environmentList.dimensions():
            p = self.theEnvironmentDictionary[cname]
            if (len(p.requirements()) == 0):
                exceptionText = 'No requirements selected for environment ' + p.name(
                )
                raise ARM.EnvironmentValidationError(exceptionText)
            if (len(p.targets()) == 0):
                exceptionText = 'No targets selected for environment ' + p.name(
                )
                raise ARM.EnvironmentValidationError(exceptionText)
            if (len(p.cost()) == 0):
                exceptionText = 'No cost selected for environment ' + p.name()
                raise ARM.EnvironmentValidationError(exceptionText)
            if (len(p.roles()) == 0):
                exceptionText = 'No roles selected for environment ' + p.name()
                raise ARM.EnvironmentValidationError(exceptionText)
        return self.theEnvironmentDictionary.values()
class UseCaseEnvironmentPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, USECASE_PANELENVIRONMENT_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theUseCaseId = None
        self.theUseCaseName = ""
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self, USECASE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbBoxSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbBoxSizer, 1, wx.EXPAND)
        self.notebook = UseCaseEnvironmentNotebook(self, self.dbProxy)
        nbBoxSizer.Add(self.notebook, 1, wx.EXPAND)

        self.preCondCtrl = self.notebook.FindWindowById(USECASE_TEXTPRECONDITION_ID)
        self.postCondCtrl = self.notebook.FindWindowById(USECASE_TEXTPOSTCONDITION_ID)
        self.stepsCtrl = self.notebook.FindWindowById(USECASE_PANELFLOW_ID)

        self.SetSizer(mainSizer)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM, self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnDeleteEnvironment)
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnEnvironmentDeselected)

    def loadControls(self, uc):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theUseCaseId = uc.id()
        self.theUseCaseName = uc.name()
        environmentNames = []
        for cp in uc.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in uc.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.preCondCtrl.SetValue(p.preconditions())
        self.stepsCtrl.reloadSteps(p.steps())
        self.stepsCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.SetValue(p.postconditions())
        self.stepsCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)

        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnEnvironmentDeselected)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]

        self.preCondCtrl.SetValue(p.preconditions())
        self.stepsCtrl.reloadSteps(p.steps())
        self.postCondCtrl.SetValue(p.postconditions())
        self.stepsCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[environmentName] = UseCaseEnvironmentProperties(
            environmentName, self.preCondCtrl.GetValue(), self.stepsCtrl.steps(), self.postCondCtrl.GetValue()
        )
        self.preCondCtrl.SetValue("")
        self.stepsCtrl.clear()
        self.stepsCtrl.setEnvironment("")
        self.postCondCtrl.SetValue("")
        self.preCondCtrl.setEnvironment("")
        self.preCondCtrl.setUseCase("")
        self.postCondCtrl.setEnvironment("")
        self.postCondCtrl.setUseCase("")
        self.theSelectedIdx = -1
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[environmentName] = UseCaseEnvironmentProperties(environmentName)
        self.environmentList.Select(self.theSelectedIdx)
        self.preCondCtrl.SetValue("")
        self.stepsCtrl.setEnvironment(environmentName)
        self.stepsCtrl.clear()
        self.postCondCtrl.SetValue("")
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if inheritedEnv != "" and self.theUseCaseId != None:
            p = self.dbProxy.inheritedUseCaseProperties(self.theUseCaseId, inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.preCondCtrl.SetValue(p.preconditions())
            self.stepsCtrl.reloadSteps(p.steps())
            self.stepsCtrl.setEnvironment(environmentName)
            self.postCondCtrl.SetValue(p.preconditions())
            self.preCondCtrl.setEnvironment(environmentName)
            self.preCondCtrl.setUseCase(self.theUseCaseName)
            self.postCondCtrl.setEnvironment(environmentName)
            self.postCondCtrl.setUseCase(self.theUseCaseName)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1
        self.preCondCtrl.SetValue("")
        self.stepsCtrl.clear()
        self.stepsCtrl.setEnvironment("")
        self.postCondCtrl.SetValue("")
        self.preCondCtrl.setEnvironment("")
        self.preCondCtrl.setUseCase("")
        self.postCondCtrl.setEnvironment("")
        self.postCondCtrl.setUseCase("")
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()

    def environmentProperties(self):
        if self.theSelectedIdx != -1:
            environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
            self.theEnvironmentDictionary[environmentName] = UseCaseEnvironmentProperties(
                environmentName, self.preCondCtrl.GetValue(), self.stepsCtrl.steps(), self.postCondCtrl.GetValue()
            )
        return self.theEnvironmentDictionary.values()
class MisuseCaseEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, armid.MISUSECASE_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1
        self.theSelectedRisk = ''
        self.theSelectedThreat = ''
        self.theSelectedVulnerability = ''

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.MISUSECASE_LISTENVIRONMENTS_ID, self.dbProxy)
        self.environmentList.Unbind(wx.EVT_RIGHT_DOWN)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = MisuseCaseNotebook(self)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.SetSizer(mainSizer)

        self.objectiveCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTOBJECTIVE_ID)
        self.attackerList = self.notebook.FindWindowById(
            armid.MISUSECASE_LISTATTACKERS_ID)
        self.assetList = self.notebook.FindWindowById(
            armid.MISUSECASE_LISTASSETS_ID)
        self.threatCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTTHREAT_ID)
        self.lhoodCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTLIKELIHOOD_ID)
        self.vulCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTVULNERABILITY_ID)
        self.sevCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTSEVERITY_ID)
        self.ratingCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTSCORE_ID)
        self.narrativeCtrl = self.notebook.FindWindowById(
            armid.MISUSECASE_TEXTNARRATIVE_ID)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.narrativeCtrl.Disable()

    def unloadMCComponents(self):
        self.ratingCtrl.SetValue('')
        self.threatCtrl.SetValue('')
        self.lhoodCtrl.SetValue('')
        self.vulCtrl.SetValue('')
        self.sevCtrl.SetValue('')
        self.attackerList.DeleteAllItems()
        self.assetList.DeleteAllItems()
        self.objectiveCtrl.SetValue('')

    def loadMCComponents(self):
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.ratingCtrl.SetValue(
            self.dbProxy.riskRating(self.theSelectedThreat,
                                    self.theSelectedVulnerability,
                                    environmentName))

        self.threatCtrl.SetValue(self.theSelectedThreat)
        threatId = self.dbProxy.getDimensionId(self.theSelectedThreat,
                                               'threat')
        environmentId = self.dbProxy.getDimensionId(environmentName,
                                                    'environment')
        self.lhoodCtrl.SetValue(
            self.dbProxy.threatLikelihood(threatId, environmentId))

        self.vulCtrl.SetValue(self.theSelectedVulnerability)
        vulId = self.dbProxy.getDimensionId(self.theSelectedVulnerability,
                                            'vulnerability')
        self.sevCtrl.SetValue(
            self.dbProxy.vulnerabilitySeverity(vulId, environmentId))

        self.attackerList.DeleteAllItems()
        attackers = self.dbProxy.threatAttackers(threatId, environmentId)
        attackerSet = set(attackers)
        for atidx, attacker in enumerate(attackerSet):
            self.attackerList.InsertStringItem(atidx, attacker)

        threatenedAssets = self.dbProxy.threatenedAssets(
            threatId, environmentId)
        vulnerableAssets = self.dbProxy.vulnerableAssets(vulId, environmentId)

        objectiveText = 'Exploit vulnerabilities in '
        for idx, vulAsset in enumerate(vulnerableAssets):
            objectiveText += vulAsset
            if (idx != (len(vulnerableAssets) - 1)):
                objectiveText += ','
        objectiveText += ' to threaten '
        for idx, thrAsset in enumerate(threatenedAssets):
            objectiveText += thrAsset
            if (idx != (len(threatenedAssets) - 1)):
                objectiveText += ','
        objectiveText += '.'
        self.objectiveCtrl.SetValue(objectiveText)

        self.assetList.DeleteAllItems()
        assetSet = set(threatenedAssets + vulnerableAssets)
        for asidx, asset in enumerate(assetSet):
            self.assetList.InsertStringItem(asidx, asset)

    def loadMisuseCase(self, mc):
        self.theSelectedRisk = mc.risk()
        self.theSelectedThreat = mc.threat()
        self.theSelectedVulnerability = mc.vulnerability()

        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        environmentNames = []
        for cp in mc.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in mc.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.narrativeCtrl.SetValue(p.narrative())
        self.environmentList.Select(0)
        self.loadMCComponents()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.narrativeCtrl.Enable()
        self.theSelectedIdx = 0

    def loadRiskComponents(self, threatName, vulName):
        self.theSelectedThreat = threatName
        self.theSelectedVulnerability = vulName
        self.environmentList.Unbind(wx.EVT_LIST_INSERT_ITEM)
        self.environmentList.Unbind(wx.EVT_LIST_DELETE_ITEM)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        environments = self.dbProxy.threatVulnerabilityEnvironmentNames(
            threatName, vulName)
        for environmentName in environments:
            self.theEnvironmentDictionary[
                environmentName] = MisuseCaseEnvironmentProperties(
                    environmentName)
        self.environmentList.load(environments)
        self.environmentList.Select(0)
        self.theSelectedIdx = 0
        self.loadMCComponents()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]
        self.narrativeCtrl.SetValue(p.narrative())
        self.loadMCComponents()
        self.narrativeCtrl.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = MisuseCaseEnvironmentProperties(
                environmentName, self.narrativeCtrl.GetValue())
        self.narrativeCtrl.SetValue('')
        self.narrativeCtrl.Disable()
        self.unloadMCComponents()

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = MisuseCaseEnvironmentProperties(environmentName)
        self.environmentList.Select(self.theSelectedIdx)
        self.loadMCComponents()
        self.narrativeCtrl.Enable()

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1
        self.narrativeCtrl.SetValue('')
        self.narrativeCtrl.Disable()
        self.unloadMCComponents()

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            self.theEnvironmentDictionary[
                environmentName] = MisuseCaseEnvironmentProperties(
                    environmentName, self.narrativeCtrl.GetValue())
        return self.theEnvironmentDictionary.values()
예제 #48
0
class UseCaseEnvironmentPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, armid.USECASE_PANELENVIRONMENT_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theUseCaseId = None
        self.theUseCaseName = ''
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, armid.USECASE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbBoxSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbBoxSizer, 1, wx.EXPAND)
        self.notebook = UseCaseEnvironmentNotebook(self, self.dbProxy)
        nbBoxSizer.Add(self.notebook, 1, wx.EXPAND)

        self.preCondCtrl = self.notebook.FindWindowById(
            armid.USECASE_TEXTPRECONDITION_ID)
        self.postCondCtrl = self.notebook.FindWindowById(
            armid.USECASE_TEXTPOSTCONDITION_ID)
        self.stepsCtrl = self.notebook.FindWindowById(
            armid.USECASE_PANELFLOW_ID)

        self.SetSizer(mainSizer)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)

    def loadControls(self, uc):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theUseCaseId = uc.id()
        self.theUseCaseName = uc.name()
        environmentNames = []
        for cp in uc.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in uc.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.preCondCtrl.SetValue(p.preconditions())
        self.stepsCtrl.reloadSteps(p.steps())
        self.stepsCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.SetValue(p.postconditions())
        self.stepsCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)

        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]

        self.preCondCtrl.SetValue(p.preconditions())
        self.stepsCtrl.reloadSteps(p.steps())
        self.postCondCtrl.SetValue(p.postconditions())
        self.stepsCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = UseCaseEnvironmentProperties(
                environmentName, self.preCondCtrl.GetValue(),
                self.stepsCtrl.steps(), self.postCondCtrl.GetValue())
        self.preCondCtrl.SetValue('')
        self.stepsCtrl.clear()
        self.stepsCtrl.setEnvironment('')
        self.postCondCtrl.SetValue('')
        self.preCondCtrl.setEnvironment('')
        self.preCondCtrl.setUseCase('')
        self.postCondCtrl.setEnvironment('')
        self.postCondCtrl.setUseCase('')
        self.theSelectedIdx = -1
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = UseCaseEnvironmentProperties(environmentName)
        self.environmentList.Select(self.theSelectedIdx)
        self.preCondCtrl.SetValue('')
        self.stepsCtrl.setEnvironment(environmentName)
        self.stepsCtrl.clear()
        self.postCondCtrl.SetValue('')
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if (inheritedEnv != '' and self.theUseCaseId != None):
            p = self.dbProxy.inheritedUseCaseProperties(
                self.theUseCaseId, inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.preCondCtrl.SetValue(p.preconditions())
            self.stepsCtrl.reloadSteps(p.steps())
            self.stepsCtrl.setEnvironment(environmentName)
            self.postCondCtrl.SetValue(p.preconditions())
            self.preCondCtrl.setEnvironment(environmentName)
            self.preCondCtrl.setUseCase(self.theUseCaseName)
            self.postCondCtrl.setEnvironment(environmentName)
            self.postCondCtrl.setUseCase(self.theUseCaseName)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1
        self.preCondCtrl.SetValue('')
        self.stepsCtrl.clear()
        self.stepsCtrl.setEnvironment('')
        self.postCondCtrl.SetValue('')
        self.preCondCtrl.setEnvironment('')
        self.preCondCtrl.setUseCase('')
        self.postCondCtrl.setEnvironment('')
        self.postCondCtrl.setUseCase('')
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            self.theEnvironmentDictionary[
                environmentName] = UseCaseEnvironmentProperties(
                    environmentName, self.preCondCtrl.GetValue(),
                    self.stepsCtrl.steps(), self.postCondCtrl.GetValue())
        return self.theEnvironmentDictionary.values()
예제 #49
0
class MitigateEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.MITIGATE_PANELENVIRONMENT_ID)
    self.theResponsePanel = parent
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.MITIGATE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    typeBox = wx.StaticBox(self,-1,'Type')
    typeBoxSizer = wx.StaticBoxSizer(typeBox,wx.HORIZONTAL)
    environmentDimSizer.Add(typeBoxSizer,0,wx.EXPAND)
    self.typeCombo = wx.ComboBox(self,armid.MITIGATE_COMBOTYPE_ID,"",choices=['Deter','Prevent','Detect','React'],style=wx.CB_READONLY)
    typeBoxSizer.Add(self.typeCombo,1,wx.EXPAND)
   
    pointBox = wx.StaticBox(self,-1,'Detection Point')
    pointBoxSizer = wx.StaticBoxSizer(pointBox,wx.HORIZONTAL)
    environmentDimSizer.Add(pointBoxSizer,0,wx.EXPAND)
    self.pointCombo = wx.ComboBox(self,armid.MITIGATE_COMBODETECTIONPOINT_ID,"",choices=['Before','At','After'],style=wx.CB_READONLY)
    pointBoxSizer.Add(self.pointCombo,1,wx.EXPAND)


    dmBox = wx.StaticBox(self,-1,)
    dmBoxSizer = wx.StaticBoxSizer(dmBox,wx.HORIZONTAL)
    environmentDimSizer.Add(dmBoxSizer,1,wx.EXPAND)
    self.dmList = DimensionListCtrl(self,armid.MITIGATE_LISTDETMECH_ID,wx.DefaultSize,'Detection Mechanism','detection_mechanism',self.dbProxy,listStyle=wx.LC_REPORT)
    dmBoxSizer.Add(self.dmList,1,wx.EXPAND)

    self.typeCombo.Disable()
    self.pointCombo.Disable() 
    self.dmList.Disable()
    
    self.SetSizer(mainSizer)
    self.typeCombo.Bind(wx.EVT_COMBOBOX,self.onTypeChange)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def onTypeChange(self,evt):
    self.activateTypeCtrls()
    mitType = self.typeCombo.GetValue()
    riskCombo = self.theResponsePanel.FindWindowById(armid.RESPONSE_COMBORISK_ID)
    riskName = riskCombo.GetValue()
    if (riskName != ''):
      riskNameCtrl = self.theResponsePanel.FindWindowById(armid.RESPONSE_TEXTNAME_ID)
      riskNameLabel = mitType + ' ' + riskName
      riskNameCtrl.SetValue(riskNameLabel)

  def activateTypeCtrls(self):
    mitType = self.typeCombo.GetValue()
    if ((mitType == 'Deter') or (mitType == 'Prevent')):
      self.pointCombo.SetValue('')
      self.pointCombo.Disable() 
      self.dmList.DeleteAllItems()
      self.dmList.Disable()
    elif (mitType == 'Detect'):
      self.pointCombo.Enable() 
      self.dmList.Disable()
    elif (mitType == 'React'):
      self.pointCombo.Disable() 
      self.dmList.Enable()
  
  def loadControls(self,accept):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in accept.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in accept.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.typeCombo.SetStringSelection(p.type())
    self.pointCombo.SetStringSelection(p.detectionPoint())
    self.dmList.setEnvironment(environmentName)
    self.dmList.load(p.detectionMechanisms())

    self.environmentList.Select(0)

    self.activateTypeCtrls()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]

    self.typeCombo.SetStringSelection(p.type())
    self.pointCombo.SetStringSelection(p.detectionPoint())
    self.dmList.setEnvironment(environmentName)
    self.dmList.load(p.detectionMechanisms())
    self.typeCombo.Enable()
    self.activateTypeCtrls()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = MitigateEnvironmentProperties(environmentName,self.typeCombo.GetValue(),self.pointCombo.GetValue(),self.dmList.dimensions())
    self.typeCombo.SetValue('')
    self.pointCombo.SetValue('')
    self.dmList.setEnvironment('')
    self.dmList.DeleteAllItems()

    self.theSelectedIdx = -1
    self.typeCombo.Disable() 
    self.pointCombo.Disable() 
    self.dmList.Disable() 

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = MitigateEnvironmentProperties(environmentName)
    self.typeCombo.SetValue('')
    self.pointCombo.SetValue('')
    self.dmList.setEnvironment(environmentName)
    self.dmList.DeleteAllItems()
    self.environmentList.Select(self.theSelectedIdx)
    self.typeCombo.Enable() 

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      properties = MitigateEnvironmentProperties(environmentName,self.typeCombo.GetValue(),self.pointCombo.GetValue(),self.dmList.dimensions())
      self.theEnvironmentDictionary[environmentName] = properties
    for cname in self.environmentList.dimensions():
      p = self.theEnvironmentDictionary[cname]
      mitType = p.type()
      if (len(mitType) == 0):
        exceptionText = 'No mitigation type selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
      if (mitType == 'Detect') and (len(p.detectionPoint()) == 0):
        exceptionText = 'No detection point selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
      if (mitType == 'React') and (len(p.detectionMechanisms()) == 0):
        exceptionText = 'No detection mechanisms selected for environment ' + p.name()
        raise ARM.EnvironmentValidationError(exceptionText)
    return self.theEnvironmentDictionary.values()