Skip to content

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

feat: addressed grepy review

=f7c6c6754ba2
diff --git a/backend/src/ee/services/secret-rotation-v2/ssh-password/ssh-password-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/ssh-password/ssh-password-rotation-schemas.ts
index f8b16bdc5a..89c2171ab9 100644
--- a/backend/src/ee/services/secret-rotation-v2/ssh-password/ssh-password-rotation-schemas.ts
+++ b/backend/src/ee/services/secret-rotation-v2/ssh-password/ssh-password-rotation-schemas.ts
@@ -8,6 +8,7 @@ import {
} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-schemas";
import { PasswordRequirementsSchema } from "@app/ee/services/secret-rotation-v2/shared/general";
import { SecretRotations } from "@app/lib/api-docs";
+import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
import { SecretNameSchema } from "@app/server/lib/schemas";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
@@ -26,7 +27,15 @@ export const SshPasswordRotationGeneratedCredentialsSchema = z
.max(2);
const SshPasswordRotationParametersSchema = z.object({
- username: z.string().trim().min(1, "Username required").describe(SecretRotations.PARAMETERS.SSH_PASSWORD.username),
+ username: z
+ .string()
+ .trim()
+ .min(1, "Username required")
+ .refine(
+ (val) => characterValidator([CharacterType.AlphaNumeric, CharacterType.Hyphen, CharacterType.Underscore])(val),
+ "Name can only contain alphanumeric characters, dashes, underscores, and spaces"
+ )
+ .describe(SecretRotations.PARAMETERS.SSH_PASSWORD.username),
passwordRequirements: PasswordRequirementsSchema.optional(),
rotationMethod: z
.nativeEnum(SshPasswordRotationMethod)
@@ -63,15 +72,13 @@ export const CreateSshPasswordRotationSchema = BaseCreateSecretRotationSchema(Se
.optional()
})
.superRefine((val, ctx) => {
- // Password is required for both rotation methods during initial setup
- // Self rotation: needed to authenticate as the user
if (
val.parameters.rotationMethod === SshPasswordRotationMethod.LoginAsTarget &&
!val.temporaryParameters?.password
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
- message: "Current password is required for initial rotation setup in login as root method",
+ message: "Current password is required for initial rotation setup in login as target method",
path: ["temporaryParameters", "password"]
});
}
diff --git a/backend/src/services/app-connection/ssh/ssh-connection-fns.ts b/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
index fb1c7062be..517f841239 100644
--- a/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
+++ b/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
@@ -49,10 +49,12 @@ export const getSshConnectionClient = async (
err.message.includes("publickey")
) {
reject(new Error("SSH Error: Account credentials invalid."));
+ return;
}
if (err.message === "Connection timeout") {
reject(new Error("SSH Error: Connection timeout. Verify that the SSH server is reachable"));
+ return;
}
}
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SshPasswordRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SshPasswordRotationParametersFields.tsx
index 91f4c7f494..2c2b9a73c1 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SshPasswordRotationParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SshPasswordRotationParametersFields.tsx
@@ -13,7 +13,7 @@ export const SshPasswordRotationParametersFields = () => {
}
>();
- const [id] = watch(["id"]);
+ const id = watch("id");
const rotationMethod = watch(
"parameters.rotationMethod",
SshPasswordRotationMethod.LoginAsTarget