Skip to content

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

Address greptile comments

Carlos Monastyrski04ac7edb1a1c
diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts
index 10cb264a20..675e1f5d18 100644
--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts
+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts
@@ -328,7 +328,7 @@ describe("rotateScheduledAccount recovery probe", () => {
expect(newPassword.length).toBe(30);
});
- test("caps an Oracle password whose required minimums sum above the ceiling", async () => {
+ test("refuses to rotate when the template's minimums cannot fit Oracle's ceiling", async () => {
const account = {
...buildAccount(),
accountType: PamAccountType.OracleDB,
@@ -343,13 +343,13 @@ describe("rotateScheduledAccount recovery probe", () => {
};
const { service, applyPasswordChange } = buildService((pw) => pw === CURRENT_PASSWORD, { account });
- await service.rotateScheduledAccount("acc-1");
+ const result = await service.rotateScheduledAccount("acc-1");
- const { newPassword } = applyPasswordChange.mock.calls[0][0] as { newPassword: string };
- expect(newPassword.length).toBe(30);
+ expect(result?.rotationStatus).toBe(ROTATION_STATUS.Failed);
+ expect(applyPasswordChange).not.toHaveBeenCalled();
});
- test("keeps every character class the template asked for when it caps", async () => {
+ test("caps only the length when the template's character mix still fits", async () => {
const account = {
...buildAccount(),
accountType: PamAccountType.OracleDB,
@@ -357,7 +357,7 @@ describe("rotateScheduledAccount recovery probe", () => {
rotation: { enabled: true, intervalSeconds: 3600 as number | null },
passwordRequirements: {
length: 80,
- required: { lowercase: 20, uppercase: 20, digits: 20, symbols: 20 },
+ required: { lowercase: 5, uppercase: 5, digits: 5, symbols: 5 },
allowedSymbols: "-_.~!*"
}
}
diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
index eed39c5b9c..cafea92abf 100644
--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
@@ -163,17 +163,15 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
): TGeneratedPasswordRequirements => {
if (accountType !== PamAccountType.OracleDB) return requirements;
const effective = requirements ?? DEFAULT_PASSWORD_REQUIREMENTS;
+ if (effective.length <= ORACLE_MAX_PASSWORD_LENGTH) return requirements;
+
const requiredTotal = Object.values(effective.required).reduce((sum, count) => sum + count, 0);
- if (effective.length <= ORACLE_MAX_PASSWORD_LENGTH && requiredTotal <= ORACLE_MAX_PASSWORD_LENGTH) {
- return requirements;
+ if (requiredTotal > ORACLE_MAX_PASSWORD_LENGTH) {
+ throw new BadRequestError({
+ message: `This account's template requires at least ${requiredTotal} characters, which is more than the ${ORACLE_MAX_PASSWORD_LENGTH} an Oracle password allows. Lower the character requirements on the template, then rotate again`
+ });
}
- return {
- ...effective,
- length: Math.min(effective.length, ORACLE_MAX_PASSWORD_LENGTH),
- required: Object.fromEntries(
- Object.entries(effective.required).map(([type, count]) => [type, count > 0 ? 1 : 0])
- ) as typeof effective.required
- };
+ return { ...effective, length: ORACLE_MAX_PASSWORD_LENGTH };
};
const getPasswordRequirements = (templateSettings: unknown) =>
diff --git a/backend/src/ee/services/pam-account/pam-account-connection-test.ts b/backend/src/ee/services/pam-account/pam-account-connection-test.ts
index 1723ad535d..e3d14175e7 100644
--- a/backend/src/ee/services/pam-account/pam-account-connection-test.ts
+++ b/backend/src/ee/services/pam-account/pam-account-connection-test.ts
@@ -8,7 +8,14 @@ import {
} from "../pam-session/aws-iam/aws-iam-federation";
import { AZURE_SCOPES, getAzureAccessToken } from "../pam-session/azure/azure-federation";
import { mintGcpAccessToken } from "../pam-session/gcp/gcp-federation";
-import { extractGatewayTarget, isCredentialConfigured, qualifyUsernameWithDomain } from "./pam-account-schemas";
+import {
+ extractGatewayTarget,
+ isCredentialConfigured,
+ ORACLE_MAX_PASSWORD_LENGTH,
+ qualifyUsernameWithDomain
+} from "./pam-account-schemas";
+
+export { ORACLE_MAX_PASSWORD_LENGTH };
export enum TestConnectionMode {
SQL = "sql",
@@ -91,8 +98,6 @@ const SQL_DIALECTS = {
const tcp = (host: string, port: number) => ({ host, port, request: { mode: TestConnectionMode.Tcp } as const });
-export const ORACLE_MAX_PASSWORD_LENGTH = 30;
-
export const exceedsOraclePasswordLimit = (
accountType: PamAccountType,
credentials: Record<string, unknown> | null
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.ts
index a431124b4c..c6e3a48b60 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -81,6 +81,8 @@ type TFieldConditionHint = { field: string; equals: string | boolean };
type TFieldForcedRuleHint = { when: TFieldConditionHint; value: string | number | boolean; reason: string };
// Source of truth for account types: per-type schemas + sparse UI hints
+export const ORACLE_MAX_PASSWORD_LENGTH = 30;
+
export const ACCOUNT_TYPE_CONFIGS = {
[PamAccountType.Postgres]: {
name: "PostgreSQL",
@@ -337,7 +339,9 @@ export const ACCOUNT_TYPE_CONFIGS = {
password: z
.string()
.trim()
- .max(256)
+ .max(ORACLE_MAX_PASSWORD_LENGTH, {
+ message: `Oracle passwords are limited to ${ORACLE_MAX_PASSWORD_LENGTH} characters`
+ })
.transform((v) => v || undefined)
.optional()
}),
diff --git a/docs/documentation/platform/pam/product-reference/credential-rotation/oracledb.mdx b/docs/documentation/platform/pam/product-reference/credential-rotation/oracledb.mdx
index c80bce22cd..12781bebb4 100644
--- a/docs/documentation/platform/pam/product-reference/credential-rotation/oracledb.mdx
+++ b/docs/documentation/platform/pam/product-reference/credential-rotation/oracledb.mdx
@@ -18,6 +18,12 @@ When an Oracle account rotates, the rotation account connects to the target and
ALTER USER "<target_username>" IDENTIFIED BY "<generated_password>";
```
+An account that rotates its own password restates the old one, which Oracle requires when a password policy is in force:
+
+```sql
+ALTER USER "<target_username>" IDENTIFIED BY "<generated_password>" REPLACE "<current_password>";
+```
+
The connection uses the account's existing connection details, including the SSL settings.
The statement matches the stored username exactly, so an account whose username doesn't match the case Oracle stored fails to rotate even though its sessions launch fine. Oracle reports this as a privilege error, not a missing user.
diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.ts
index ce61ad7611..5ed3937407 100644
--- a/frontend/src/hooks/api/pam/enums.ts
+++ b/frontend/src/hooks/api/pam/enums.ts
@@ -38,6 +38,11 @@ export const ROTATABLE_PAM_ACCOUNT_TYPES = [
export const isRotatablePamAccountType = (type: PamAccountType | string) =>
(ROTATABLE_PAM_ACCOUNT_TYPES as string[]).includes(type);
+export const ORACLE_MAX_PASSWORD_LENGTH = 30;
+
+export const maxGeneratedPasswordLength = (type: PamAccountType | string | undefined) =>
+ type === PamAccountType.OracleDB ? ORACLE_MAX_PASSWORD_LENGTH : 250;
+
export enum PamHeartbeatStatus {
Healthy = "healthy",
InvalidCredentials = "invalid-credentials",
diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
index 1c3f634391..70d4e56c7d 100644
--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
@@ -36,6 +36,7 @@ import { AppConnection, useListAvailableAppConnections } from "@app/hooks/api/ap
import {
accountTypeRequiresRecording,
isRotatablePamAccountType,
+ maxGeneratedPasswordLength,
PAM_ROTATION_INTERVAL_OPTIONS,
PamAccountType,
useGetPamAccountTemplate,
@@ -304,6 +305,9 @@ const SettingsTab = ({
}
});
+ const maxPwLength = maxGeneratedPasswordLength(template?.type);
+ const defaultPwLength = Math.min(32, maxPwLength);
+
useEffect(() => {
onDirtyChange?.(isDirty);
return () => onDirtyChange?.(false);
@@ -350,7 +354,7 @@ const SettingsTab = ({
heartbeatIntervalSeconds: heartbeat.intervalSeconds ?? 86400,
rotationIntervalSeconds:
rotation.intervalSeconds !== undefined ? rotation.intervalSeconds : 86400,
- pwLength: pw.length ?? 32,
+ pwLength: pw.length ?? defaultPwLength,
pwUppercase: pw.required?.uppercase ?? 1,
pwLowercase: pw.required?.lowercase ?? 1,
pwDigits: pw.required?.digits ?? 1,
@@ -425,7 +429,7 @@ const SettingsTab = ({
intervalSeconds: isRotationOn ? (data.settings.rotationIntervalSeconds ?? 86400) : null
};
settings.passwordRequirements = {
- length: data.settings.pwLength ?? 32,
+ length: data.settings.pwLength ?? defaultPwLength,
required: {
uppercase: data.settings.pwUppercase ?? 0,
lowercase: data.settings.pwLowercase ?? 0,
@@ -582,6 +586,7 @@ const SettingsTab = ({
<FieldLabel>{label}</FieldLabel>
<Input
type="number"
+ max={name === "settings.pwLength" ? maxPwLength : undefined}
value={field.value ?? 0}
onChange={(e) => field.onChange(Number(e.target.value))}
onWheel={(e) => e.currentTarget.blur()}