warmachine028 / memories

A well refined project to store your valuable memories in a digital Diary
https://memories-pritam.vercel.app
MIT License
43 stars 36 forks source link

[BUG 🐞] Fix code scanning alert - Change user-controlled sources for GoogleSignIn #70

Closed warmachine028 closed 1 year ago

warmachine028 commented 1 year ago

Description

Tracking issue for:

Screenshots

Before:

export const googleSignin = async (req, res) => {
    const { name, email, image, googleId } = req.body

    try {
        const id = new mongoose.Types.ObjectId(googleId)
        const user = await User.findByIdAndUpdate(id, { name, email, image }, { upsert: true })
                ...

After:

export const googleSignin = async (req, res) => {
    const { name, email, image, googleId } = req.body

    try {
        if (![name, email, image].every((field) => typeof field === "string")) {
            return res.status(400).json({ status: "error" });
        }
        const user = await User.findByIdAndUpdate(googleId, { name, email, image }, { upsert: true })

Additional information

vibh1103 commented 1 year ago

Hi @warmachine028 can i pick this issue ?

warmachine028 commented 1 year ago

Sure, I'm assigning you

vibh1103 commented 1 year ago

Hi @warmachine028 https://github.com/warmachine028/memories/commit/7e348c0d8655deb1ade828a28fc6a4fe40e9d7c5 This change is made in this commit can you confirm me once what i have to do ?

warmachine028 commented 1 year ago

Seems like this Issue was already fixed by the Commit, wait I am creating another similar issue for another vulnerability, you can fix that.

warmachine028 commented 1 year ago

@vibh1103 please see #85