mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-17 06:34:57 +00:00
Merge remote-tracking branch 'origin/main' into feat/blockDuplicateSyncDestination
This commit is contained in:
@@ -211,10 +211,18 @@ export const GithubSyncFns = {
|
||||
}
|
||||
|
||||
const { connection } = secretSync;
|
||||
const token =
|
||||
connection.method === GitHubConnectionMethod.OAuth
|
||||
? connection.credentials.accessToken
|
||||
: await getGitHubAppAuthToken(connection, gatewayService, gatewayV2Service);
|
||||
let token: string;
|
||||
|
||||
switch (connection.method) {
|
||||
case GitHubConnectionMethod.OAuth:
|
||||
token = connection.credentials.accessToken;
|
||||
break;
|
||||
case GitHubConnectionMethod.Pat:
|
||||
token = connection.credentials.personalAccessToken;
|
||||
break;
|
||||
default:
|
||||
token = await getGitHubAppAuthToken(connection, gatewayService, gatewayV2Service);
|
||||
}
|
||||
|
||||
const encryptedSecrets = await getEncryptedSecrets(secretSync, gatewayService, gatewayV2Service);
|
||||
const publicKey = await getPublicKey(secretSync, gatewayService, gatewayV2Service, token);
|
||||
@@ -269,10 +277,18 @@ export const GithubSyncFns = {
|
||||
const secretMap = Object.fromEntries(Object.entries(ogSecretMap).map(([i, v]) => [i.toUpperCase(), v]));
|
||||
|
||||
const { connection } = secretSync;
|
||||
const token =
|
||||
connection.method === GitHubConnectionMethod.OAuth
|
||||
? connection.credentials.accessToken
|
||||
: await getGitHubAppAuthToken(connection, gatewayService, gatewayV2Service);
|
||||
let token: string;
|
||||
|
||||
switch (connection.method) {
|
||||
case GitHubConnectionMethod.OAuth:
|
||||
token = connection.credentials.accessToken;
|
||||
break;
|
||||
case GitHubConnectionMethod.Pat:
|
||||
token = connection.credentials.personalAccessToken;
|
||||
break;
|
||||
default:
|
||||
token = await getGitHubAppAuthToken(connection, gatewayService, gatewayV2Service);
|
||||
}
|
||||
|
||||
const encryptedSecrets = await getEncryptedSecrets(secretSync, gatewayService, gatewayV2Service);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";
|
||||
import { getConfig } from "@app/lib/config/env";
|
||||
import { logger } from "@app/lib/logger";
|
||||
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
|
||||
import { SecretNameSchema } from "@app/server/lib/schemas";
|
||||
import { decryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";
|
||||
import { ActorType } from "@app/services/auth/auth-type";
|
||||
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
|
||||
@@ -408,6 +409,24 @@ export const secretSyncQueueFactory = ({
|
||||
|
||||
if (!Object.keys(importedSecrets).length) return {};
|
||||
|
||||
let invalidNameCount = 0;
|
||||
let errorMessage = "";
|
||||
|
||||
for (const [key] of Object.entries(importedSecrets)) {
|
||||
const result = SecretNameSchema.safeParse(key);
|
||||
if (!result.success) {
|
||||
invalidNameCount += 1;
|
||||
if (errorMessage === "") errorMessage = result.error.issues[0]?.message;
|
||||
}
|
||||
}
|
||||
|
||||
if (invalidNameCount > 0) {
|
||||
throw new SecretSyncError({
|
||||
message: `Found ${invalidNameCount} invalid secret name${invalidNameCount === 1 ? "" : "s"}. ${errorMessage}`,
|
||||
shouldRetry: false
|
||||
});
|
||||
}
|
||||
|
||||
const importedSecretMap: TSecretMap = {};
|
||||
|
||||
const secretMap = await $getInfisicalSecrets(secretSync, false);
|
||||
|
||||
Reference in New Issue
Block a user