Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add docs and fix greptile comments
Matheus Nogueira4543ee05bb7a
diff --git a/backend/src/ee/services/permission/permission-fns.ts b/backend/src/ee/services/permission/permission-fns.tsindex 7daa8b4201..8f877ffa7e 100644--- a/backend/src/ee/services/permission/permission-fns.ts+++ b/backend/src/ee/services/permission/permission-fns.ts@@ -20,7 +20,6 @@ import {ProjectPermissionV2Schema,SecretSubjectFields} from "./project-permission";-import { logger } from "@app/lib/logger";export function throwIfMissingSecretReadValueOrDescribePermission(permission: MongoAbility<ProjectPermissionSet> | PureAbility,@@ -368,37 +367,36 @@ const expandLegacyForbidActions = <T extends RawRuleOf<MongoAbility<ProjectPermi});};--const createHandlebarsClient = () => {- const hbs = handlebars.create();-- hbs.registerHelper('substr', hbsSubstr);- hbs.registerHelper("stripPrefix", hbsStripPrefix);-- return hbs;-}-const hbsSubstr = (text: string, start: number, end?: number) => {const textStr = String(text || "");if (!textStr) return textStr;- const endIndex = end && typeof end === 'number' ? end : undefined;+ const endIndex = end && typeof end === "number" ? end : undefined;return textStr.substring(start, endIndex);-}+};const hbsStripPrefix = (text: string, prefix: string) => {const textStr = String(text || "");if (!textStr) return textStr;return textStr.startsWith(prefix) ? textStr.substring(prefix.length) : textStr;-}+};++const handlebarsClient = (() => {+ const hbs = handlebars.create();++ hbs.registerHelper("substr", hbsSubstr);+ hbs.registerHelper("stripPrefix", hbsStripPrefix);++ return hbs;+})();export {assertPermissionBoundary,constructPermissionErrorMessage,- createHandlebarsClient,escapeHandlebarsMissingDict,expandLegacyForbidActions,+ handlebarsClient,isAuthMethodSaml,validateOrgSSO,validatePrivilegeChangeOperationdiff --git a/backend/src/ee/services/permission/permission-service.ts b/backend/src/ee/services/permission/permission-service.tsindex 1c615cb214..566f6f0bea 100644--- a/backend/src/ee/services/permission/permission-service.ts+++ b/backend/src/ee/services/permission/permission-service.ts@@ -1,7 +1,6 @@import { createMongoAbility, ForbiddenError, MongoAbility, RawRuleOf, subject } from "@casl/ability";import { PackRule, packRules, unpackRules } from "@casl/ability/extra";import { requestContext } from "@fastify/request-context";-import handlebars from "handlebars";import {AccessScope,@@ -63,7 +62,12 @@ import {OrgPermissionSubjects} from "./org-permission";import { TPermissionDALFactory } from "./permission-dal";-import { createHandlebarsClient, escapeHandlebarsMissingDict, expandLegacyForbidActions, validateOrgSSO } from "./permission-fns";+import {+ escapeHandlebarsMissingDict,+ expandLegacyForbidActions,+ handlebarsClient,+ validateOrgSSO+} from "./permission-fns";import {TBuildOrgPermissionDTO,TBuildProjectPermissionDTO,@@ -621,7 +625,7 @@ export const permissionServiceFactory = ({}const rules = buildProjectPermissionRules(permissionFromRoles);- const templatedRules = createHandlebarsClient().compile(JSON.stringify(rules), { data: false });+ const templatedRules = handlebarsClient.compile(JSON.stringify(rules), { data: false });const unescapedMetadata = objectify(permissionData?.[0]?.metadata,(i) => i.key,@@ -823,7 +827,7 @@ export const permissionServiceFactory = ({})) || [];const rules = buildProjectPermissionRules(rolePermissions.concat(additionalPrivileges));- const templatedRules = createHandlebarsClient().compile(JSON.stringify(rules), { data: false });+ const templatedRules = handlebarsClient.compile(JSON.stringify(rules), { data: false });const metadataKeyValuePair = escapeHandlebarsMissingDict(objectify(userProjectPermission.metadata,@@ -869,7 +873,7 @@ export const permissionServiceFactory = ({})) || [];const rules = buildProjectPermissionRules(rolePermissions.concat(additionalPrivileges));- const templatedRules = createHandlebarsClient().compile(JSON.stringify(rules), { data: false });+ const templatedRules = handlebarsClient.compile(JSON.stringify(rules), { data: false });const metadataKeyValuePair = escapeHandlebarsMissingDict(objectify(identityProjectPermission.metadata,diff --git a/backend/src/lib/template/validate-handlebars.ts b/backend/src/lib/template/validate-handlebars.tsindex d7b1dc7ef1..ac0447793c 100644--- a/backend/src/lib/template/validate-handlebars.ts+++ b/backend/src/lib/template/validate-handlebars.ts@@ -9,7 +9,6 @@ type SanitizationArg = {};const isValidExpression = (expression: string, dto: SanitizationArg): boolean => {- // Allow helper functions (replace, truncate)const allowedHelpers = dto.allowedHelpers ?? ["replace", "truncate", "random", "uppercase", "lowercase"];if (allowedHelpers.includes(expression)) {return true;diff --git a/docs/documentation/platform/access-controls/abac/managing-machine-identity-attributes.mdx b/docs/documentation/platform/access-controls/abac/managing-machine-identity-attributes.mdxindex 2f1aec551e..fcbf2132eb 100644--- a/docs/documentation/platform/access-controls/abac/managing-machine-identity-attributes.mdx+++ b/docs/documentation/platform/access-controls/abac/managing-machine-identity-attributes.mdx@@ -94,3 +94,38 @@ For methods like OIDC, these come as claims in the token and can be made availabAt the moment we only support OIDC claims, Kubernetes attributes, and AWS attributes. Payloads on other authentication methods are not yet accessible.</Tab></Tabs>++#### Template Helper Functions++In addition to referencing attributes directly, you can use helper functions to transform attribute values within your policy templates. These functions allow you to extract or manipulate parts of an attribute before it is evaluated.++**substr**++Extracts a portion of a string. Accepts a start index and an optional end index (exclusive). If the end index is omitted, the rest of the string is returned.++**Examples:**++Given `identity.auth.aws.arn` = `arn:aws:iam::123456789012:user/example-user`:++```handlebars+{{ substr identity.auth.aws.arn 0 3 }} -> arn+{{ substr identity.auth.aws.arn 4 }} -> aws:iam::123456789012:user/example-user+```++**stripPrefix**++Removes a prefix from the beginning of a string. If the string does not start with the given prefix, it is returned unchanged.++**Examples:**++Given `identity.auth.kubernetes.namespace` = `production-us-east`:++```handlebars+{{ stripPrefix identity.auth.kubernetes.namespace 'production-' }} -> us-east+```++Given `identity.auth.aws.arn` = `arn:aws:iam::123456789012:user/example-user`:++```handlebars+{{ stripPrefix identity.auth.aws.arn 'arn:aws:iam::123456789012:' }} -> user/example-user+```