fix(security): use server-configured PET notification recipient
This commit is contained in:
@@ -15,7 +15,6 @@ const allowedSubjects = [
|
||||
];
|
||||
|
||||
const allowedFields = new Set([
|
||||
"petEmail",
|
||||
"contactEmail",
|
||||
"contactSubject",
|
||||
"contactbody",
|
||||
@@ -120,22 +119,22 @@ export default async function ApiProxy(req, res) {
|
||||
);
|
||||
}
|
||||
|
||||
const petEmail = sanitizeString(requestBody.petEmail);
|
||||
const petEmail = sanitizeString(process.env.PETEMAIL);
|
||||
const contactEmail = sanitizeString(requestBody.contactEmail);
|
||||
const contactSubject = sanitizeString(requestBody.contactSubject);
|
||||
const contactBody = requestBody.contactbody;
|
||||
|
||||
if (
|
||||
typeof requestBody.petEmail !== "string" ||
|
||||
typeof process.env.PETEMAIL !== "string" ||
|
||||
!isNonEmptyString(petEmail) ||
|
||||
petEmail.length > 200 ||
|
||||
!emailRegex.test(petEmail)
|
||||
) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_PET_EMAIL",
|
||||
"petEmail must be a valid email address of 200 characters or fewer"
|
||||
);
|
||||
return respondError(res, {
|
||||
status: 500,
|
||||
code: "PET_RECIPIENT_NOT_CONFIGURED",
|
||||
message: "PET notification recipient is not configured"
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user