def create_in_dir(num, path_to_dir, aRstr):
    if num < 0:
        return
    print("create_in_dir(%i, %s)" % (num, path_to_dir))
    files_in_dir = os.listdir(path_to_dir)
    name = "%s.fart" % (aRstr.rstr(rstr.letters()))
    recurse_dir = []
    errrs = 0
    for itera in range(num):
        if itera % 1000 == 0:
            print("%i of %i " % (itera, num))
        try:
            if name not in files_in_dir:
                with open(name, 'x') as f:
                    #print('\tcreated file: %s' % (name))
                    for _ in range(100):
                        f.write(aRstr.rstr(rstr.letters()))
                        f.write('\n')
                    files_in_dir.append(name)
            else:
                errrs += 1
            name = "%s.fart" % (aRstr.rstr(rstr.letters()))
        except FileExistsError:
            files_in_dir.append(name)
            errrs += 1
            name = "%s.fart" % (aRstr.rstr(rstr.letters()))
        except FileNotFoundError:
            print("File wasn't found?!? (FileNotFoundError). Filename: `%s`" % name)
            errrs += 1
            name = "%s.fart" % (aRstr.rstr(rstr.letters()))
    print("%i errors occurred while processing....\n\n\n\n\n\n\n" % errrs)
def create_in_dir(num, path_to_dir, aRstr):
    if num < 0:
        return
    print("create_in_dir(%i, %s)" % (num, path_to_dir))
    files_in_dir = os.listdir(path_to_dir)
    name = "%s.fart" % (aRstr.rstr(rstr.letters()))
    recurse_dir = []
    errrs = 0
    for itera in range(num):
        if itera % 1000 == 0:
            print("%i of %i " % (itera, num))
        try:
            if name not in files_in_dir:
                with open(name, 'x') as f:
                    #print('\tcreated file: %s' % (name))
                    for _ in range(100):
                        f.write(aRstr.rstr(rstr.letters()))
                        f.write('\n')
                    files_in_dir.append(name)
            else:
                errrs += 1
            name = "%s.fart" % (aRstr.rstr(rstr.letters()))
        except FileExistsError:
            files_in_dir.append(name)
            errrs += 1
            name = "%s.fart" % (aRstr.rstr(rstr.letters()))
        except FileNotFoundError:
            print("File wasn't found?!? (FileNotFoundError). Filename: `%s`" %
                  name)
            errrs += 1
            name = "%s.fart" % (aRstr.rstr(rstr.letters()))
    print("%i errors occurred while processing....\n\n\n\n\n\n\n" % errrs)
예제 #3
0
 def getRandom(self, choice):
     if self.dataConf.pattern == 'Random_normal':
         if self.dataConf.minimum is None and self.dataConf.maximum is None:
             return ''.join(random.SystemRandom().choice(choice)
                            for _ in range(10))
         elif self.dataConf.maximum is None:
             return ''.join(random.SystemRandom().choice(choice)
                            for _ in range(int(self.dataConf.minimum)))
         else:
             range_length = random.randint(int(self.dataConf.minimum),
                                           int(self.dataConf.maximum))
             return ''.join(random.SystemRandom().choice(choice)
                            for _ in range(range_length))
     elif self.dataConf.pattern == 'E_Mail':
         return '{0}@{1}.{2}'.format(rstr.domainsafe(), rstr.domainsafe(),
                                     rstr.letters(3))
     elif self.dataConf.pattern == 'Postal_Address':
         return """{0} {1} {2} {3} {4}, {5} {6} """.format(
             rstr.letters(4, 8).title(),
             rstr.letters(4, 8).title(), rstr.digits(3, 5),
             rstr.letters(4, 10).title(),
             rstr.letters(4, 15).title(), rstr.uppercase(2), rstr.digits(5))
     elif self.dataConf.pattern == 'User_Name':
         return '{0} {1}'.format(
             rstr.letters(4, 15).title(),
             rstr.letters(4, 10).title())
     elif self.dataConf.pattern == 'Url_address':
         return 'http://{0}.{1}/{2}/?{3}'.format(rstr.domainsafe(),
                                                 rstr.letters(3),
                                                 rstr.urlsafe(),
                                                 rstr.urlsafe())
     else:
         return "XXXXX"
