mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 02:26:26 +00:00
Greptile review fixes
This commit is contained in:
@@ -27,6 +27,7 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
|
.max(100, "Cannot have more than 100 approvers")
|
||||||
.min(1, { message: "At least one approver should be provided" }),
|
.min(1, { message: "At least one approver should be provided" }),
|
||||||
bypassers: z
|
bypassers: z
|
||||||
.discriminatedUnion("type", [
|
.discriminatedUnion("type", [
|
||||||
@@ -34,6 +35,7 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
|
.max(100, "Cannot have more than 100 bypassers")
|
||||||
.optional(),
|
.optional(),
|
||||||
approvals: z.number().min(1).default(1),
|
approvals: z.number().min(1).default(1),
|
||||||
enforcementLevel: z.nativeEnum(EnforcementLevel).default(EnforcementLevel.Hard),
|
enforcementLevel: z.nativeEnum(EnforcementLevel).default(EnforcementLevel.Hard),
|
||||||
@@ -154,13 +156,15 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
.min(1, { message: "At least one approver should be provided" }),
|
.min(1, { message: "At least one approver should be provided" })
|
||||||
|
.max(100, "Cannot have more than 100 approvers"),
|
||||||
bypassers: z
|
bypassers: z
|
||||||
.discriminatedUnion("type", [
|
.discriminatedUnion("type", [
|
||||||
z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
|
z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
|
||||||
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
|
.max(100, "Cannot have more than 100 bypassers")
|
||||||
.optional(),
|
.optional(),
|
||||||
approvals: z.number().min(1).optional(),
|
approvals: z.number().min(1).optional(),
|
||||||
enforcementLevel: z.nativeEnum(EnforcementLevel).default(EnforcementLevel.Hard),
|
enforcementLevel: z.nativeEnum(EnforcementLevel).default(EnforcementLevel.Hard),
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
.min(1, { message: "At least one approver should be provided" }),
|
.min(1, { message: "At least one approver should be provided" })
|
||||||
|
.max(100, "Cannot have more than 100 approvers"),
|
||||||
bypassers: z
|
bypassers: z
|
||||||
.discriminatedUnion("type", [
|
.discriminatedUnion("type", [
|
||||||
z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
|
z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
|
||||||
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
|
.max(100, "Cannot have more than 100 bypassers")
|
||||||
.optional(),
|
.optional(),
|
||||||
approvals: z.number().min(1).default(1),
|
approvals: z.number().min(1).default(1),
|
||||||
enforcementLevel: z.nativeEnum(EnforcementLevel).default(EnforcementLevel.Hard),
|
enforcementLevel: z.nativeEnum(EnforcementLevel).default(EnforcementLevel.Hard),
|
||||||
@@ -85,13 +87,15 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
.min(1, { message: "At least one approver should be provided" }),
|
.min(1, { message: "At least one approver should be provided" })
|
||||||
|
.max(100, "Cannot have more than 100 approvers"),
|
||||||
bypassers: z
|
bypassers: z
|
||||||
.discriminatedUnion("type", [
|
.discriminatedUnion("type", [
|
||||||
z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
|
z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
|
||||||
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() })
|
||||||
])
|
])
|
||||||
.array()
|
.array()
|
||||||
|
.max(100, "Cannot have more than 100 bypassers")
|
||||||
.optional(),
|
.optional(),
|
||||||
approvals: z.number().min(1).default(1),
|
approvals: z.number().min(1).default(1),
|
||||||
secretPath: z
|
secretPath: z
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ export const accessApprovalRequestServiceFactory = ({
|
|||||||
|
|
||||||
const isApprover = policy.approvers.find((approver) => approver.userId === actorId);
|
const isApprover = policy.approvers.find((approver) => approver.userId === actorId);
|
||||||
|
|
||||||
|
// If user is (not an approver OR cant self approve) AND can't bypass policy
|
||||||
if ((!isApprover || (!policy.allowedSelfApprovals && isSelfApproval)) && cannotBypassUnderSoftEnforcement) {
|
if ((!isApprover || (!policy.allowedSelfApprovals && isSelfApproval)) && cannotBypassUnderSoftEnforcement) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: "Failed to review access approval request. Users are not authorized to review their own request."
|
message: "Failed to review access approval request. Users are not authorized to review their own request."
|
||||||
|
|||||||
Reference in New Issue
Block a user