Hanami 3.0
Last reviewed Oct 28, 2026
Prompt Details
Prompt Composition
2prompts
- Ruby 4.0124 lines · 4.3K tokens
- Hanami 3.075 lines · 4.4K tokens
Total199 lines · 8.7K tokens
CWE Coverage
- 20
- 22
- 23
- 59
- 74
- 78
- 79
- 89
- 93
- 95
- 113
- 117
- 122
- 134
- 201
- 208
- 209
- 214
- 250
- 295
- 306
- 307
- 327
- 338
- 347
- 352
- 362
- 367
- 378
- 384
- 409
- 416
- 426
- 470
- 502
- 525
- 532
- 552
- 601
- 613
- 614
- 639
- 770
- 772
- 807
- 829
- 862
- 863
- 915
- 916
- 918
- 942
- 1004
- 1333
- 1395
Prompt Preview
Apply the Ruby 4.0 baseline first. These rules cover Hanami 3.0 with its 3.0-series action, view, database, and optional mailer integrations; they were checked against Hanami 3.0.2. Hanami requires Ruby 3.3 or newer.
Routes, action lifecycle, and shared components
- Limit
resourcesandresourceroutes withonly:to the required operations. Authenticate and authorize every protected action and separately protect route blocks, callable endpoints, and mounted Rack apps; these do not acquire action callbacks merely by sharing a route scope or slice. - Put authentication and authorization before protected work, and use
haltorresponse.redirect_toto stop a denied request. Settingresponse.statusor returning from a callback does not halt the action. Keep essential cleanup inensureor enclosing middleware because halting skips subsequent callbacks, includingaftercallbacks. - For browser cross-origin API actions, position CORS Rack middleware outermost for the affected paths, before authentication, caches, static serving, and other short-circuiting middleware. Use
config.middleware.useor routeuseonly where the resulting stack coversOPTIONSpreflights and 401/403/error responses. Allowlist exact origins, methods, request headers, and resources; never reflect an arbitrary ornullorigin. Keep credential sharing off unless required; then enablecredentials: trueonly for specifically allowed origins and resources, never a wildcard. SendVary: Originfor dynamic origin selection, and enforce authentication and CSRF separately. - Rate-limit