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
address comments
adilson17a615a5869c
diff --git a/backend/src/services/app-connection/gitlab/gitlab-connection-fns.ts b/backend/src/services/app-connection/gitlab/gitlab-connection-fns.tsindex 7bb220d9b7..c8651ed657 100644--- a/backend/src/services/app-connection/gitlab/gitlab-connection-fns.ts+++ b/backend/src/services/app-connection/gitlab/gitlab-connection-fns.ts@@ -355,6 +355,7 @@ export const listGitLabProjects = async ({pagination: "offset",...(limit !== undefined ? { perPage: limit } : {}),...(search ? { search } : {}),+ maxPages: 1,archived: false,includePendingDelete: false,membership: true,diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsxindex c6900e353a..343711328e 100644--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsx+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsx@@ -1,4 +1,4 @@-import { useEffect, useState } from "react";+import { useEffect, useMemo, useState } from "react";import { Controller, useFormContext, useWatch } from "react-hook-form";import { MultiValue, SingleValue } from "react-select";import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";@@ -61,31 +61,71 @@ export const GitLabDataSourceConfigFields = () => {const scope = watch("config.scope");const groupName = watch("config.groupName");const includeProjects = watch("config.includeProjects");+ const projectId = watch("config.projectId");+ const projectName = watch("config.projectName");+ const groupId = watch("config.groupId");const [projectSearch, setProjectSearch] = useState("");const [debouncedProjectSearch] = useDebounce(projectSearch, 300);const [groupSearch, setGroupSearch] = useState("");const [debouncedGroupSearch] = useDebounce(groupSearch, 300);- const projectListLimit = debouncedProjectSearch ? undefined : GITLAB_DATA_SOURCE_LIST_LIMIT;- const groupListLimit = debouncedGroupSearch ? undefined : GITLAB_DATA_SOURCE_LIST_LIMIT;-const { data: projects, isPending: isProjectsPending } = useGitLabConnectionListProjects(connectionId,debouncedProjectSearch || undefined,- projectListLimit,+ GITLAB_DATA_SOURCE_LIST_LIMIT,{ enabled: Boolean(connectionId) });const { data: groups, isPending: isGroupsPending } = useGitLabConnectionListGroups(connectionId,debouncedGroupSearch || undefined,- groupListLimit,+ GITLAB_DATA_SOURCE_LIST_LIMIT,{enabled: Boolean(connectionId) && scope === GitLabDataSourceScope.Group});+ const groupOptions = useMemo(() => {+ const results = groups ?? [];+ if (+ groupId &&+ groupName &&+ !results.some((group) => Number.parseInt(group.id, 10) === groupId)+ ) {+ return [+ { id: String(groupId), name: groupName, fullName: groupName, fullPath: groupName },+ ...results+ ];+ }+ return results;+ }, [groups, groupId, groupName]);++ const projectOptions = useMemo(() => {+ const results = projects ?? [];+ if (+ projectId &&+ projectName &&+ !results.some((project) => Number.parseInt(project.id, 10) === projectId)+ ) {+ return [{ id: String(projectId), name: projectName }, ...results];+ }+ return results;+ }, [projects, projectId, projectName]);++ const includeProjectOptions = useMemo(() => {+ const selectedGroupPath = (groups ?? []).find(+ (group) => Number.parseInt(group.id, 10) === groupId+ )?.fullPath;+ const filtered = (projects ?? []).filter(+ (project) => !selectedGroupPath || project.name.startsWith(`${selectedGroupPath}/`)+ );+ const missing = (includeProjects ?? [])+ .filter((name) => name !== "*" && !filtered.some((project) => project.name === name))+ .map((name) => ({ id: name, name }));+ return [...missing, ...filtered];+ }, [projects, groups, groupId, includeProjects]);+const scanMethod =!includeProjects || includeProjects.includes("*")? ScanMethod.AllProjects@@ -176,7 +216,13 @@ export const GitLabDataSourceConfigFields = () => {helperText={<TooltipclassName="max-w-md"- content={<>Ensure that your connection has the correct permissions.</>}+ content={+ <>+ Ensure the project exists in the connection's GitLab instance URL and the+ connection has access to it. Only the first results are shown, search by name+ to find more.+ </>+ }><div><span>Don't see the project you're looking for?</span>{" "}@@ -188,7 +234,7 @@ export const GitLabDataSourceConfigFields = () => {<FilterableSelectisLoading={isProjectsPending && Boolean(connectionId)}isDisabled={!connectionId}- value={projects?.find((project) => value === Number.parseInt(project.id, 10))}+ value={projectOptions.find((project) => value === Number.parseInt(project.id, 10))}onChange={(newValue) => {const project = newValue as SingleValue<TGitLabProject>;@@ -197,7 +243,7 @@ export const GitLabDataSourceConfigFields = () => {}}onInputChange={(newValue) => setProjectSearch(newValue)}filterOption={null}- options={projects}+ options={projectOptions}placeholder="Search for a project..."getOptionLabel={(option) => {const shortName = option.name.split("/").pop() || option.name;@@ -222,7 +268,13 @@ export const GitLabDataSourceConfigFields = () => {helperText={<TooltipclassName="max-w-md"- content={<>Ensure that your connection has the correct permissions.</>}+ content={+ <>+ Ensure the group exists in the connection's GitLab instance URL and the+ connection has access to it. Only the first results are shown, search by+ name to find more.+ </>+ }><div><span>Don't see the group you're looking for?</span>{" "}@@ -234,7 +286,7 @@ export const GitLabDataSourceConfigFields = () => {<FilterableSelectisLoading={isGroupsPending && Boolean(connectionId)}isDisabled={!connectionId}- value={groups?.find((group) => value === Number.parseInt(group.id, 10))}+ value={groupOptions.find((group) => value === Number.parseInt(group.id, 10))}onChange={(newValue) => {const group = newValue as SingleValue<TGitLabGroup>;@@ -244,7 +296,7 @@ export const GitLabDataSourceConfigFields = () => {}}onInputChange={(newValue) => setGroupSearch(newValue)}filterOption={null}- options={groups}+ options={groupOptions}placeholder="Search for a group..."getOptionLabel={(option) => `${option.name} · ${option.fullPath}`}formatOptionLabel={formatGitLabGroupOptionLabel}@@ -286,7 +338,13 @@ export const GitLabDataSourceConfigFields = () => {helperText={<TooltipclassName="max-w-md"- content={<>Ensure that your connection has the correct permissions.</>}+ content={+ <>+ Ensure the project exists in the connection's GitLab instance URL and+ the connection has access to it. Only the first results are shown, search+ by name to find more.+ </>+ }><div><span>Don't see the project you're looking for?</span>{" "}@@ -300,7 +358,7 @@ export const GitLabDataSourceConfigFields = () => {isLoading={isProjectsPending && Boolean(connectionId)}isDisabled={!connectionId || !groupName}isMulti- value={projects?.filter((project) => value.includes(project.name))}+ value={includeProjectOptions.filter((project) => value.includes(project.name))}onChange={(newValue) => {onChange(newValue@@ -310,7 +368,7 @@ export const GitLabDataSourceConfigFields = () => {}}onInputChange={(newValue) => setProjectSearch(newValue)}filterOption={null}- options={projects?.filter((project) => project.name.startsWith(groupName))}+ options={includeProjectOptions}placeholder="Search for projects..."getOptionLabel={(option) => {const shortName = option.name.split("/").pop() || option.name;diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GitLabSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GitLabSyncFields.tsxindex 077a33dc29..148558b147 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GitLabSyncFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GitLabSyncFields.tsx@@ -111,13 +111,10 @@ export const GitLabSyncFields = () => {const groupId = useWatch({ name: "destinationConfig.groupId", control });const groupName = useWatch({ name: "destinationConfig.groupName", control });- const groupListLimit = debouncedGroupSearch ? undefined : GITLAB_SYNC_LIST_LIMIT;- const projectListLimit = debouncedProjectSearch ? undefined : GITLAB_SYNC_LIST_LIMIT;-const { data: groups, isLoading: isGroupsLoading } = useGitLabConnectionListGroups(connectionId,debouncedGroupSearch || undefined,- groupListLimit,+ GITLAB_SYNC_LIST_LIMIT,{enabled: Boolean(connectionId) && scope === GitLabSyncScope.Group}@@ -126,7 +123,7 @@ export const GitLabSyncFields = () => {const { data: projects, isLoading: isProjectsLoading } = useGitLabConnectionListProjects(connectionId,debouncedProjectSearch || undefined,- projectListLimit,+ GITLAB_SYNC_LIST_LIMIT,{enabled: Boolean(connectionId) && scope === GitLabSyncScope.Project}@@ -218,7 +215,7 @@ export const GitLabSyncFields = () => {</TooltipTrigger><TooltipContent className="max-w-md">Ensure the group exists in the connection's GitLab instance URL. Only the- first results are shown — search by name to find more.+ first results are shown, search by name to find more.</TooltipContent></Tooltip></FieldLabel>@@ -266,8 +263,8 @@ export const GitLabSyncFields = () => {</TooltipTrigger><TooltipContent className="max-w-md">Ensure the project exists in the connection's GitLab instance URL and the- connection has access to it. Only the first results are shown — search by name- to find more.+ connection has access to it. Only the first results are shown, search by name to+ find more.</TooltipContent></Tooltip></FieldLabel>