mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 07:51:51 +09:00
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# save as data/report.csv
|
|
import os
|
|
import csv
|
|
from mitmproxy import http
|
|
import lib.cur_target_url as cur_target_url
|
|
|
|
# target, status, title, description, uri
|
|
|
|
# file path는 'data/report.csv'로 고정
|
|
def report_vuln(title: str, desc: str, status: str, uri: str) -> None:
|
|
file_path: str = 'data/report.csv'
|
|
|
|
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
|
|
|
"""
|
|
report_data 안의 각 레포트를 한 줄씩 CSV에 추가로 저장합니다.
|
|
파일이 없으면 헤더를 먼저 쓰고, 있으면 레코드만 이어서 씁니다.
|
|
"""
|
|
fieldnames = ['target', 'status', 'title', 'description', 'uri']
|
|
file_exists = os.path.exists(file_path)
|
|
|
|
with open(file_path, mode='a', newline='', encoding='utf-8') as csvfile:
|
|
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
|
# 파일이 없던 새로 만들 때만 헤더 작성
|
|
if not file_exists:
|
|
writer.writeheader()
|
|
|
|
writer.writerow({
|
|
'target': cur_target_url.load(),
|
|
'status': status,
|
|
'title': title,
|
|
'description': desc,
|
|
'uri': uri,
|
|
})
|