Beispiel #1
0
    def setUp(self):
        # region Class fields
        self.logger = logging.getLogger(__name__)

        self.existing_countermeasure_name = 'Location-based X.509 extension'
        self.existing_countermeasure_type = 'Information'
        self.existing_countermeasure_description = 'X.509 certificates extended to tie client workstations so NeuroGrid tasks can only be carried out on these.'
        self.existing_environment_name = 'Psychosis'
        self.existing_requirements = ['User certificate addressability']
        self.existing_targets = [
            CountermeasureTarget('Certificate Ubiquity', 'High',
                                 'Discourages certificate sharing')
        ]
        self.existing_properties = []
        self.existing_rationale = [
            'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None'
        ]
        self.existing_cost = 'Medium'
        self.existing_roles = ['Data Consumer', 'Certificate Authority']
        self.existing_personas = [
            CountermeasureTaskCharacteristics('Upload data', 'Claire', 'None',
                                              'None', 'None', 'Low Hindrance'),
            CountermeasureTaskCharacteristics('Download data', 'Claire',
                                              'None', 'None', 'None',
                                              'Low Hindrance')
        ]

        countermeasure_class = Countermeasure.__module__ + '.' + Countermeasure.__name__
Beispiel #2
0
 def convert_props(self, real_props=None, fake_props=None):
   new_props = []
   if real_props is not None:
     if len(real_props) > 0:
       for real_prop in real_props:
         assert isinstance(real_prop, CountermeasureEnvironmentProperties)
         ctList = []
         for ctc in real_prop.personas():
           ctList.append(CountermeasureTaskCharacteristics(ctc[0],ctc[1],ctc[2],ctc[3],ctc[4],ctc[5]))
         real_prop.thePersonas = ctList
         assert len(real_prop.theProperties) == len(real_prop.theRationale)
         new_attrs = []
         for idx in range(0, len(real_prop.theProperties)):
           attr_name = self.rev_attr_dict.get(idx)
           attr_value = self.prop_dict[real_prop.theProperties[idx]]
           attr_rationale = real_prop.theRationale[idx]
           new_attr = SecurityAttribute(attr_name, attr_value, attr_rationale)
           new_attrs.append(new_attr)
         real_prop.theProperties = new_attrs
         new_targets = []
         for idx in range(0, len(real_prop.theTargets)):
           tName = real_prop.theTargets[idx].name()
           tEff = real_prop.theTargets[idx].effectiveness()
           tRat = real_prop.theTargets[idx].rationale()
           new_targets.append(CountermeasureTarget(tName,tEff,tRat))
         real_prop.theTargets = new_targets
         new_props.append(real_prop)
     return new_props
   elif fake_props is not None:
     if len(fake_props) > 0:
       for fake_prop in fake_props:
         check_required_keys(fake_prop, CountermeasureEnvironmentPropertiesModel.required)
         ctList = []
         for ctc in fake_prop['thePersonas']:
           ctList.append([ctc['theTask'],ctc['thePersona'],ctc['theDuration'],ctc['theFrequency'],ctc['theDemands'],ctc['theGoalConflict']])
         fake_prop['thePersonas'] = ctList
         new_ndprops = array([0]*8).astype(numpy.core.int32)
         new_ratios = ['None']*8
         for idx in range(0, len(fake_prop['theProperties'])):
           new_attr = fake_prop['theProperties'][idx]
           check_required_keys(new_attr, SecurityAttribute.required)
           attr_id = self.attr_dict.get(new_attr['name'], -1)
           if -1 < attr_id < len(self.attr_dict):
             attr_value = self.rev_prop_dict[new_attr['value']]
             attr_rationale = new_attr['rationale']
             new_ndprops[attr_id] = attr_value
             new_ratios[attr_id] = attr_rationale
         fake_prop['theProperties'] = new_ndprops
         fake_prop['theRationale'] = new_ratios
         new_targets = []
         for idx in range(0, len(fake_prop['theTargets'])):
           tName = fake_prop['theTargets'][idx]['theName']
           tEff = fake_prop['theTargets'][idx]['theEffectiveness']
           tRat = fake_prop['theTargets'][idx]['theRationale']
           new_targets.append(CountermeasureTarget(tName,tEff,tRat))
         fake_prop['theTargets'] = new_targets
         check_required_keys(fake_prop, CountermeasureEnvironmentPropertiesModel.required)
         new_prop = CountermeasureEnvironmentProperties(
                      environmentName=fake_prop['theEnvironmentName'],
                      requirements=fake_prop['theRequirements'],
                      targets=fake_prop['theTargets'],
                      properties=fake_prop['theProperties'],
                      rationale=fake_prop['theRationale'],
                      cost=fake_prop['theCost'],
                      roles=fake_prop['theRoles'],
                      personas=fake_prop['thePersonas']
                    )
         new_props.append(new_prop)
     return new_props
   else:
     self.close()
     raise MissingParameterHTTPError(param_names=['real_props', 'fake_props'])