Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Prefer an HMAC signature over a raw shared-secret header
For a request-signing protocol, keep the shared key off the wire and bind the full request plus replay protection; signatures remain sensitive.
Bad example
| 1 | // secret travels in plaintext; if it leaks, attacker can replay anything |
| 2 | fetch(url, { headers: { 'x-internal-secret': INTERNAL_API_SECRET } }); |
Explanation (EN)
Sending a long-lived shared secret as a reusable bearer credential increases impact when the header leaks.
Objašnjenje (HR)
Good example
| 1 | const signed = await requestSigner.sign({ method, url, body, createdAt, nonce }); |
| 2 | await transport.send(signed); |
Explanation (EN)
A reviewed protocol adapter covers the request content and freshness fields; the receiver verifies the signature and rejects expired or reused nonces.
Objašnjenje (HR)
Notes (EN)
When a service protocol uses request signatures, use a reviewed signing implementation that binds method, target, body digest and freshness/replay fields, and verify them on the receiver over TLS.
Exceptions / Tradeoffs (EN)
A captured valid signature may be replayable; it is not safe to log or expose. HMAC is not a universal replacement for established OAuth, mTLS or other authenticated protocols.