feat: add proxy template origin field and implement socket utilities for log streaming

This commit is contained in:
gabdevele
2026-05-07 10:54:57 +02:00 Unverified
parent 53dcdafdb1
commit 354ec150bc
32 changed files with 1681 additions and 1214 deletions
@@ -0,0 +1,35 @@
id: http-block-suspicious-methods
name: Block suspicious HTTP methods
protocol: http
description: Denies uncommon or dangerous HTTP methods.
category: http
family: web-hardening
tags:
- method-filter
- web
- block
action: block
summary: Denies uncommon or dangerous HTTP methods.
behavior: Returns 405 Method Not Allowed for methods outside the allowlist and logs
the blocked method and target URL.
source_url: https://docs.mitmproxy.org/stable/addons/examples/
code: |
import logging
from mitmproxy import http
ALLOWED_METHODS = {"GET", "POST", "HEAD"}
def request(flow: http.HTTPFlow) -> None:
if flow.request.method not in ALLOWED_METHODS:
logging.warning(
"[http-block-suspicious-methods] blocked method=%s url=%s",
flow.request.method,
flow.request.pretty_url,
)
flow.response = http.Response.make(
405,
b"",
{"allow": "GET, POST, HEAD"},
)