Для использования HTTPFlow необходимо импортировать модуль http .Для ведения журнала доступен ctx.log, например:
ctx.log.info("This is some informative text.")
ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")
Итак, скрипт выглядит так:
#!/usr/bin/env python3
from mitmproxy import http
from mitmproxy import ctx
def request(flow: http.HTTPFlow) -> None:
if flow.request.method == "POST" or flow.request.method == "PUT":
ctx.log.info("Sensitive pattern found")
flow.kill()
ctx.log.info("Am I killed part 1")