grow food, not lawn.

Skip to content

Monero Integration, CSRF: enforce coverage test + CI gate; Monero docs/hardening updates

Be Disruptive requested to merge feature/csrf-audit-ci-monero-docs into master

Summary

  • Completes CSRF protection audit.
  • Adds a focused CSRF coverage test and integrates it into CI as a gate.
  • Updates docs (Testing, Security, README) with CSRF policy and Monero hardening guidance.
  • No runtime breaking changes or DB migrations.

Changes

CSRF Audit Details

  • All state-changing POST routes use require_csrf=True.
  • All local POST forms include {% include "snippets/csrf.j2" %}.
  • External POSTs (e.g., signed S3/Spaces uploads) are excluded from CSRF and test coverage.

Examples (selected):

Monero: Documentation & Hardening Notes

  • docs/security.md:

    • Monero hardening checklist:
      • RPC bound to localhost, strong auth, no public exposure.
      • Disable mock mode in production; keep mock JSON non-public.
      • Price oracle: HTTPS, enforce timeouts/retries and sanity bounds.
      • Minimal PII in logs; avoid leaking addresses/PII.
      • Watcher idempotence and confirmation thresholds.
    • Notes on watcher behavior and inventory finalization parity with Stripe.
  • docs/testing.md:

    • Monero test targets remain (make test-monero), with CSRF test added.

Testing

  • Local CSRF coverage test:

    • make test-csrf → 2 passed (CSRF views + template coverage).
  • Full test suite:

    • make test (set Stripe test keys per README if needed).

CI

  • Adds csrf-audit job to the test stage that runs make test-csrf to prevent regressions.
  • Pip-audit job retained as before.

Backwards Compatibility

  • No runtime behavior changes except added CSRF enforcement on POST (expected security hardening).
  • No config changes or DB migrations.

Risks & Mitigations

  • Risk: Missing CSRF in a new POST endpoint or template could regress.
    • Mitigation: CI gate (csrf-audit) fails if coverage is incomplete.
  • Risk: False positive for external POSTs.
    • Mitigation: Test explicitly skips actions to absolute URLs and signed_post["url"].

Follow-ups (Optional)

  • Add a CI badge or README note for CSRF coverage gate.
  • Extend tests to assert specific critical routes/forms if desired.
  • Consider adding price oracle timeouts/retries and bounds in views/crypto.py.

How To Verify

  • Locally:
    • make test-csrf should pass.
  • In CI:
    • Ensure csrf-audit job passes in the MR pipeline.

Merge request reports