Ejemplo n.º 1
0
def generate_system_facts(name=None):
    """Generate random system facts for registration.

    :param str name: A valid FQDN for a system. If one is not
        provided, then a random value will be generated.
    :return: A dictionary with random system facts
    :rtype: dict
    """
    if name is None:
        name = f'{gen_alpha().lower()}.example.net'

    # Make a copy of the system facts 'template'
    new_facts = copy.deepcopy(SYSTEM_FACTS)
    # Select a random RHEL version...
    distro = gen_choice(DISTRO_IDS)

    # ...and update our facts
    new_facts['distribution.id'] = distro['id']
    new_facts['distribution.version'] = distro['version']
    new_facts['dmi.bios.relase_date'] = _bios_date().strftime('%m/%d/%Y')
    new_facts['dmi.memory.maximum_capacity'] = gen_choice(MEMORY_CAPACITY)
    new_facts['dmi.memory.size'] = gen_choice(MEMORY_SIZE)
    new_facts['dmi.system.uuid'] = gen_uuid()
    new_facts['dmi.system.version'] = 'RHEL'
    new_facts['lscpu.architecture'] = distro['architecture']
    new_facts['net.interface.eth1.hwaddr'] = gen_mac(multicast=False)
    new_facts['net.interface.eth1.ipaddr'] = gen_ipaddr()
    new_facts['network.hostname'] = name
    new_facts['network.ipaddr'] = new_facts['net.interface.eth1.ipaddr']
    new_facts['uname.machine'] = distro['architecture']
    new_facts['uname.nodename'] = name
    new_facts['uname.release'] = distro['kernel']
    new_facts['virt.uuid'] = new_facts['dmi.system.uuid']

    return new_facts
Ejemplo n.º 2
0
    def test_gen_uuid_1(self):
        """
        @Test: Create a random UUID4 value
        @Feature: UUID Generator
        @Assert: A random UUID value is generated
        """

        for turn in range(100):
            result = gen_uuid()
            self.assertGreater(
                len(result), 0,
                "A valid UUID value was not generated.")
Ejemplo n.º 3
0
def generate_system_facts(name=None):
    """Generate random system facts for registration.

    :param str name: A valid FQDN for a system. If one is not
        provided, then a random value will be generated.
    :return: A dictionary with random system facts
    :rtype: dict
    """
    if name is None:
        name = u'{0}.example.net'.format(
            gen_alpha().lower())

    # Make a copy of the system facts 'template'
    new_facts = copy.deepcopy(SYSTEM_FACTS)
    # Select a random RHEL version...
    distro = gen_choice(DISTRO_IDS)

    # ...and update our facts
    new_facts['distribution.id'] = distro['id']
    new_facts['distribution.version'] = distro['version']
    new_facts['dmi.bios.relase_date'] = _bios_date().strftime('%m/%d/%Y')
    new_facts['dmi.memory.maximum_capacity'] = gen_choice(
        MEMORY_CAPACITY)
    new_facts['dmi.memory.size'] = gen_choice(MEMORY_SIZE)
    new_facts['dmi.system.uuid'] = gen_uuid()
    new_facts['dmi.system.version'] = u'RHEL'
    new_facts['lscpu.architecture'] = distro['architecture']
    new_facts['net.interface.eth1.hwaddr'] = gen_mac()
    new_facts['net.interface.eth1.ipaddr'] = gen_ipaddr()
    new_facts['network.hostname'] = name
    new_facts['network.ipaddr'] = new_facts['net.interface.eth1.ipaddr']
    new_facts['uname.machine'] = distro['architecture']
    new_facts['uname.nodename'] = name
    new_facts['uname.release'] = distro['kernel']
    new_facts['virt.uuid'] = new_facts['dmi.system.uuid']

    return new_facts
Ejemplo n.º 4
0
def random_uuid_as_string():
    """Creates a random uuid and returns is as a string"""
    return fauxfactory.gen_uuid()
Ejemplo n.º 5
0
    def brute(self):
        """Run the brute force thing."""
        parser = argparse.ArgumentParser()
        parser.add_argument(
            "-e",
            "--entities",
            type=str,
            nargs='+',
            help="The name of the entity(s) you want to test (Product; All).")
        parser.add_argument("-o",
                            "--output-path",
                            type=str,
                            help="The file path to write the test tasks to.")
        parser.add_argument("-i",
                            "--import-path",
                            type=str,
                            help="The file path to exported test tasks.")
        parser.add_argument("-l",
                            "--log-name",
                            type=str,
                            default="session{0}.log".format(gen_uuid()[:8]),
                            help="The file name to write test results to.")
        parser.add_argument("--max-fields",
                            type=int,
                            help="The maximum number of entity fields to use.")
        parser.add_argument("--max-inputs",
                            type=int,
                            help="The maximum number of input methods to use.")
        parser.add_argument(
            "--field-exclude",
            type=str,
            nargs='+',
            help="One or more fields to exclude from brute force testing. "
            "(e.g. 'label id'")
        parser.add_argument(
            "--method-exclude",
            type=str,
            nargs='+',
            help="One or more methods to exclude from brute force testing. "
            "(e.g. 'raw search read get payload')")
        parser.add_argument("--debug",
                            action="store_true",
                            help="Enable debug loggin level.")

        args = parser.parse_args(sys.argv[2:])
        self.conf.load_cli_args(args, command=True)
        self.conf.init_logger(path='logs/{}'.format(args.log_name),
                              level='debug' if args.debug else None)

        if args.import_path:
            tests = TaskManager.import_tasks(args.import_path)
            TaskManager.run_tests(tests=tests)
        else:
            for entity in args.entities:
                e_tester = EntityTester(entity)
                e_tester.prep(field_exclude=args.field_exclude,
                              method_exclude=args.method_exclude)
                tests = e_tester.brute_force(max_fields=args.max_fields,
                                             max_inputs=args.max_inputs)
                if args.output_path:
                    TaskManager.export_tasks(path=args.output_path,
                                             tasks=tests)
                else:
                    TaskManager.run_tests(tests=tests)
Ejemplo n.º 6
0
def random_uuid_as_string():
    """Creates a random uuid and returns is as a string"""
    return fauxfactory.gen_uuid()