use crate::error::Result;
use super::{PatternRule, parse_rule};
const EMBEDDED_RULES: &[(&str, &str)] = &[
(
"role-check-conditional",
include_str!("../../rules/typescript/role-check-conditional.toml"),
),
(
"role-includes-check",
include_str!("../../rules/typescript/role-includes-check.toml"),
),
(
"has-role-call",
include_str!("../../rules/typescript/has-role-call.toml"),
),
(
"express-auth-middleware",
include_str!("../../rules/typescript/express-auth-middleware.toml"),
),
(
"express-route-middleware",
include_str!("../../rules/typescript/express-route-middleware.toml"),
),
(
"nestjs-use-guards",
include_str!("../../rules/typescript/nestjs-use-guards.toml"),
),
(
"nestjs-roles-decorator",
include_str!("../../rules/typescript/nestjs-roles-decorator.toml"),
),
(
"authorize-function-call",
include_str!("../../rules/typescript/authorize-function-call.toml"),
),
(
"permission-check-call",
include_str!("../../rules/typescript/permission-check-call.toml"),
),
(
"session-auth-check",
include_str!("../../rules/typescript/session-auth-check.toml"),
),
(
"jwt-token-check",
include_str!("../../rules/typescript/jwt-token-check.toml"),
),
(
"ownership-check",
include_str!("../../rules/typescript/ownership-check.toml"),
),
(
"feature-gate-check",
include_str!("../../rules/typescript/feature-gate-check.toml"),
),
(
"java-spring-preauthorize",
include_str!("../../rules/java/spring-preauthorize.toml"),
),
(
"java-spring-secured",
include_str!("../../rules/java/spring-secured.toml"),
),
(
"java-roles-allowed",
include_str!("../../rules/java/spring-roles-allowed.toml"),
),
(
"java-roles-allowed-array",
include_str!("../../rules/java/spring-roles-allowed-array.toml"),
),
(
"java-spring-permit-all",
include_str!("../../rules/java/spring-permit-all.toml"),
),
(
"java-is-user-in-role",
include_str!("../../rules/java/is-user-in-role.toml"),
),
(
"java-has-role-call",
include_str!("../../rules/java/has-role-call.toml"),
),
(
"java-shiro-requires-permissions",
include_str!("../../rules/java/shiro-requires-permissions.toml"),
),
(
"java-shiro-requires-roles",
include_str!("../../rules/java/shiro-requires-roles.toml"),
),
(
"java-shiro-requires-roles-array",
include_str!("../../rules/java/shiro-requires-roles-array.toml"),
),
(
"java-shiro-requires-authentication",
include_str!("../../rules/java/shiro-requires-authentication.toml"),
),
(
"java-shiro-is-permitted",
include_str!("../../rules/java/shiro-is-permitted.toml"),
),
(
"java-role-equals-check",
include_str!("../../rules/java/role-equals-check.toml"),
),
(
"java-ownership-check",
include_str!("../../rules/java/ownership-check.toml"),
),
(
"java-http-security-authorize",
include_str!("../../rules/java/http-security-authorize.toml"),
),
(
"java-authenticated-check",
include_str!("../../rules/java/authenticated-check.toml"),
),
(
"java-access-decision-voter",
include_str!("../../rules/java/access-decision-voter.toml"),
),
(
"java-security-interface-impl",
include_str!("../../rules/java/security-interface-impl.toml"),
),
(
"java-feature-gate-check",
include_str!("../../rules/java/feature-gate-check.toml"),
),
(
"java-custom-authz-call",
include_str!("../../rules/java/custom-authz-call.toml"),
),
(
"py-django-permission-required",
include_str!("../../rules/python/django-permission-required.toml"),
),
(
"py-login-required-decorator",
include_str!("../../rules/python/login-required-decorator.toml"),
),
(
"py-django-user-passes-test",
include_str!("../../rules/python/django-user-passes-test.toml"),
),
(
"py-has-perm-call",
include_str!("../../rules/python/has-perm-call.toml"),
),
(
"py-fastapi-depends",
include_str!("../../rules/python/fastapi-depends.toml"),
),
(
"py-role-check-conditional",
include_str!("../../rules/python/role-check-conditional.toml"),
),
(
"py-has-role-call",
include_str!("../../rules/python/has-role-call.toml"),
),
(
"py-permission-check-call",
include_str!("../../rules/python/permission-check-call.toml"),
),
(
"py-ownership-check",
include_str!("../../rules/python/ownership-check.toml"),
),
(
"py-feature-gate-check",
include_str!("../../rules/python/feature-gate-check.toml"),
),
(
"go-has-role-call",
include_str!("../../rules/go/has-role-call.toml"),
),
(
"go-permission-check-call",
include_str!("../../rules/go/permission-check-call.toml"),
),
(
"go-role-check-conditional",
include_str!("../../rules/go/role-check-conditional.toml"),
),
(
"go-ownership-check",
include_str!("../../rules/go/ownership-check.toml"),
),
(
"go-casbin-enforce",
include_str!("../../rules/go/casbin-enforce.toml"),
),
(
"go-feature-gate-check",
include_str!("../../rules/go/feature-gate-check.toml"),
),
(
"go-gin-auth-middleware",
include_str!("../../rules/go/gin-auth-middleware.toml"),
),
];
pub fn load_embedded_rules() -> Result<Vec<PatternRule>> {
let mut rules = Vec::with_capacity(EMBEDDED_RULES.len());
for (name, content) in EMBEDDED_RULES {
rules.push(parse_rule(content, name)?);
}
Ok(rules)
}