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
Address greptile comments
Carlos Monastyrskica8c61d8c423
diff --git a/backend/src/ee/services/pki-scep/pki-scep-service.ts b/backend/src/ee/services/pki-scep/pki-scep-service.tsindex cd95a9217e..812a5ef9db 100644--- a/backend/src/ee/services/pki-scep/pki-scep-service.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-service.ts@@ -478,6 +478,31 @@ export const pkiScepServiceFactory = ({}if (result.status === "pending") {+ if (scepConfig.challengeType === ScepChallengeType.MICROSOFT_INTUNE) {+ const failReason =+ "Certificate issuance requires approval and cannot complete synchronously for Microsoft Intune.";+ void logEnrollmentEvent({ status: "failure", failReason });++ await validationHandler+ .reportFailure?.({+ transactionId: parsed.transactionId,+ csrDer,+ error: failReason,+ validationConnectionId: scepConfig.validationConnectionId+ })+ .catch((reportErr) =>+ logger.error(reportErr, `Failed to report SCEP pending as failure [transactionId=${parsed.transactionId}]`)+ );++ return buildCertRepFailure({+ raCertDer,+ raPrivateKeyDer,+ transactionId: parsed.transactionId,+ recipientNonce: parsed.senderNonce,+ failInfo: ScepFailInfo.BadRequest+ });+ }+void logEnrollmentEvent({ status: "pending" });return buildCertRepPending({diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 5e499f71cf..756c1516df 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -2950,7 +2950,7 @@ export const registerRoutes = async (estEnrollmentConfigDAL,acmeEnrollmentConfigDAL,scepEnrollmentConfigDAL,- appConnectionDAL,+ appConnectionService,certificateProfileDAL,certificateAuthorityDAL,certificateAuthoritySecretDAL,diff --git a/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.ts b/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.tsindex e0069af51a..ff96df2f17 100644--- a/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.ts+++ b/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.ts@@ -45,6 +45,8 @@ export const registerPkiApplicationScepEnrollmentRouter = async (server: FastifyactorId: req.permission.id,actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,+ actorRootOrgId: req.permission.rootOrgId,+ actorParentOrgId: req.permission.parentOrgId,projectId: req.internalCertManagerProjectId,applicationId: req.params.applicationId,profileId: req.params.profileId,diff --git a/backend/src/services/app-connection/microsoft-intune/microsoft-intune-connection-fns.ts b/backend/src/services/app-connection/microsoft-intune/microsoft-intune-connection-fns.tsindex 4727a867b4..c27dffd568 100644--- a/backend/src/services/app-connection/microsoft-intune/microsoft-intune-connection-fns.ts+++ b/backend/src/services/app-connection/microsoft-intune/microsoft-intune-connection-fns.ts@@ -3,6 +3,7 @@ import { randomUUID } from "crypto";import { request } from "@app/lib/config/request";import { BadRequestError, InternalServerError } from "@app/lib/errors";+import { safeRequest } from "@app/lib/validator";import { IntegrationUrls } from "@app/services/integration-auth/integration-list";import { AppConnection } from "../app-connection-enums";@@ -71,7 +72,7 @@ export const getMicrosoftEntraToken = async (export const discoverScepValidationServiceUri = async (graphAccessToken: string) => {try {const { data } = await request.get<TMicrosoftGraphServicePrincipalEndpointsResponse>(- `https://graph.microsoft.com/v1.0/servicePrincipals/appId=${INTUNE_WELL_KNOWN_APP_ID}/endpoints`,+ `https://graph.microsoft.com/v1.0/servicePrincipals(appId='${INTUNE_WELL_KNOWN_APP_ID}')/endpoints`,{headers: {Authorization: `Bearer ${graphAccessToken}`,@@ -122,7 +123,7 @@ export const intuneValidateScepRequest = async ({certificateRequest: string;}): Promise<{ allowed: boolean; errorDescription?: string }> => {try {- const { data } = await request.post<TIntuneScepValidationResponse>(+ const { data } = await safeRequest.post<TIntuneScepValidationResponse>(`${serviceUri}/ScepActions/validateRequest`,{request: {@@ -167,7 +168,7 @@ export const intuneSendSuccessNotification = async ({issuingCertificateAuthority: string;};}) => {- await request.post(+ await safeRequest.post(`${serviceUri}/ScepActions/successNotification`,{ notification: { ...notification, callerInfo: INTUNE_CALLER_INFO } },{ headers: intuneScepActionHeaders(intuneAccessToken) }@@ -188,7 +189,7 @@ export const intuneSendFailureNotification = async ({errorDescription: string;};}) => {- await request.post(+ await safeRequest.post(`${serviceUri}/ScepActions/failureNotification`,{ notification: { ...notification, callerInfo: INTUNE_CALLER_INFO } },{ headers: intuneScepActionHeaders(intuneAccessToken) }diff --git a/backend/src/services/pki-application/pki-application-enrollment-service.ts b/backend/src/services/pki-application/pki-application-enrollment-service.tsindex a489f7e8b5..5196e45559 100644--- a/backend/src/services/pki-application/pki-application-enrollment-service.ts+++ b/backend/src/services/pki-application/pki-application-enrollment-service.ts@@ -13,8 +13,8 @@ import { getConfig } from "@app/lib/config/env";import { crypto } from "@app/lib/crypto";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { TProjectPermission } from "@app/lib/types";-import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { TAppConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";import { TCertificateAuthorityCertDALFactory } from "@app/services/certificate-authority/certificate-authority-cert-dal";import { TCertificateAuthorityDALFactory } from "@app/services/certificate-authority/certificate-authority-dal";import { TCertificateAuthoritySecretDALFactory } from "@app/services/certificate-authority/certificate-authority-secret-dal";@@ -76,6 +76,8 @@ type TSetScepEnrollmentDTO = {validationConnectionId?: string;signRaWithCa?: boolean;};+ actorRootOrgId: string;+ actorParentOrgId: string;} & TProjectPermission;type TClearMethodEnrollmentDTO = {@@ -98,7 +100,7 @@ type TPkiApplicationEnrollmentServiceFactoryDep = {estEnrollmentConfigDAL: Pick<TEstEnrollmentConfigDALFactory, "create" | "updateById" | "deleteById" | "findById">;acmeEnrollmentConfigDAL: Pick<TAcmeEnrollmentConfigDALFactory, "create" | "updateById" | "deleteById" | "findById">;scepEnrollmentConfigDAL: Pick<TScepEnrollmentConfigDALFactory, "create" | "updateById" | "deleteById" | "findById">;- appConnectionDAL: Pick<TAppConnectionDALFactory, "findById">;+ appConnectionService: Pick<TAppConnectionServiceFactory, "validateAppConnectionUsageById">;certificateProfileDAL: Pick<TCertificateProfileDALFactory, "findById">;certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "findById" | "findByIdWithAssociatedCa">;certificateAuthoritySecretDAL: Pick<TCertificateAuthoritySecretDALFactory, "findOne">;@@ -121,7 +123,7 @@ export const pkiApplicationEnrollmentServiceFactory = ({estEnrollmentConfigDAL,acmeEnrollmentConfigDAL,scepEnrollmentConfigDAL,- appConnectionDAL,+ appConnectionService,certificateProfileDAL,certificateAuthorityDAL,certificateAuthoritySecretDAL,@@ -643,7 +645,9 @@ export const pkiApplicationEnrollmentServiceFactory = ({actor,actorId,actorAuthMethod,- actorOrgId+ actorOrgId,+ actorRootOrgId,+ actorParentOrgId}: TSetScepEnrollmentDTO) => {const { junction } = await $assertEditEnrollment(applicationId,@@ -667,10 +671,18 @@ export const pkiApplicationEnrollmentServiceFactory = ({message: "A Microsoft Intune connection is required for Microsoft Intune SCEP validation."});}- const connection = await appConnectionDAL.findById(config.validationConnectionId);- if (!connection || connection.orgId !== actorOrgId || connection.app !== AppConnection.MicrosoftIntune) {- throw new BadRequestError({ message: "The selected Microsoft Intune connection could not be found." });- }+ const connection = await appConnectionService.validateAppConnectionUsageById(+ AppConnection.MicrosoftIntune,+ { connectionId: config.validationConnectionId, projectId },+ {+ id: actorId,+ type: actor,+ orgId: actorOrgId,+ authMethod: actorAuthMethod,+ rootOrgId: actorRootOrgId,+ parentOrgId: actorParentOrgId+ }+ );validationConnectionId = connection.id;validationConnectionName = connection.name;}