Пример #1
0
    def __init__(self, requests=[]):
        """ Instantiates a collection of requests.

        @param requests: List of Request class objects.
        @type  requests: List

        """
        if requests:
            # This request constructor should always be empty;
            # the interface exists for compatibility reasons only.
            raise Exception(
                "Attempting to initialize RequestCollection with a pre-defined"
                " list of Request objects. This is not allowed. The interface is in place for"
                " compatibility reasons only.")

        # grammar name (if applicable).
        self._grammar_name = ''

        # Request objects that comprise current sequence
        self._requests = []

        # Groupings of requests with their request ids
        self._request_id_collection = dict()

        # pointer to shared global pool of candidate values
        self.candidate_values_pool = primitives.CandidateValuesPool()
 def test_max_combinations_in_settings(self):
     settings_file = {'settings_file_exists': True, 'max_combinations': 10}
     settings = RestlerSettings(settings_file)
     candidate_values = primitives.CandidateValuesPool()
     test_dict = {}
     candidate_values.set_candidate_values(test_dict)
     self.assertEqual(10, settings.max_combinations)
Пример #3
0
    def test_checkers_in_settings(self):
        settings_file = {
                    'settings_file_exists':True,
                    'checkers' :
                    {
                        'NamespaceRule' : {
                            'mode' : 'exhaustive'
                        },
                        'useafterfree' : {
                            'mode' : 'exhaustive'
                        },
                        'leakagerule' : {
                            'mode' : 'exhaustive'
                        },
                        'resourcehierarchy' : {
                            'mode' : 'exhaustive'
                        }
                    }
                }

        settings = RestlerSettings(settings_file)
        candidate_values = primitives.CandidateValuesPool()
        test_dict = {
                    }
        candidate_values.set_candidate_values(test_dict)
        self.assertEqual('exhaustive', settings.get_checker_arg('namespacerule', 'mode'))
        self.assertEqual('exhaustive', settings.get_checker_arg('USEAFTERFREE', 'mode'))
        self.assertEqual('exhaustive', settings.get_checker_arg('LeakageRule', 'mode'))
        self.assertEqual('exhaustive', settings.get_checker_arg('resourcehierarchy', 'mode'))
        self.assertEqual(None, settings.get_checker_arg('namespace_rule_mode', 'mode'))
        self.assertEqual(None, settings.get_checker_arg('use_after_free_rule_mode', 'mode'))
        self.assertEqual(None, settings.get_checker_arg('leakage_rule_mode', 'mode'))
        self.assertEqual(None, settings.get_checker_arg('resource_hierarchy_rule_mode', 'mode'))