47 lines
1.4 KiB
Markdown
47 lines
1.4 KiB
Markdown
Experience source file for analysing the AST of Python programs using RegEx.
|
|
|
|
## Installation
|
|
The Python RegEx module should be include in Python. Use Python 3.7+.
|
|
|
|
## Quick start
|
|
Create a new Python file called `flaw_1.py`. Inside you should import the `re` module and write your regex checker.
|
|
The file should look like this:
|
|
```python
|
|
import re
|
|
|
|
def detect_flaw_1(code):
|
|
...
|
|
```
|
|
|
|
After creating the regex, add it to the list of regex in the file [detect_flaws.py](detect_flaws.py).
|
|
To run the code, use `python detect_flaws.py`. All the result should be in the file `result.csv`.
|
|
|
|
## Structure
|
|
### File structure
|
|
Keep the structure simple.
|
|
|
|
```
|
|
code/
|
|
flaw_1.py
|
|
...
|
|
flaw_n.py
|
|
detect_flaws.py
|
|
readme.md
|
|
result.csv
|
|
```
|
|
|
|
### CSV structure
|
|
Please keep the structure of the output csv file.
|
|
```
|
|
code;flaw_1;flaw_2;...;flaw_n
|
|
code1;True;False;...;False
|
|
...
|
|
coden;False;True;...False
|
|
```
|
|
|
|
### [detect_flaws.py](detect_flaws.py) structure
|
|
You can change this file as you want. But as said before, please keep the same output format in the csv.
|
|
The example function `detect_hardcoded_list(code)` can be changed. The number and the type of the arguments can be changed. You can also write some python code to help you detect the flaws but the main detection should be done by the RegEx.
|
|
|
|
## Result
|
|
At the end, please provide all the content of this folder. Even unfinished code will be useful! All the code is anonymous. |