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 some reviews
Andrey4efc14e2b1c6
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex 82befe0bfe..14a1995b55 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -498,11 +498,16 @@ export const ACCOUNT_TYPE_CONFIGS = {tooltip:"The account identifier from the Snowflake URL, without the snowflakecomputing.com suffix (e.g. myorg-myaccount)."},- warehouse: { tooltip: "The warehouse sessions run their queries on. Snowflake charges for its compute." },+ warehouse: {+ tooltip: "The warehouse sessions run their queries on. Leave empty to use the user's default warehouse."+ },database: { tooltip: "The database sessions open. The explorer lists the schemas and tables inside it." },- schema: { tooltip: "The schema sessions open by default." },+ schema: {+ tooltip: "The schema a session starts in. A session can still switch to another schema the role can reach."+ },role: {- tooltip: "The role sessions activate. Leave empty to use the user's default role."+ tooltip:+ "The role a session starts with. A session can still switch to another role the user holds, so grant the user only the roles its sessions should reach."},authMethod: {label: "Auth Method",diff --git a/backend/src/ee/services/pam-project/pam-project-bootstrap.ts b/backend/src/ee/services/pam-project/pam-project-bootstrap.tsindex 0b5877def7..91ab69fb6b 100644--- a/backend/src/ee/services/pam-project/pam-project-bootstrap.ts+++ b/backend/src/ee/services/pam-project/pam-project-bootstrap.ts@@ -134,6 +134,14 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres}+ },+ {+ name: "snowflake",+ type: PamAccountType.Snowflake,+ settings: {+ recordingEnabled: true,+ recordingStorageBackend: PamRecordingStorageBackend.Postgres+ }}];diff --git a/backend/src/ee/services/pam-web-access/snowflake/pam-snowflake-relay-client.ts b/backend/src/ee/services/pam-web-access/snowflake/pam-snowflake-relay-client.tsindex 26ad0edb4c..3f753a45bb 100644--- a/backend/src/ee/services/pam-web-access/snowflake/pam-snowflake-relay-client.ts+++ b/backend/src/ee/services/pam-web-access/snowflake/pam-snowflake-relay-client.ts@@ -2,6 +2,9 @@ import snowflake from "snowflake-sdk";import { BadRequestError } from "@app/lib/errors";+const STATEMENT_TIMEOUT_MS = 30 * 60 * 1000;+const LOGIN_TIMEOUT_MS = 30 * 1000;+// The gateway answers Snowflake's REST API on the relay port and authenticates for the sessionexport const connectThroughRelay = async (relayPort: number, account: string): Promise<snowflake.Connection> => {const client = snowflake.createConnection({@@ -9,15 +12,24 @@ export const connectThroughRelay = async (relayPort: number, account: string): Pusername: "pam",password: "pam",accessUrl: `http://127.0.0.1:${relayPort}`,- application: "Infisical"+ application: "Infisical",+ timeout: STATEMENT_TIMEOUT_MS});+ let loginTimer: NodeJS.Timeout | undefined;try {- return await client.connectAsync();+ return await Promise.race([+ client.connectAsync(),+ new Promise<never>((_, reject) => {+ loginTimer = setTimeout(() => reject(new Error("timed out")), LOGIN_TIMEOUT_MS);+ })+ ]);} catch (err) {client.destroy(() => {});throw new BadRequestError({message: `Unable to reach Snowflake through the gateway: ${(err as Error)?.message ?? "connection failed"}`});+ } finally {+ clearTimeout(loginTimer);}};diff --git a/docs/documentation/platform/pam/accounts/snowflake.mdx b/docs/documentation/platform/pam/accounts/snowflake.mdxindex a325902ab0..22c30b9630 100644--- a/docs/documentation/platform/pam/accounts/snowflake.mdx+++ b/docs/documentation/platform/pam/accounts/snowflake.mdx@@ -6,12 +6,12 @@ description: "Add and connect to Snowflake accounts."Snowflake accounts let you manage access to a Snowflake database. Users connect through Web Access or the CLI, and every statement they run is recorded in the [session](/documentation/platform/pam/sessions/overview).-Snowflake has no database wire protocol, so the [gateway](/documentation/platform/gateways/overview) answers the REST API its drivers speak and runs each statement itself. The credential never reaches the client, and because the gateway sits in your own network, an account behind AWS PrivateLink or a network policy is reachable like any other target.+Every statement runs from the [gateway](/documentation/platform/gateways/overview) in your own network, and the credential never reaches the client. Make sure the gateway can reach your Snowflake account, including over AWS PrivateLink if that's how you expose it.## Prerequisites- A Snowflake user for Infisical to connect as.-- A warehouse the user's role can use. Snowflake bills for the compute a session's queries consume.+- A warehouse the user's role can use.- A [gateway](/documentation/platform/gateways/overview) that can reach your Snowflake account. Snowflake returns large results from cloud object storage rather than from the account host, so a gateway behind an egress allowlist needs that storage reachable too.- A key pair or a programmatic access token for that user. Snowflake blocks single-factor password sign-in for human users, so password authentication only works for a service user whose account policy still permits it.@@ -125,7 +125,7 @@ Command blocking matches the text of each statement, so a statement that builds</Tab></Tabs>-Results are capped at 10,000 rows per statement, and the Data Explorer shows the first 1,000 rows of a result and tells you when there are more.+Infisical caps results at 10,000 rows per statement so a large query can't exhaust the gateway's memory, and the Data Explorer shows the first 1,000 of those and tells you when there are more. Snowflake itself imposes no such limit; use the CLI with your own client to work with a full result set.<Note>Snowflake doesn't enforce primary keys, but the Data Explorer still needs one declared on a table before it can edit that table's rows. A table without one is read-only in the grid, and editable from the SQL editor.diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsxindex 9693ea5272..646c8d156e 100644--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx@@ -531,6 +531,7 @@ const SettingsTab = ({return (<Editorkey={p.key}+ accountType={template.type as PamAccountType}label={p.label}description={p.description}value={policies[p.key]}diff --git a/frontend/src/pages/pam/components/policyEditors/index.tsx b/frontend/src/pages/pam/components/policyEditors/index.tsxindex efce9fff87..8045d43f8c 100644--- a/frontend/src/pages/pam/components/policyEditors/index.tsx+++ b/frontend/src/pages/pam/components/policyEditors/index.tsx@@ -1,6 +1,6 @@import { ComponentType } from "react";-import { PamPolicyType } from "@app/hooks/api/pam";+import { PamAccountType, PamPolicyType } from "@app/hooks/api/pam";import { BooleanPolicyEditor } from "./BooleanPolicyEditor";import { DurationPolicyEditor } from "./DurationPolicyEditor";@@ -10,8 +10,18 @@ import { PolicyEditorProps } from "./types";const DEFAULT_PATTERN_PLACEHOLDER ="rm\\s+-rf.*\npassword\\s*=\\s*\\S+\n\\b\\d{3}-\\d{2}-\\d{4}\\b";-const CommandBlockingEditor = (props: PolicyEditorProps) => (- <TextAreaPolicyEditor {...props} placeholder={DEFAULT_PATTERN_PLACEHOLDER} />+const SQL_PATTERN_PLACEHOLDER = "^\\s*drop\\b\n\\btruncate\\b\n^\\s*grant\\b";++const COMMAND_BLOCKING_PLACEHOLDERS: Partial<Record<PamAccountType, string>> = {+ [PamAccountType.Snowflake]: SQL_PATTERN_PLACEHOLDER+};++const CommandBlockingEditor = ({ accountType, ...props }: PolicyEditorProps) => (+ <TextAreaPolicyEditor+ {...props}+ accountType={accountType}+ placeholder={COMMAND_BLOCKING_PLACEHOLDERS[accountType] ?? DEFAULT_PATTERN_PLACEHOLDER}+ />);export const POLICY_EDITORS: Partial<Record<PamPolicyType, ComponentType<PolicyEditorProps>>> = {diff --git a/frontend/src/pages/pam/components/policyEditors/types.ts b/frontend/src/pages/pam/components/policyEditors/types.tsindex 031d3b277a..02bca614c9 100644--- a/frontend/src/pages/pam/components/policyEditors/types.ts+++ b/frontend/src/pages/pam/components/policyEditors/types.ts@@ -1,4 +1,7 @@+import { PamAccountType } from "@app/hooks/api/pam";+export type PolicyEditorProps = {+ accountType: PamAccountType;label: string;description: string;value: unknown;