mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 05:21:51 +09:00
[Refactor and Enhance] addon init.py의 비동기 작업을 더욱 효율적으로 수행
This commit is contained in:
parent
58d5deb435
commit
0d81fdd49f
7 changed files with 58 additions and 155 deletions
43
README.md
43
README.md
|
|
@ -51,47 +51,36 @@ http://localhost:11081로 백엔드 서버가 열리게 됩니다.
|
|||
`./addon/init.py`
|
||||
|
||||
```py
|
||||
from example_check import Example
|
||||
|
||||
class LoggerAddon:
|
||||
def __init__(self):
|
||||
self.checker = Example()
|
||||
|
||||
def request(self, flow: http.HTTPFlow): # 비동기가 필요할 경우 async def로 할 것
|
||||
# 오탐 검사하고 있을때는 검증하지 않음
|
||||
...
|
||||
async def request(self, flow: http.HTTPFlow):
|
||||
if false_true_varifing_task.is_verifing_false_true():
|
||||
return
|
||||
self.checker.test(flow)
|
||||
|
||||
def response(self, flow: http.HTTPFlow): # 비동기가 필요할 경우 async def로 할 것
|
||||
# 오탐 검사하고 있을때는 검증하지 않음
|
||||
if false_true_varifing_task.is_verifing_false_true():
|
||||
return
|
||||
self.checker.test(flow)
|
||||
|
||||
tasks = [
|
||||
try_catch(self.google_login_hint.request(flow)) if self.google_login_hint else None,
|
||||
try_catch(PKCEDowngradeChecker().test(flow)),
|
||||
try_catch(Example().test(flow))
|
||||
]
|
||||
await asyncio.gather(*tasks)
|
||||
...
|
||||
```
|
||||
|
||||
`./addon/example.py`
|
||||
|
||||
```py
|
||||
import lib.target as target
|
||||
from lib.report import save_report
|
||||
from lib.report_vuln import report_vuln
|
||||
|
||||
class Example:
|
||||
async def test(self, flow):
|
||||
req = flow.request
|
||||
method = req.method
|
||||
url = req.pretty_url
|
||||
|
||||
# data/report.csv에 저장
|
||||
report_data = [{
|
||||
'target': target.load(),
|
||||
'status': "CRITICAL",
|
||||
'title': "PKCE Downgrade Vulnerability",
|
||||
'description': "PKCE downgrade vulnerability detected! Both URLs returned authorization code.",
|
||||
'uri': f"Original: {url}\nDowngraded: {downgraded_url}"
|
||||
}]
|
||||
save_report(report_data)
|
||||
report_vuln(
|
||||
title="PKCE Plain Method",
|
||||
desc="PKCE method is set to 'plain'. Possible downgrade.",
|
||||
status="CRITICAL",
|
||||
uri=url,
|
||||
)
|
||||
```
|
||||
|
||||
이러한 예제를 참고하여 작성하여주세요.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue