Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Access checks must fail closed
Grant access only on an explicit positive match so missing or unexpected values deny access.
Bad example
| 1 | const data = await response.json(); |
| 2 | // undefined !== 'DENY' is true -> access granted on missing/unexpected value |
| 3 | return res.status(200).json({ hasAccess: data?.decision !== 'DENY' }); |
Explanation (EN)
A negative comparison can turn missing or unrecognized upstream decisions into an unintended grant.
Objašnjenje (HR)
Negativna usporedba može nedostajuću ili nepoznatu odluku nadređenog servisa pretvoriti u nenamjerno dopuštenje.
Good example
| 1 | const data = await response.json(); |
| 2 | // only an explicit 'ALLOW' grants access; anything else denies |
| 3 | return res.status(200).json({ hasAccess: data?.decision === 'ALLOW' }); |
Explanation (EN)
Access requires an explicit positive value. Missing, null, or unrecognized responses all evaluate to false, so the check fails closed and denies access by default.
Objašnjenje (HR)
Pristup zahtijeva eksplicitnu pozitivnu vrijednost. Vrijednosti koje nedostaju, null su, ili nisu prepoznate, sve daju false, pa provjera otkazuje 'zatvoreno' (fail closed) i prema zadanom odbija pristup.
Notes (EN)
At an authorization boundary, grant access only for a validated positive decision; deny or return an explicit error on missing values, non-OK responses and upstream failures.
Bilješke (HR)
Na granici autorizacije dopusti pristup samo nakon provjerene pozitivne odluke; nedostajući podaci, neuspješan odgovor i kvar nadređenog servisa moraju odbiti pristup ili vratiti izričitu pogrešku.
Exceptions / Tradeoffs (EN)
A separately authorized public route or documented fallback must have its own policy; it cannot arise accidentally from a failed access check.