Repository navigation
Conversation
…ument the operator trade-off
Reject bodies beyond 512 container levels before parsing so CPython scanner differences cannot change a malformed-input 400 into a model-type 422. Preserve ordinary model validation and ignore brackets within JSON strings. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
|
Merge-order note. PR #568 adds |
There was a problem hiding this comment.
🟡 Changes recommended
The JSON pre-scan permits quadratic CPU consumption, and the required dependency audit blocks unpublished release candidates.
2 open issues
What changed in this PR
Strengthens security verification for the Azure Functions validation library, covering HTTP trust boundaries, package integrity, and release-time dependency checks for #567.
Changes:
- Adds security regression tests and a portable 512-level JSON nesting limit.
- Introduces redacted scanner evidence, expiring exceptions, and a blocking runtime dependency audit.
- Documents production boundaries and extends SDK/worker compatibility coverage.
| File | Description |
|---|---|
tools/security_report.py |
Defines structured, allow-listed security reports. |
tools/security_exceptions.py |
Validates exact, time-limited exceptions. |
tools/security_evidence.py |
Collects Bandit inventory and Semgrep execution evidence. |
tools/dependency_audit_policy.py |
Classifies dependency audits and enforces release policy. |
tests/test_security_workflows.py |
Checks audit gating, permissions, and evidence uploads. |
tests/test_security_runtime.py |
Tests response sanitation across extension points. |
tests/test_security_inputs.py |
Tests hostile input, limits, and nesting boundaries. |
tests/test_security_evidence.py |
Tests scanner failures, exceptions, and redacted evidence. |
tests/test_security_auth.py |
Verifies host-owned authentication remains unchanged. |
tests/test_print_safe_app_settings.py |
Adds credential-shape redaction coverage. |
tests/test_dependency_audit_policy.py |
Tests advisory blocking and exception handling. |
tests/test_check_wheel_schemas.py |
Verifies tampering fails without modifying artifacts. |
src/azure_functions_validation/decorator.py |
Clarifies the production risk of error exposure. |
src/azure_functions_validation/adapter.py |
Routes body parsing through the depth-limited helper. |
src/azure_functions_validation/_json_body.py |
Adds nesting checks and normalized parsing errors. |
security/dependency-audit-policy.json |
Sets the runtime advisory blocking policy. |
security/bandit-policy.json |
Records exact, expiring static-analysis exceptions. |
SECURITY.md |
Documents trust boundaries, controls, and recovery. |
pyproject.toml |
Adds explicit type checking for security tools. |
examples/README.md |
Distinguishes demonstrations from production configurations. |
docs/configuration.md |
Documents nesting limits and formatter safety. |
AGENTS.md |
Links contributor guidance to security policy. |
.gitignore |
Excludes generated security evidence. |
.github/workflows/worker-nightly.yml |
Runs security tests against worker previews. |
.github/workflows/security.yml |
Adds expanded scanning and evidence uploads. |
.github/workflows/publish-pypi.yml |
Requires candidate dependency audits before publishing. |
.github/workflows/dependency-audit.yml |
Reuses shared tooling for advisory reports. |
.github/workflows/ci-test.yml |
Adds security tests to SDK 2.x compatibility checks. |
Review effort: Balanced
|
Do not merge this draft wholesale. The depth fix is already on main via #583; fail-closed expanded Bandit landed via #587. Fresh focused #591 addresses #585 (oversized JSON integer 500) and draft #592 addresses the supported Semgrep CLI for #579. These supersede the corresponding portions, not the entire security tracker: exact-candidate runtime advisory gating and remaining disclosure/auth proofs still need focused current-main work. #567 stays open until all acceptance criteria/children are done. Leaving draft closure to the maintainer; no changes made to its branch or dirty checkout. |
|
This draft is superseded by focused fixes on current main: #583 bounds hostile JSON depth, #591 sanitizes oversized integers, #587 makes expanded Bandit scanning fail closed, and #592 replaces deprecated Semgrep (still awaiting GitHub seeded-finding proof). #567 still needs exact-candidate runtime dependency advisory gating across Python 3.11–3.14, fail-closed tool-error behavior, and focused regression evidence for the remaining error-disclosure/auth contracts. This draft’s broader exception/reporting framework is explicitly outside #567 scope. Leaving this superseded draft open for the maintainer; it will not be merged. |
| grep -E '^\.PHONY: ' Makefile | cut -d ':' -f2 | xargs -n1 echo " - make" | ||
|
|
||
| # Security entry points use the selected CI interpreter without provisioning Hatch. | ||
| SECURITY_PYTHON ?= $(if $(CI),python,hatch run python) |
| args = ["audit", "--site-packages", str(tmp_path), "--output", str(tmp_path)] | ||
| if development: | ||
| args.append("--development") | ||
| monkeypatch.setattr(sys, "argv", args) | ||
| monkeypatch.setattr( | ||
| dependency_audit_policy, | ||
| "run_audit", | ||
| lambda path, policy: Check("pip-audit", (), Status.INCOMPLETE, None), |


Summary
Strengthen validation security tests and release checks. Testing did not identify a default 5xx response leak, but it found inconsistent handling of deeply nested JSON across Python versions.
Changes
expose_internal_errors.SECURITY.md. Existing logging behavior remains unchanged; log redaction or handler-exception containment would require separate work.Validation
Related Issues
Closes #567