Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

apply same thing for additional privileges

Matheus Nogueiraa0be9401516e
diff --git a/backend/src/ee/services/permission/permission-fns.ts b/backend/src/ee/services/permission/permission-fns.ts
index 542c543161..7daa8b4201 100644
--- a/backend/src/ee/services/permission/permission-fns.ts
+++ b/backend/src/ee/services/permission/permission-fns.ts
@@ -379,13 +379,18 @@ const createHandlebarsClient = () => {
}
const hbsSubstr = (text: string, start: number, end?: number) => {
+ const textStr = String(text || "");
+ if (!textStr) return textStr;
+
const endIndex = end && typeof end === 'number' ? end : undefined;
- logger.info({text, start, end: end ?? 'undefined'}, 'substr')
- return text.substring(start, endIndex);
+ return textStr.substring(start, endIndex);
}
const hbsStripPrefix = (text: string, prefix: string) => {
- return text.startsWith(prefix) ? text.substring(prefix.length) : text;
+ const textStr = String(text || "");
+ if (!textStr) return textStr;
+
+ return textStr.startsWith(prefix) ? textStr.substring(prefix.length) : textStr;
}
export {
diff --git a/backend/src/services/additional-privilege/additional-privilege-service.ts b/backend/src/services/additional-privilege/additional-privilege-service.ts
index e63fe711d7..14d94c530b 100644
--- a/backend/src/services/additional-privilege/additional-privilege-service.ts
+++ b/backend/src/services/additional-privilege/additional-privilege-service.ts
@@ -69,7 +69,8 @@ export const additionalPrivilegeServiceFactory = ({
if (existingSlug) throw new BadRequestError({ message: `Additional privilege with name ${data.name} exists` });
validateHandlebarTemplate("Additional Privilege Create", JSON.stringify(data.permissions || []), {
- allowedExpressions: (val) => val.includes("identity.")
+ allowedExpressions: (val) => val.includes("identity."),
+ allowedHelpers: ["substr", "stripPrefix"]
});
if (!data.isTemporary) {
@@ -132,7 +133,8 @@ export const additionalPrivilegeServiceFactory = ({
throw new NotFoundError({ message: `Additional privilege with id ${dto.selector.id} doesn't exist` });
validateHandlebarTemplate("Additional Privilege Create", JSON.stringify(data.permissions || []), {
- allowedExpressions: (val) => val.includes("identity.")
+ allowedExpressions: (val) => val.includes("identity."),
+ allowedHelpers: ["substr", "stripPrefix"]
});
const updatedData = { ...existingPrivilege, ...data };