Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ func main() {

Install the library and required dependencies:
```bash
# Install baitroute
# Install baitroute with pip
pip install git+https://github.com/utkusen/baitroute.git#subdirectory=py

# Install baitroute with poetry
poetry add "git+https://github.com/utkusen/baitroute.git#subdirectory=py"
```

1. **Example Usage**
Expand Down
4 changes: 3 additions & 1 deletion py/baitroute/fastapi_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def register_with_fastapi(app: FastAPI, baitroute: BaitRoute) -> None:
@app.middleware("http")
async def bait_middleware(request: Request, call_next: Callable):
rule = baitroute.get_matching_rule(request.url.path, request.method)
if not rule and request.method == "HEAD":
rule = baitroute.get_matching_rule(request.url.path, "GET")
if rule:
# Send alert if handler is configured
if baitroute.alert_handler is not None:
Expand Down Expand Up @@ -41,7 +43,7 @@ async def bait_middleware(request: Request, call_next: Callable):
headers.update(rule['headers'])

return Response(
content=rule.get('body', ''),
content="" if request.method == "HEAD" else rule.get("body", ""),
status_code=rule.get('status', 200),
headers=headers
)
Expand Down
67 changes: 67 additions & 0 deletions py/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[tool.poetry]
name = "baitroute"
version = "0.1.0"
description = "A configurable HTTP honeypot library for Python web applications"
authors = ["Utku Sen <utkusen@gmail.com>"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/utkusen/baitroute"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
]

[tool.poetry.dependencies]
python = ">=3.6,<4.0"
pyyaml = ">=5.1"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
27 changes: 0 additions & 27 deletions py/setup.py

This file was deleted.