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
remove support for glob
adilson7093ebd5a857
diff --git a/backend/src/ee/services/permission/permission-fns.test.ts b/backend/src/ee/services/permission/permission-fns.test.tsindex c1a525026e..b88890c44f 100644--- a/backend/src/ee/services/permission/permission-fns.test.ts+++ b/backend/src/ee/services/permission/permission-fns.test.ts@@ -263,47 +263,28 @@ describe("trimSuffix handlebars helper", () => {const render = (template: string, value: string) =>handlebarsClient.compile(template)({ identity: { auth: { kubernetes: { namespace: value } } } });- const trim = (value: string, pattern: string) =>- render(`{{ trimSuffix identity.auth.kubernetes.namespace '${pattern}' }}`, value);+ const trim = (value: string, suffix: string) =>+ render(`{{ trimSuffix identity.auth.kubernetes.namespace '${suffix}' }}`, value);- test("trims a matching glob suffix", () => {- expect(trim("myapp-pr-1", "-pr-*")).toBe("myapp");- expect(trim("myapp-pr-42", "-pr-*")).toBe("myapp");- });-- test("returns the value unchanged when nothing matches the pattern", () => {- expect(trim("myapp", "-pr-*")).toBe("myapp");- expect(trim("myapp-mr-1", "-pr-*")).toBe("myapp-mr-1");- });-- test("removes the shortest matching suffix, not the longest", () => {- expect(trim("app-pr-1", "-*")).toBe("app-pr");- });-- test("trims a literal suffix when the pattern has no glob syntax", () => {+ test("trims a matching suffix", () => {expect(trim("myapp-prod", "-prod")).toBe("myapp");- expect(trim("myapp", "-prod")).toBe("myapp");});- test("supports the wider glob syntax used by permission conditions", () => {- expect(trim("myapp-pr-1", "-{pr,mr}-*")).toBe("myapp");- expect(trim("myapp-pr-1", "-pr-?")).toBe("myapp");+ test("returns the value unchanged when it does not end with the suffix", () => {+ expect(trim("myapp", "-prod")).toBe("myapp");+ expect(trim("myapp-staging", "-prod")).toBe("myapp-staging");});test("leaves an unresolved attribute literal intact so the condition fails closed", () => {- expect(trim("{{identity.auth.kubernetes.namespace}}", "-pr-*")).toBe("{{identity.auth.kubernetes.namespace}}");+ expect(trim("{{identity.auth.kubernetes.namespace}}", "-prod")).toBe("{{identity.auth.kubernetes.namespace}}");});test("returns an empty string for an empty value", () => {- expect(trim("", "-pr-*")).toBe("");- });-- test("returns the value unchanged for a malformed pattern instead of throwing", () => {- expect(trim("myapp-pr-1", "-pr-+(")).toBe("myapp-pr-1");+ expect(trim("", "-prod")).toBe("");});- test("returns the value unchanged when no pattern is supplied", () => {- expect(render("{{ trimSuffix identity.auth.kubernetes.namespace }}", "myapp-pr-1")).toBe("myapp-pr-1");+ test("returns the value unchanged when no suffix is supplied", () => {+ expect(render("{{ trimSuffix identity.auth.kubernetes.namespace }}", "myapp-prod")).toBe("myapp-prod");});});describe("getProjectPermissionFingerprint", () => {diff --git a/backend/src/ee/services/permission/permission-fns.ts b/backend/src/ee/services/permission/permission-fns.tsindex ae9b4daeed..9063553d31 100644--- a/backend/src/ee/services/permission/permission-fns.ts+++ b/backend/src/ee/services/permission/permission-fns.ts@@ -1,7 +1,6 @@/* eslint-disable no-nested-ternary */import { ForbiddenError, MongoAbility, PureAbility, RawRuleOf, subject } from "@casl/ability";import handlebars from "handlebars";-import picomatch from "picomatch";import { z } from "zod";import { SecretFolderRole, TOrganizations } from "@app/db/schemas";@@ -436,8 +435,6 @@ const expandLegacyForbidActions = <T extends RawRuleOf<MongoAbility<ProjectPermi});};-const HBS_TRIM_SUFFIX_MAX_GLOB_INPUT_LENGTH = 256;-const hbsStripPrefix = (text: string, prefix: string) => {const textStr = String(text || "");if (!textStr) return textStr;@@ -451,26 +448,7 @@ const hbsTrimSuffix = (text: string, suffix: string) => {if (typeof suffix !== "string" || !suffix) return textStr;- if (suffix.length > HBS_TRIM_SUFFIX_MAX_GLOB_INPUT_LENGTH) return textStr;-- if (!picomatch.scan(suffix).isGlob) {- return textStr.endsWith(suffix) ? textStr.slice(0, -suffix.length) : textStr;- }-- if (textStr.length > HBS_TRIM_SUFFIX_MAX_GLOB_INPUT_LENGTH) return textStr;-- let isSuffixMatch: (input: string) => boolean;- try {- isSuffixMatch = picomatch(suffix, { dot: true });- } catch {- return textStr;- }-- for (let i = textStr.length; i >= 0; i -= 1) {- if (isSuffixMatch(textStr.slice(i))) return textStr.slice(0, i);- }-- return textStr;+ return textStr.endsWith(suffix) ? textStr.slice(0, -suffix.length) : textStr;};const handlebarsClient = (() => {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 4be2e1a81a..4bac751eae 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@@ -119,34 +119,18 @@ Given `identity.auth.aws.arn` = `arn:aws:iam::123456789012:user/example-user`:**trimSuffix**-Removes a suffix from the end of a string. The suffix is a glob pattern, using the same syntax as-the **Glob Match** condition operator, so it can match a part of the value that varies. The-shortest matching suffix is removed. If nothing at the end of the string matches the pattern, the-string is returned unchanged.--This is useful when a namespace or resource name carries a generated trailing segment. For-example, an ArgoCD ApplicationSet using the pull request generator creates one namespace per open-pull request, such as `myapp-pr-1` and `myapp-pr-42`. Trimming the generated segment lets every one-of those namespaces resolve to the same secret path as the base namespace, without writing a-condition for each pull request.+Removes a suffix from the end of a string. If the string does not end with the given suffix, it is returned unchanged.**Examples:**-Given `identity.auth.kubernetes.namespace` = `myapp-pr-42`:--```handlebars-{{ trimSuffix identity.auth.kubernetes.namespace '-pr-*' }} -> myapp-```--Given `identity.auth.kubernetes.namespace` = `myapp` (nothing matches the pattern):+Given `identity.auth.kubernetes.namespace` = `myapp-prod`:```handlebars-{{ trimSuffix identity.auth.kubernetes.namespace '-pr-*' }} -> myapp+{{ trimSuffix identity.auth.kubernetes.namespace '-prod' }} -> myapp```-You can combine this with a secret path condition so both the base namespace and its pull request-namespaces read from one path:+Given `identity.auth.kubernetes.namespace` = `myapp` (nothing matches the suffix):```handlebars-/{{ trimSuffix identity.auth.kubernetes.namespace '-pr-*' }}/**+{{ trimSuffix identity.auth.kubernetes.namespace '-prod' }} -> myapp```