def generate_user(num: int):
    """
    This function will generate random user details (for a single user)
    :param num: User number
    :return: Details of the user
    """
    user = []
    firstname = faker.first_name()
    username = gen_user_n_pw(firstname, num)
    user.append(username)
    user.append(username)
    user.append(firstname)
    user.append(faker.last_name())
    user.append(faker.company())
    user.append(faker.country())
    user.append(firstname.lower() + str(num) + '@gmail.com')
    user.append(faker.phone_number())
    user.append(faker.phone_number())
    user.append(firstname.lower() + str(num))
    user.append('http://{0}.{1}.com/{2}/?{3}'.format(rstr.domainsafe(),
                                                     rstr.letters(3),
                                                     rstr.urlsafe(),
                                                     rstr.urlsafe()))

    return user
예제 #5
0
def generateUser(num: int):
    """
    This function will generate random user details (for a single user)
    :param num: User number
    :return: Dictionary containing details of the user
    """
    user = {}
    firstname = faker.first_name()
    username = genUsernamePassword(firstname, num)
    user['username'] = username
    user['password'] = username
    user['firstname'] = firstname
    user['lastname'] = faker.last_name()
    user['organization'] = faker.company()
    user['country'] = faker.country()
    user['email'] = firstname.lower() + str(num) + '@gmail.com'
    user['no_land'] = faker.phone_number()
    user['no_mobile'] = faker.phone_number()
    user['IM'] = firstname.lower() + str(num)
    user['url'] = 'http://{0}.{1}.com/{2}/?{3}'.format(rstr.domainsafe(),
                                                       rstr.letters(3),
                                                       rstr.urlsafe(),
                                                       rstr.urlsafe())
    user['applications'] = None

    return user
예제 #6
0
def gen_urls():
    reg_str = 'ABC'
    reg_str = r'[A-Z]\d[A-Z] \d[A-Z]\d'
    reg_str = '!"#$%&\'()*+,-./@:;<=>[\\]^_`{|}~'
    #reg_str = "((https?://|ftp://|www\.|[^\s:=]+@www\.).*?[a-z_\/0-9\-\#=&])(?=(\.|,|;|\?|\!)?(\"|'|«|»|\[|\s|\r|\n|$))"
    #reg_str = "https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,}"
    #reg_str = "http?[12345]"
    #reg_str = "(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?"
    #reg_str = "(\b(https?)://)?www\.[-A-Za-z0-9+?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"
    reg_str = "^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$"
    reg_str = 'http://{0}.{1}/{2}/?{3}'.format(rstr.domainsafe(),
                                               rstr.letters(3), rstr.urlsafe(),
                                               rstr.urlsafe())
    #reg_str = "((https?://)?)www\.(([a-z_0-9\-\#=&]{4,10})\.){1,3}(com|cn|org|edu|com\.cn|net|xin|cc|tech|top|info|gov)"
    #reg_str = "((https?://)?)(www\.)?(([a-z_0-9\-]{4,10})\.){1,3}(com|cn|org|edu|com\.cn|net|xin|cc|tech|top|info|gov)"
    #reg_str = "((https?://)?)(www\.)?(([a-z_0-9\-]{4,10})\.){1,2}(com|cn|org|edu|com\.cn|net|xin|cc|tech|top|info|gov)"

    #reg_str = "((https?://)?)(www\.)?(([a-z_0-9\-]{3,6})\.){1,2}(com|cn|org|edu|com\.cn|net|xin|cc|tech|top|info|gov)"

    #reg_str_1 = "((https?://)?)(www\.)?(([a-z_0-9\-]{4,8})\.){1}(com|cn|org|edu|com\.cn|net|xin|cc|tech|top|info|gov)"
    #reg_str_2 = "((https?://)?)(www\.)?(([a-z_0-9\-]{3,4})\.){2}(com|cn|org|edu|com\.cn|net|xin|cc|tech|top|info|gov)"

    s = rstr.rstr(reg_str, 6, 20)
    s = rstr.xeger(reg_str)
    #print s
    return s
예제 #7
0
파일: demo.py 프로젝트: jdukes/ilwrathi
 def get_pet(self):
     pet_d = {
         "id": randint(100, 500),
         "category": {
             "id": randint(100, 500),
             "name": rstr.letters(5),
         },
         "name": rstr.letters(5),
         "photoUrls": [""],
         "tags": [{
             "id": 0,
             "name": rstr.letters(5)
         }],
         "status": ""
     }
     resp = self.client.post_pet(pet_d)
     assert resp.status_code == 200, "shit broke"
     return pet_d
