Skip to content
Merged
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
2 changes: 1 addition & 1 deletion dementor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

__version__ = "1.0.0.dev23"
__version__ = "1.0.0.dev24"
__author__ = "MatrixEditor"
27 changes: 19 additions & 8 deletions dementor/protocols/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class ProxyAutoConfig(TomlConfig):
if typing.TYPE_CHECKING:
proxy_script: str | None

def set_proxy_script(self, script: str | None) -> None:
def set_proxy_script(
self, script: str | dict[str, dict[str, str]] | object | None
) -> None:
self.proxy_script = None
match script:
case str():
Expand All @@ -94,11 +96,15 @@ def set_proxy_script(self, script: str | None) -> None:

path = pathlib.Path(script["file"])
if not path.exists() or not path.is_file():
dm_logger.error(f"WPAD script at {path} does not exist - ignoring...")
dm_logger.error(
f"WPAD script at {path} does not exist - ignoring..."
)
return

if not path.is_file():
dm_logger.error(f"WPAD script at {path} is not a file - ignoring...")
dm_logger.error(
f"WPAD script at {path} is not a file - ignoring..."
)
return

self.proxy_script = path.read_text()
Expand Down Expand Up @@ -276,10 +282,10 @@ def __init__(
client_address: tuple[str, int],
server,
) -> None:
self.config = session
self.server_config = server_config
self.config: SessionConfig = session
self.server_config: HTTPServerConfig = server_config
self.client_address = client_address
self.challenge = None
self.challenge: bytes | None = None
self.setup_proto_logger()
for http_method in server_config.http_methods:
if http_method in ("OPTIONS", "PROPFIND"):
Expand Down Expand Up @@ -335,7 +341,9 @@ def version_string(self) -> str:
def log_message(self, format: str, *args) -> None:
# let us log mssages
text = format % args
msg = text.translate(self._control_char_table) # ty:ignore[unresolved-attribute]
msg = text.translate(
self._control_char_table
) # ty:ignore[unresolved-attribute]
self.logger.debug(msg)

