Reject null bytes in rule fields

Merged
BE
2mo ago
+449-14

Summary

  • Reject NUL bytes and malformed text encoding in writable rule text fields before PostgreSQL writes them.
  • Return a 422 validation response for malformed selectors without substituting a different option into a resubmittable form. Ordinary text errors still re-render the form.
  • Reject malformed rule names and reference values before CSV or family-data imports strip text or look up categories, merchants, and tags. Import error details omit the invalid raw text.

Fixes #4101

Validation

  • bin/rails test — 11,068 runs, 47,035 assertions, 0 failures, 0 errors, 34 skips.
  • bin/rubocop -f github -a — passed.
  • bundle exec erb_lint ./app/**/*.erb -a — passed.
  • npm run lint — passed.
  • bin/brakeman --no-pager — 0 errors and 0 security warnings.
  • git diff --check — passed.

No migration or view changes are required.

Related PR

#4089 also changes Rule::Condition. If it merges first, rebase this branch and ensure its regex validation skips malformed text before probing PostgreSQL.