예제 #8
0
    def create_random_text_file(self, filename: str):
        """Create a text file with some random contents."""

        content = ''

        for x in range(1, 10):
            content += rstr.letters(0, 79)
            content += '\n'

        with open(filename, 'w+') as generated_file:
            generated_file.write(content)
예제 #9
0
파일: demo.py 프로젝트: jdukes/ilwrathi
 def get_pet(self):
     pet_d = {"id": randint(100, 500),
              "category": {
                  "id": randint(100, 500),
                  "name": rstr.letters(5),
              },
              "name": rstr.letters(5),
              "photoUrls": [
                  ""
              ],
              "tags": [
                  {
                      "id": 0,
                      "name": rstr.letters(5)
                  }
              ],
              "status": ""}
     resp = self.client.post_pet(pet_d)
     assert resp.status_code == 200, "shit broke"
     return pet_d
def generateUser(num: int):
    user = []
    firstname = faker.first_name()
    username = genUnPw(firstname, num)
    user.append(username)
    user.append(username)
    user.append(firstname)
    user.append(faker.last_name())
    user.append(faker.company())
    user.append(faker.country())
    user.append(firstname.lower() + str(num) + '@gmail.com')
    user.append(faker.phone_number())
    user.append(faker.phone_number())
    user.append(firstname.lower() + str(num))
    user.append('http://{0}.{1}.com/{2}/?{3}'.format(rstr.domainsafe(),
                                                     rstr.letters(3),
                                                     rstr.urlsafe(),
                                                     rstr.urlsafe()))

    return user
 def getRandom(self,choice):
     if self.dataConf.pattern == 'Random_normal':
         if self.dataConf.minimum is None and self.dataConf.maximum is None:
             return ''.join(random.SystemRandom().choice(choice) for _ in range(10))
         elif self.dataConf.maximum is None:
             return ''.join(random.SystemRandom().choice(choice) for _ in range(int(self.dataConf.minimum)))                       
         else:
             range_length=random.randint(int(self.dataConf.minimum),int(self.dataConf.maximum))
             return ''.join(random.SystemRandom().choice(choice) for _ in range(range_length))       
     elif self.dataConf.pattern == 'E_Mail':                                    
         return '{0}@{1}.{2}'.format(rstr.domainsafe(),rstr.domainsafe(),rstr.letters(3))
     elif self.dataConf.pattern == 'Postal_Address':                                    
         return """{0} {1} {2} {3} {4}, {5} {6} """.format(rstr.letters(4, 8).title(),rstr.letters(4, 8).title(),
                                                           rstr.digits(3, 5),rstr.letters(4, 10).title(),
                                                           rstr.letters(4, 15).title(),rstr.uppercase(2),rstr.digits(5))
     elif self.dataConf.pattern == 'User_Name':
         return '{0} {1}'.format(rstr.letters(4, 15).title(),rstr.letters(4, 10).title())  
     elif self.dataConf.pattern == 'Url_address':
         return 'http://{0}.{1}/{2}/?{3}'.format(rstr.domainsafe(),rstr.letters(3),rstr.urlsafe(),rstr.urlsafe())    
     else:
         return "XXXXX"
예제 #12
0
 def test_convenience_function(self):
     assert re.match(r'^[a-zA-Z]+$', rstr.letters())
예제 #13
0
 def test_convenience_function(self):
     assert re.match(r"^[a-zA-Z]+$", rstr.letters())
예제 #14
0
import random
import rstr


"""
:type: str

Domain of service that fuzzer tests
"""

req_types = [random.randint(1, 10 ** 9), -random.randint(1, 10 ** 9),
             random.randint(10 ** 50, 10 ** 100),
             -random.randint(10 ** 50, 10 ** 100),
             random.uniform(0.0, 5.0), -random.uniform(0.0, 5.0), 0,
             rstr.letters(1, 64),
             rstr.letters(65, 256), rstr.nonwhitespace(1, 64),
             rstr.nonwhitespace(65, 256),
             rstr.letters(257, 2000), rstr.nonwhitespace(257, 2000),
             int(bool(random.getrandbits(1))),
             'абвгдеёжзийклмнопрстуфхцчшщъыьэюя']
"""
:type: list

Contains parameters of different types(str, int, long int),
that our fuzzer places as a QueryParameter or UriParameter in request methods 
from RAML specification to identify incorrect error codes
"""

types = {
    'uuid': r'^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-['