Casbin 2.135.0

Last reviewed Sep 19, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Go 1.27130 lines · 5.5K tokens
  2. Casbin 2.135.068 lines · 3.3K tokens
Total198 lines · 8.8K tokens

CWE Coverage

  • 15
  • 20
  • 22
  • 59
  • 78
  • 79
  • 89
  • 94
  • 95
  • 117
  • 190
  • 208
  • 209
  • 250
  • 252
  • 257
  • 269
  • 295
  • 307
  • 323
  • 327
  • 338
  • 347
  • 352
  • 362
  • 367
  • 378
  • 426
  • 444
  • 488
  • 494
  • 532
  • 636
  • 732
  • 759
  • 770
  • 772
  • 807
  • 862
  • 863
  • 915
  • 916
  • 918
  • 942
  • 1004
  • 1275
  • 1395

Prompt Preview

Apply the Go 1.27 baseline first. These rules cover github.com/casbin/casbin/v2 at 2.135.0, including its model evaluator, policy APIs, adapters, cached and synchronized enforcers, and transactions. Keep integrations compatible with this exact major version.

Enforcement boundaries

  • Require successful NewEnforcer initialization and loading of the required model and policy before accepting protected traffic; a constructor returning no error does not prove that the intended policies are present. Explicitly distinguish an intentional policy-free ABAC model from a failed or omitted policy load.
  • Call Enforce at each protected operation and proceed only when err == nil && allowed; apply the same rule to cached and explanatory enforcement APIs. Do not ignore an error merely because the returned boolean is true.
  • Construct request arguments in the model's exact order from authenticated identity, the resolved resource, the actual action, and verified tenant context. Enforce against the object and state used by the operation; coordinate authorization with the application transaction because Casbin does not make the protected mutation atomic.
  • Check the error, result count, and each item from BatchEnforce before acting on a batch; it can return a partial result slice on error. Do not use a single allowed item to authorize the whole batch.
  • Keep enforcement enabled. Prohibit EnableEnforce(false) in production fallback and maintenance paths because it makes the underlying enforcer allow every request; an unavailable authorizer must not become an allow-all