Do something fuzzing with acceptableRegex.py

If you use a library called acceptableRegex.py, you can get a string that matches the regular expression. You can use the results to do something like fuzzing.

Installation

Get the file from github.

$ git clone https://github.com/tokoroten/acceptableRegex.git

How to Use

Place the obtained acceptableRegex.py in a place where PYTHONPATH passes, or Place it in the same directory as the script you are creating.

The usage is in main () of acceptableRegex.py, If you pass a regular expression to getAcceptableRegex, it will return a matching result.

from acceptableRegex import getAcceptableRegex

if __name__ == '__main__':
    print getAcceptableRegex('[0-9]{9}')

This sample returns a 9-digit number from 0 to 9.

Make a nice CSV

Using the result of acceptableRegex.py, It seems that it can be used in tests such as programs that read CSV and do something.

sample.py


# -*- coding: utf-8 -*-

import csv

from acceptableRegex import getAcceptableRegex

if __name__ == '__main__':
    with open('eggs.csv', 'wb') as f:
        csvfile = csv.writer(f)
        for x in range(1, 100):
            syouhin = getAcceptableRegex('[a-zA-Z]{10}')
            price = getAcceptableRegex('[01]{1}[0-9]{3}')
            category = getAcceptableRegex('(aaa|bbb|ccc|fff)')
            csvfile.writerow([syouhin, price, category])

Recommended Posts

Do something fuzzing with acceptableRegex.py
Do Houdini with Python3! !! !!
Do Django with CodeStar (Python3.6.8, Django2.2.9)
Do AES encryption with DJango
Let's do R-CNN with Sklearn-theano
Do multi-stage SSH with Fabric
[Alibaba Cloud] Do something like SSI even with OSS / Function Compute
Do not switch with pyenv global!
To do tail recursion with Python2
What to do with PYTHON release?
Python | What you can do with Python
Do something object-oriented in GO language