Skip to content

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

addressed some comments

Matheus Nogueira9459a8bb3df5
diff --git a/backend/src/lib/dotenv/index.test.ts b/backend/src/lib/dotenv/index.test.ts
index 3e817927bb..5e8dba411d 100644
--- a/backend/src/lib/dotenv/index.test.ts
+++ b/backend/src/lib/dotenv/index.test.ts
@@ -60,6 +60,14 @@ describe("serializeEnvFile", () => {
test("allows underscores and dots in keys", () => {
expect(serializeEnvFile({ "MY_KEY.sub": "val" })).toBe("MY_KEY.sub=val");
});
+
+ test("quotes values containing hash to prevent inline comment parsing", () => {
+ expect(serializeEnvFile({ KEY: "foo#bar" })).toBe('KEY="foo#bar"');
+ });
+
+ test("quotes values containing equals sign", () => {
+ expect(serializeEnvFile({ KEY: "a=b" })).toBe('KEY="a=b"');
+ });
});
describe("parseEnvFile", () => {
@@ -87,10 +95,18 @@ describe("parseEnvFile", () => {
expect(parseEnvFile("# comment\n\nKEY=val\n \n# another")).toEqual({ KEY: "val" });
});
- test("handles value containing equals sign", () => {
+ test("handles unquoted value containing equals sign", () => {
expect(parseEnvFile("KEY=a=b=c")).toEqual({ KEY: "a=b=c" });
});
+ test("handles quoted value containing equals sign", () => {
+ expect(parseEnvFile('KEY="a=b=c"')).toEqual({ KEY: "a=b=c" });
+ });
+
+ test("handles quoted value containing hash", () => {
+ expect(parseEnvFile('KEY="foo#bar"')).toEqual({ KEY: "foo#bar" });
+ });
+
test("handles empty value", () => {
expect(parseEnvFile("KEY=")).toEqual({ KEY: "" });
});
@@ -120,6 +136,9 @@ describe("round-trip", () => {
{ QUOTES: 'say "hello"' },
{ BACKSLASH: "C:\\Users\\test" },
{ MIXED: 'val with "quotes" and\nnewlines and \\backslash' },
+ { HASH: "foo#bar#baz" },
+ { EQUALS: "a=b=c" },
+ { HASH_EQUALS_BACKSLASH: "path\\to#file=value" },
{ EMPTY: "" },
{ A: "1", B: "2", C: "3" },
{ "my-secret": "hyphenated" },
diff --git a/backend/src/lib/dotenv/index.ts b/backend/src/lib/dotenv/index.ts
index 776f74da34..35f2b2e99a 100644
--- a/backend/src/lib/dotenv/index.ts
+++ b/backend/src/lib/dotenv/index.ts
@@ -3,7 +3,7 @@ import RE2 from "re2";
const DOTENV_KEY_RE = new RE2(/^[^\n\r=]+$/);
const escapeValue = (value: string): string => {
- if (/[\n\r"\\]/.test(value) || value !== value.trim()) {
+ if (/[\n\r"\\#=]/.test(value) || value !== value.trim()) {
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r");
return `"${escaped}"`;
}
diff --git a/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.ts b/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.ts
index 063a2d6ca4..dd890bc483 100644
--- a/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.ts
+++ b/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.ts
@@ -16,6 +16,6 @@ export const SPACELIFT_SYNC_LIST_OPTION: TSecretSyncListItem = {
name: "Spacelift",
destination: SecretSync.Spacelift,
connection: AppConnection.Spacelift,
- canImportSecrets: true,
+ canImportSecrets: false,
canRemoveSecretsOnDeletion: true
};
diff --git a/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.ts b/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.ts
index b70ec35a34..1f7a0283e2 100644
--- a/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.ts
+++ b/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.ts
@@ -46,7 +46,7 @@ const SpaceliftSyncDestinationConfigSchema = z
}
});
-const SpaceliftSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: true };
+const SpaceliftSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: false };
const SpaceliftSyncOptionsSchema = z.object({
writeOnly: z.boolean().optional().default(false).describe(SecretSyncs.ADDITIONAL_SYNC_OPTIONS.SPACELIFT.writeOnly)
@@ -84,7 +84,7 @@ export const SpaceliftSyncListItemSchema = z
name: z.literal("Spacelift"),
connection: z.literal(AppConnection.Spacelift),
destination: z.literal(SecretSync.Spacelift),
- canImportSecrets: z.literal(true),
+ canImportSecrets: z.literal(false),
canRemoveSecretsOnDeletion: z.literal(true)
})
.describe(JSON.stringify({ title: SECRET_SYNC_NAME_MAP[SecretSync.Spacelift] }));
diff --git a/docs/integrations/app-connections/spacelift.mdx b/docs/integrations/app-connections/spacelift.mdx
index 0ec0c179c5..34e092bcc0 100644
--- a/docs/integrations/app-connections/spacelift.mdx
+++ b/docs/integrations/app-connections/spacelift.mdx
@@ -29,7 +29,7 @@ Infisical supports connecting to Spacelift using an API key ID and API key secre
![Set API Key Name](/images/app-connections/spacelift/spacelift-set-api-key-name.png)
</Step>
<Step title="Configure Roles, Space, and Create">
- Select the roles **Space reader** and **Space writer**, choose the Space that will be managed by this credential, then click **Add** and **Create API Key**. A file will be downloaded containing your credentials.
+ Select the **Space admin** role (or a custom role with at least **Space reader**, **Space writer**, and **Context update** permissions), choose the Space that will be managed by this credential, then click **Add** and **Create API Key**. A file will be downloaded containing your credentials.
![Select Roles](/images/app-connections/spacelift/spacelift-select-roles.png)
</Step>
@@ -43,7 +43,7 @@ Infisical supports connecting to Spacelift using an API key ID and API key secre
<Steps>
<Step title="Navigate to App Connections">
Navigate to the **Integrations** tab in the desired project, then select **App Connections**.
- ![App Connections Tab](/images/app-connections/general/add-connection.png)
+ ![App Connections Tab](/images/app-connections/general/revamped-app-connection-tab.png)
</Step>
<Step title="Add Connection">
Select the **Spacelift Connection** option from the connection options modal.
@@ -52,6 +52,11 @@ Infisical supports connecting to Spacelift using an API key ID and API key secre
<Step title="Input Credentials">
Enter your Spacelift API URL, API Key ID, and API Key Secret in the provided fields and
click **Connect to Spacelift** to establish the connection.
+
+ <Note>
+ The API URL is the base URL of your Spacelift account (e.g., `https://myorgname.app.us.spacelift.io/`).
+ </Note>
+
![Connect to Spacelift](/images/app-connections/spacelift/spacelift-app-connection-form.png)
</Step>
<Step title="Connection Created">
diff --git a/docs/integrations/secret-syncs/spacelift.mdx b/docs/integrations/secret-syncs/spacelift.mdx
index b456d53045..0ba50ac126 100644
--- a/docs/integrations/secret-syncs/spacelift.mdx
+++ b/docs/integrations/secret-syncs/spacelift.mdx
@@ -52,19 +52,12 @@ description: "Learn how to configure a Spacelift Sync for Infisical."
<Step title="Configure sync options">
Configure the **Sync Options**, then click **Next**.
- - **Initial Sync Behavior**: Determines how Infisical resolves the first sync.
- - **Overwrite Destination Secrets**: Removes any secrets at the destination not present in Infisical.
- - **Import Secrets (Prioritize Infisical)**: Imports secrets from Spacelift before syncing, prioritizing values from Infisical over Spacelift when keys conflict.
- - **Import Secrets (Prioritize Spacelift)**: Imports secrets from Spacelift before syncing, prioritizing values from Spacelift over Infisical when keys conflict.
+ - **Initial Sync Behavior**: Only **Overwrite Destination Secrets** is supported. Infisical cannot read secrets back from Spacelift because variables marked as secret in the Spacelift API are write-only, so importing is not possible.
- **Key Schema**: A template that transforms secret names when syncing. Use `{{secretKey}}` for the original secret name and `{{environment}}` for the environment.
- **Auto-Sync Enabled**: Automatically sync secrets from the source location when changes occur. Disable this to sync manually only.
- **Disable Secret Deletion**: Prevents Infisical from removing secrets at the destination. Enable this when you intend to manage destination secrets outside Infisical.
- **Mark as Secret**: When enabled, synced variables are marked as secrets in Spacelift. Secret values are only available to Runs and Tasks and are not accessible in the web GUI or through the API.
- <Warning>
- Variables marked as secret in Spacelift cannot be read back by Infisical. When using an import sync behavior, only plaintext variable values will be imported. If **Disable Secret Deletion** is not enabled, any existing secret variables in the Spacelift context that are not present in Infisical will be deleted during sync.
- </Warning>
-
![Configure Sync Options](/images/secret-syncs/spacelift/spacelift-sync-options.png)
</Step>
<Step title="Configure details">
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx
index 7a8ee88cf6..7a27693554 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx
@@ -390,17 +390,6 @@ export const SecretSyncInitialSyncBehaviorFields = () => {
</AlertDescription>
</Alert>
)}
- {destination === SecretSync.Spacelift &&
- currentInitialBehavior !== SecretSyncInitialSyncBehavior.OverwriteDestination && (
- <Alert className="mb-3" variant="warning">
- <TriangleAlert />
- <AlertTitle>Secret values are not imported</AlertTitle>
- <AlertDescription>
- Variables marked as secret in Spacelift cannot be read back, so only plaintext
- variable values will be imported.
- </AlertDescription>
- </Alert>
- )}
{destination === SecretSync.Vercel &&
!vercelSensitive &&
currentInitialBehavior !== SecretSyncInitialSyncBehavior.OverwriteDestination && (