mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 08:21:52 +09:00
[Update] save vuln report logic
This commit is contained in:
parent
062552d3d8
commit
3a1422a2f2
9 changed files with 121 additions and 190 deletions
|
|
@ -1,14 +1,16 @@
|
|||
# save as data/report.csv
|
||||
import os
|
||||
import csv
|
||||
from typing import List, Dict, Any
|
||||
from mitmproxy import http
|
||||
import lib.cur_target_url as cur_target_url
|
||||
|
||||
# target, status, title, description, uri
|
||||
|
||||
# file path는 'data/report.csv'로 고정
|
||||
def save_report(report_data: List[Dict[str, Any]], file_path: str = 'data/report.csv') -> None:
|
||||
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
||||
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에 추가로 저장합니다.
|
||||
|
|
@ -23,10 +25,10 @@ def save_report(report_data: List[Dict[str, Any]], file_path: str = 'data/report
|
|||
if not file_exists:
|
||||
writer.writeheader()
|
||||
|
||||
for row in report_data:
|
||||
# None 방지 & 줄바꿈 이스케이프
|
||||
escaped = {
|
||||
k: str(v).replace('\n', '\\n') if v is not None else ''
|
||||
for k, v in row.items()
|
||||
}
|
||||
writer.writerow(escaped)
|
||||
writer.writerow({
|
||||
'target': cur_target_url.load(),
|
||||
'status': status,
|
||||
'title': title,
|
||||
'description': desc,
|
||||
'uri': uri,
|
||||
})
|
||||
|
|
|
|||
10
lib/utils/is_oauth_uri.py
Normal file
10
lib/utils/is_oauth_uri.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
def is_oauth_uri(uri: str) -> bool:
|
||||
qs = parse_qs(urlparse(uri).query)
|
||||
qs_keys = [*qs]
|
||||
|
||||
if "client_id" in qs_keys and any(p in qs_keys for p in (
|
||||
"redirect_uri", "response_type", "grant_type", "scope", "state", "nonce")):
|
||||
return True
|
||||
return False
|
||||
Loading…
Add table
Add a link
Reference in a new issue