Skip to content

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

Merge branch 'main' into claude/fix-deep-search-slash-query

Claude7be21d2a58c8
diff --cc backend/src/server/routes/v1/dashboard-router.ts
index 4c415e8616,2e9384ecc5..6e60d693a4
--- a/backend/src/server/routes/v1/dashboard-router.ts
+++ b/backend/src/server/routes/v1/dashboard-router.ts
@@@ -37,10 -37,39 +37,12 @@@ import
} from "@app/services/secret/secret-types";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
+import { isSecretPathMatch, resolveSecretDeepSearch } from "./dashboard-secret-search-fns";
+
const MAX_DEEP_SEARCH_LIMIT = 500; // arbitrary limit to prevent excessive results
+ const DEEP_SEARCH_DEFAULT_PAGE_LIMIT = 25;
+ const DEEP_SEARCH_MAX_PAGE_LIMIT = 100;
-const parseSecretPathSearch = (search?: string) => {
- if (!search)
- return {
- searchName: "",
- searchPath: ""
- };
-
- if (!search.includes("/"))
- return {
- searchName: search,
- searchPath: ""
- };
-
- if (search === "/")
- return {
- searchName: "",
- searchPath: "/"
- };
-
- const [searchName, ...searchPathSegments] = search.split("/").reverse();
- let searchPath = removeTrailingSlash(searchPathSegments.reverse().join("/").toLowerCase());
- if (!searchPath.startsWith("/")) searchPath = `/${searchPath}`;
-
- return {
- searchName,
- searchPath
- };
-};
-
const SECRET_METADATA_SEARCH_MAX_FILTERS = 20;
const SecretMetadataSearchQuerySchema = z.object({
@@@ -1640,15 -1694,57 +1670,61 @@@ export const registerDashboardRouter =
}
}
- const sliceQuickSearch = <T>(array: T[]) => array.slice(0, 25);
- const matchedSecrets = searchPath ? secrets.filter((secret) => secret.secretPath.endsWith(searchPath)) : secrets;
++ const matchedSecrets = searchPath
++ ? secrets.filter((secret) => isSecretPathMatch(secret.secretPath, searchPath))
++ : secrets;
+
+ // page secrets by rendered entry (env + path + key): a shared secret and its personal override
+ // are two adjacent rows the client merges into one, so slicing raw rows would split the pair
+ // across a page boundary and over-count what actually renders
+ const secretUnitsByEntry = new Map<string, typeof matchedSecrets>();
+ for (const secret of matchedSecrets) {
+ const entryKey = `${secret.environment}\0${secret.secretPath}\0${secret.secretKey}`;
+ const unit = secretUnitsByEntry.get(entryKey);
+ if (unit) {
+ unit.push(secret);
+ } else {
+ secretUnitsByEntry.set(entryKey, [secret]);
+ }
+ }
+ const secretUnits = [...secretUnitsByEntry.values()];
- const filteredDynamicSecrets = sliceQuickSearch(
- searchPath
- ? dynamicSecrets.filter((dynamicSecret) => isSecretPathMatch(dynamicSecret.path, searchPath))
- : dynamicSecrets
- );
+ const matchedDynamicSecrets = searchPath
- ? dynamicSecrets.filter((dynamicSecret) => dynamicSecret.path.endsWith(searchPath))
++ ? dynamicSecrets.filter((dynamicSecret) => isSecretPathMatch(dynamicSecret.path, searchPath))
+ : dynamicSecrets;
+
+ const matchedSecretRotations = searchPath
- ? secretRotations.filter((rotation) => rotation.folder.path.endsWith(searchPath))
++ ? secretRotations.filter((rotation) => isSecretPathMatch(rotation.folder.path, searchPath))
+ : secretRotations;
+
+ const matchedFolders = allFolders.filter((folder) => {
+ const [folderName, ...folderPathSegments] = folder.path.split("/").reverse();
+ const folderPath = folderPathSegments.reverse().join("/").toLowerCase() || "/";
+
+ if (searchPath) {
+ if (searchPath === "/") {
+ // only show root folders if no folder name search
+ if (!searchName) return folderPath === searchPath;
+
+ // start partial match on root folders
+ return folderName.toLowerCase().startsWith(searchName.toLowerCase());
+ }
+
+ // support ending partial path match
- return folderPath.endsWith(searchPath) && folderName.toLowerCase().startsWith(searchName.toLowerCase());
++ return (
++ isSecretPathMatch(folderPath, searchPath) && folderName.toLowerCase().startsWith(searchName.toLowerCase())
++ );
+ }
+
+ // no search path, "fuzzy" match all folders
+ return folderName.toLowerCase().includes(searchName.toLowerCase());
+ });
- if (filteredDynamicSecrets?.length) {
+ const paginate = <T>(array: T[]) => array.slice(offset, offset + limit);
+
+ const paginatedDynamicSecrets = paginate(matchedDynamicSecrets);
+
+ if (paginatedDynamicSecrets.length) {
await server.services.auditLog.createAuditLog({
projectId,
...req.auditLogInfo,