def send_response(self, code: int, message: str | None = None) -> None:
Expand Down Expand Up @@ -506,7 +514,9 @@ def auth_ntlm(

case _:
logger.fail(f"Invalid negotiate authentication: {token}")
self.send_error(HTTPStatus.INTERNAL_SERVER_ERROR, "Internal Server Error")
self.send_error(
HTTPStatus.INTERNAL_SERVER_ERROR, "Internal Server Error"
)

def auth_bearer(self, token: str, logger: "ProtocolLogger") -> None:
self.display_request("Bearer", logger)
Expand Down Expand Up @@ -565,6 +575,7 @@ def get_extras(self) -> dict[str, str]:

class WinRMHandler(HTTPHandler):
def setup_proto_logger(self) -> None:
super().setup_proto_logger()
self.logger = ProtocolLogger(
extra={
"protocol": "WinRM",
Expand Down
6 changes: 3 additions & 3 deletions docs/source/compat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ in development. The legend for each symbol is as follows:
<tr>
<th>Supported Protocols</th>
<th><a href="https://github.com/lgandx/Responder">Responder (3.2.2.0)</a></th>
<th><a href="https://github.com/MatrixEditor/Dementor">Dementor (1.0.0.dev22)</a></th>
<th><a href="https://github.com/MatrixEditor/Dementor">Dementor (1.0.0.dev24)</a></th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -775,7 +775,7 @@ in development. The legend for each symbol is as follows:
<tr>
<th>Feature</th>
<th><a href="https://github.com/lgandx/Responder">Responder (3.2.2.0)</a></th>
<th><a href="https://github.com/MatrixEditor/Dementor">Dementor (1.0.0.dev22)</a></th>
<th><a href="https://github.com/MatrixEditor/Dementor">Dementor (1.0.0.dev22+)</a></th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -813,7 +813,7 @@ in development. The legend for each symbol is as follows:
<tr>
<th>Feature</th>
<th><a href="https://github.com/lgandx/Responder">Responder (3.2.2.0)</a></th>
<th><a href="https://github.com/MatrixEditor/Dementor">Dementor (1.0.0.dev22)</a></th>
<th><a href="https://github.com/MatrixEditor/Dementor">Dementor (1.0.0.dev22+)</a></th>
</tr>
</thead>
<tbody>
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = "Dementor"
copyright = "2025-Present, MatrixEditor"
author = "MatrixEditor"
release = "1.0.0.dev23"
release = "1.0.0.dev24"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
76 changes: 38 additions & 38 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "dementor"
version = "1.0.0.dev23"
version = "1.0.0.dev24"
# REVISIT: dynamic version
# dynamic = ["version"]
description = "LLMNR/NBT-NS/mDNS Poisoner and rogue service provider"
Expand Down Expand Up @@ -96,104 +96,104 @@ src = ["dementor", "tests"]
select = ["ALL"]
ignore = [
# --- A: flake8-builtins ---
"A001", # builtin-variable-shadowing -- unavoidable in Sphinx conf.py (copyright)
"A002", # builtin-argument-shadowing -- common in protocol code (type, id)
"A001", # builtin-variable-shadowing
"A002", # builtin-argument-shadowing

# --- ANN: flake8-annotations -- use ty for gradual typing ---
# --- ANN: flake8-annotations
"ANN",

# --- ARG: flake8-unused-arguments ---
"ARG001", # unused-function-argument -- CLI/callback params required by framework
"ARG002", # unused-method-argument -- interface/callback stubs
"ARG001", # unused-function-argument
"ARG002", # unused-method-argument

# --- ASYNC: flake8-async ---
"ASYNC240", # blocking-path-method-in-async -- startup-time checks, not hot path
"ASYNC240", # blocking-path-method-in-async

# --- BLE: flake8-blind-except ---
"BLE001", # blind-except -- legitimate in protocol handlers
"BLE001", # blind-except

# --- C90: mccabe ---
"C901", # complex-structure -- protocol handlers are inherently complex
"C901", # complex-structure

# --- COM: flake8-commas ---
"COM812", # missing-trailing-comma -- conflicts with formatter
"COM812", # missing-trailing-comma

# --- D: pydocstyle ---
"D100", "D101", "D102", "D103", "D104", "D105", "D107", # missing docstrings
"D203", # conflicts with D211
"D212", # conflicts with D213 (must pick one)
"D213", # conflicts with D212 (must pick one)
"D401", # non-imperative-mood -- too opinionated
"D401", # non-imperative-mood

# --- E: pycodestyle ---
"E501", # line-too-long -- formatter handles what it can
"E501", # line-too-long

# --- EM: flake8-errmsg ---
"EM101", # raw-string-in-exception -- too pedantic
"EM102", # f-string-in-exception -- too pedantic
"EM101", # raw-string-in-exception
"EM102", # f-string-in-exception

# --- ERA: eradicate ---
"ERA001", # REVISIT notes, protocol reference tables, placeholders

# --- EXE: flake8-executable ---
"EXE002", # shebang-missing-executable-file -- not relevant
"EXE002", # shebang-missing-executable-file

# --- FBT: flake8-boolean-trap ---
"FBT", # too strict for config-heavy protocol code
"FBT",

# --- FIX: flake8-fixme ---
"FIX002", # line-contains-todo -- TODOs are intentional
"FIX002", # line-contains-todo

# --- G: flake8-logging-format ---
"G004", # logging-f-string -- f-strings in logging are fine
"G004", # logging-f-string

# --- I: isort ---
"I001", # unsorted-imports -- custom import grouping
"I001", # unsorted-imports

# --- INP: flake8-no-pep420 ---
"INP001", # standalone script directories don't need __init__.py
"INP001",

# --- ISC: flake8-implicit-str-concat ---
"ISC003", # explicit-string-concatenation -- often more readable
"ISC003", # explicit-string-concatenation

# --- N: pep8-naming ---
"N801", "N802", "N803", "N806", # protocol code uses non-standard names
"N811", "N812", "N815", "N817", # import/variable naming conventions
"N818", # error-suffix -- control-flow exceptions are idiomatic
"N818", # error-suffix

# --- PL: Pylint ---
"PLR0912", # too-many-branches -- protocol handlers
"PLR0913", # too-many-arguments -- protocol constructors
"PLR0915", # too-many-statements -- protocol handlers
"PLR2004", # magic-value-comparison -- protocol numeric constants
"PLR0912", # too-many-branches
"PLR0913", # too-many-arguments
"PLR0915", # too-many-statements
"PLR2004", # magic-value-comparison

# --- PTH: flake8-use-pathlib ---
"PTH", # os.path -> pathlib -- low priority
"PTH", # os.path -> pathlib

# --- RET: flake8-return ---
"RET503", # implicit-return -- idiomatic Python
"RET503", # implicit-return

# --- RUF: Ruff-specific rules ---
"RUF003", # ambiguous-unicode-character-comment -- intentional
"RUF012", # mutable-class-default -- false positives with struct-like patterns
"RUF003", # ambiguous-unicode-character-comment
"RUF012", # mutable-class-default

# --- S: flake8-bandit ---
"S101", # assert -- valid in non-production paths
"S104", # hardcoded-bind-all-interfaces -- intentional for network tool
"S311", # suspicious-non-cryptographic-random -- not used for crypto
"S101", # assert
"S104", # hardcoded-bind-all-interfaces
"S311", # suspicious-non-cryptographic-random

# --- SLF: flake8-self ---
"SLF001", # private-member-access -- common in internal wiring
"SLF001", # private-member-access

# --- T20: flake8-print ---
"T201", # print -- intentional in CLI/diagnostic code
"T201", # print

# --- TD: flake8-todos ---
"TD002", # missing-todo-author -- not needed for small team
"TD003", # missing-todo-link -- not needed for small team
"TD002", # missing-todo-author
"TD003", # missing-todo-link

# --- TRY: tryceratops ---
"TRY003", # raise-vanilla-args -- too pedantic
"TRY003", # raise-vanilla-args
]

[tool.ruff.format]
Expand Down
Loading