mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 17:27:16 +00:00
Move booleanSchema to sanitizedSchema
This commit is contained in:
@@ -70,6 +70,19 @@ export const DefaultResponseErrorsSchema = {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const booleanSchema = z
|
||||||
|
.union([z.boolean(), z.string().trim()])
|
||||||
|
.transform((value) => {
|
||||||
|
if (typeof value === "string") {
|
||||||
|
// ie if not empty, 0 or false, return true
|
||||||
|
return Boolean(value) && Number(value) !== 0 && value.toLowerCase() !== "false";
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
})
|
||||||
|
.optional()
|
||||||
|
.default(false);
|
||||||
|
|
||||||
export const sapPubSchema = SecretApprovalPoliciesSchema.merge(
|
export const sapPubSchema = SecretApprovalPoliciesSchema.merge(
|
||||||
z.object({
|
z.object({
|
||||||
environment: z.object({
|
environment: z.object({
|
||||||
|
|||||||
@@ -16,7 +16,12 @@ import { secretsLimit } from "@app/server/config/rateLimiter";
|
|||||||
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
|
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
|
||||||
import { getUserAgentType } from "@app/server/plugins/audit-log";
|
import { getUserAgentType } from "@app/server/plugins/audit-log";
|
||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { SanitizedDynamicSecretSchema, SanitizedTagSchema, secretRawSchema } from "@app/server/routes/sanitizedSchemas";
|
import {
|
||||||
|
booleanSchema,
|
||||||
|
SanitizedDynamicSecretSchema,
|
||||||
|
SanitizedTagSchema,
|
||||||
|
secretRawSchema
|
||||||
|
} from "@app/server/routes/sanitizedSchemas";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
import { ResourceMetadataSchema } from "@app/services/resource-metadata/resource-metadata-schema";
|
import { ResourceMetadataSchema } from "@app/services/resource-metadata/resource-metadata-schema";
|
||||||
import { SecretsOrderBy } from "@app/services/secret/secret-types";
|
import { SecretsOrderBy } from "@app/services/secret/secret-types";
|
||||||
@@ -24,20 +29,6 @@ import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
|
|||||||
|
|
||||||
const MAX_DEEP_SEARCH_LIMIT = 500; // arbitrary limit to prevent excessive results
|
const MAX_DEEP_SEARCH_LIMIT = 500; // arbitrary limit to prevent excessive results
|
||||||
|
|
||||||
// handle querystring boolean values
|
|
||||||
const booleanSchema = z
|
|
||||||
.union([z.boolean(), z.string().trim()])
|
|
||||||
.transform((value) => {
|
|
||||||
if (typeof value === "string") {
|
|
||||||
// ie if not empty, 0 or false, return true
|
|
||||||
return Boolean(value) && Number(value) !== 0 && value.toLowerCase() !== "false";
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
})
|
|
||||||
.optional()
|
|
||||||
.default(true);
|
|
||||||
|
|
||||||
const parseSecretPathSearch = (search?: string) => {
|
const parseSecretPathSearch = (search?: string) => {
|
||||||
if (!search)
|
if (!search)
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -9,18 +9,7 @@ import { readLimit, secretsLimit } from "@app/server/config/rateLimiter";
|
|||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
const booleanSchema = z
|
import { booleanSchema } from "../sanitizedSchemas";
|
||||||
.union([z.boolean(), z.string().trim()])
|
|
||||||
.transform((value) => {
|
|
||||||
if (typeof value === "string") {
|
|
||||||
// ie if not empty, 0 or false, return true
|
|
||||||
return Boolean(value) && Number(value) !== 0 && value.toLowerCase() !== "false";
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
})
|
|
||||||
.optional()
|
|
||||||
.default(false);
|
|
||||||
|
|
||||||
export const registerSecretFolderRouter = async (server: FastifyZodProvider) => {
|
export const registerSecretFolderRouter = async (server: FastifyZodProvider) => {
|
||||||
server.route({
|
server.route({
|
||||||
|
|||||||
Reference in New Issue
Block a user