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
feat: log more info
adilson09007dd81551
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.tsindex f948e50158..718ab2c196 100644--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@ -7191,9 +7191,11 @@ interface AccessApprovalRequestDelegatedDecisionEvent {metadata: {requestId: string;policyId: string;+ policyName?: string;delegatedApprovalType: string;- providerRequestId: string;+ delegatedProviderRequestId: string;providerRecordNumber?: string;+ permissions?: string[];outcome: string;decision?: string;decidedBy?: string;diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 41c809692c..159ccfda5c 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -3298,6 +3298,7 @@ export const registerRoutes = async (const delegatedApprovalDecisionService = delegatedApprovalDecisionServiceFactory({delegatedApprovalRequestDAL,delegatedApprovalPolicyDAL,+ approvalPolicyDAL,approvalRequestDAL,appConnectionDAL,kmsService,diff --git a/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.ts b/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.tsindex d1d9520265..b1d03ce91b 100644--- a/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.ts+++ b/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.ts@@ -29,14 +29,17 @@ vi.mock("@app/lib/telemetry/metrics", () => ({recordEventOutboxExhaustedMetric: () => {}}));-const { fetchDecision } = vi.hoisted(() => ({ fetchDecision: vi.fn() }));+const { fetchDecision, REQUESTED_PERMISSIONS } = vi.hoisted(() => ({+ fetchDecision: vi.fn(),+ REQUESTED_PERMISSIONS: ["secrets: read, create", "secret-folders: edit"]+}));vi.mock("@app/services/delegated-approval/dispatch/delegated-approval-dispatch-fns", () => ({getDelegatedApprovalProvider: () => ({ fetchDecision }),getDelegatedApprovalDispatchDetailsBuilder: () => () => ({policyType: "secret-access",environment: "dev",secretPath: "/",- permissions: ["secrets: read, create", "secret-folders: edit"],+ permissions: REQUESTED_PERMISSIONS,isTemporary: false,temporaryRange: null})@@ -50,6 +53,7 @@ const DELEGATED_REQUEST_ID = "11111111-1111-1111-1111-111111111111";const APPROVAL_REQUEST_ID = "33333333-3333-3333-3333-333333333333";const ORG_ID = "22222222-2222-2222-2222-222222222222";const EXTERNAL_ID = "snow-1";+const POLICY_NAME = "Production secrets";const TX = { tx: true } as never;const PRIMARY = { primary: true } as never;const SERVICENOW_RECORD = { type: DelegatedApprovalPolicyType.ServiceNow, recordNumber: "INFAR1000000" };@@ -135,6 +139,7 @@ const buildConsumer = ({updateWithDetails},delegatedApprovalPolicyDAL: { findOne: vi.fn().mockResolvedValue(policy) },+ approvalPolicyDAL: { findById: vi.fn().mockResolvedValue({ id: "policy-1", name: POLICY_NAME }) },approvalRequestDAL: {findById: vi.fn(async () => approval),findByIdForUpdate: vi.fn(async () => approval),@@ -179,7 +184,15 @@ const auditedWith = (createAuditLog: ReturnType<typeof vi.fn>, expected: Record<expect(createAuditLog.mock.calls[0][0]).toMatchObject({orgId: ORG_ID,projectId: "project-1",- event: { metadata: { requestId: APPROVAL_REQUEST_ID, providerRequestId: EXTERNAL_ID, ...expected } }+ event: {+ metadata: {+ requestId: APPROVAL_REQUEST_ID,+ policyName: POLICY_NAME,+ delegatedProviderRequestId: EXTERNAL_ID,+ permissions: REQUESTED_PERMISSIONS,+ ...expected+ }+ }});};diff --git a/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts b/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.tsindex d0324e573a..277c5bc7e5 100644--- a/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts+++ b/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts@@ -53,6 +53,7 @@ export type TDelegatedApprovalDecisionServiceFactory = ReturnType<typeof delegatexport const delegatedApprovalDecisionServiceFactory = ({delegatedApprovalRequestDAL,delegatedApprovalPolicyDAL,+ approvalPolicyDAL,approvalRequestDAL,appConnectionDAL,kmsService,@@ -74,9 +75,11 @@ export const delegatedApprovalDecisionServiceFactory = ({metadata: {requestId: context.approvalRequest.id,policyId: context.approvalRequest.policyId ?? "",+ ...(context.policyName ? { policyName: context.policyName } : {}),delegatedApprovalType: context.delegatedApprovalType,- providerRequestId: context.providerRequestId,+ delegatedProviderRequestId: context.providerRequestId,...(context.providerRecordNumber ? { providerRecordNumber: context.providerRecordNumber } : {}),+ ...(context.permissions ? { permissions: context.permissions } : {}),outcome: metadata.outcome,...(metadata.decided? {@@ -259,10 +262,25 @@ export const delegatedApprovalDecisionServiceFactory = ({? DELEGATED_APPROVAL_NAME_MAP[delegatedPolicy.type as DelegatedApprovalPolicyType]: undefined;+ const policy = approvalRequest.policyId ? await approvalPolicyDAL.findById(approvalRequest.policyId) : undefined;+ let permissions: string[] | undefined;+ if (isDelegatedApprovalSupportedPolicyType(approvalRequest.type)) {+ try {+ permissions = getDelegatedApprovalDispatchDetailsBuilder(approvalRequest.type)(approvalRequest).permissions;+ } catch (error) {+ logger.warn(+ error,+ `Could not read the permissions on the access request [approvalRequestId=${approvalRequest.id}]`+ );+ }+ }+const context: TDelegatedApprovalDecisionContext = {delegatedRequestId,providerRequestId: delegatedRequest.providerRequestId,providerRecordNumber: delegatedRequest.details.provider?.recordNumber,+ policyName: policy?.name,+ permissions,approvalRequest,delegatedApprovalType: delegatedApprovalName ?? "the delegated approval system"};diff --git a/backend/src/services/delegated-approval-decision/delegated-approval-decision-types.ts b/backend/src/services/delegated-approval-decision/delegated-approval-decision-types.tsindex 722a9cb7f0..1a2558c897 100644--- a/backend/src/services/delegated-approval-decision/delegated-approval-decision-types.ts+++ b/backend/src/services/delegated-approval-decision/delegated-approval-decision-types.ts@@ -1,5 +1,6 @@import { TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";+import { TApprovalPolicyDALFactory } from "@app/services/approval-policy/approval-policy-dal";import { TApprovalResource } from "@app/services/approval-policy/approval-policy-types";import { TApprovalRequestDALFactory } from "@app/services/approval-policy/approval-request-dal";import { DelegatedApprovalSupportedPolicyType } from "@app/services/delegated-approval/delegated-approval-maps";@@ -51,6 +52,7 @@ export type TDelegatedApprovalDecisionServiceFactoryDep = {"findById" | "primaryNode" | "updateWithDetails">;delegatedApprovalPolicyDAL: Pick<TDelegatedApprovalPolicyDALFactory, "findOne">;+ approvalPolicyDAL: Pick<TApprovalPolicyDALFactory, "findById">;approvalRequestDAL: Pick<TApprovalRequestDALFactory, "findById" | "findByIdForUpdate" | "updateById" | "transaction">;appConnectionDAL: Pick<TAppConnectionDALFactory, "findById">;kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;@@ -63,6 +65,8 @@ export type TDelegatedApprovalDecisionContext = {delegatedRequestId: string;providerRequestId: string;providerRecordNumber?: string;+ policyName?: string;+ permissions?: string[];approvalRequest: { id: string; organizationId: string; projectId: string; policyId?: string | null };delegatedApprovalType: string;};