Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

searching by status is fixed. ToolID is next up #178

Merged
merged 1 commit into from
May 12, 2024

Conversation

DaveLuhman
Copy link
Owner

@DaveLuhman DaveLuhman commented May 12, 2024

This change is Reviewable

Copy link
Contributor

deepsource-io bot commented May 12, 2024

Here's the code health analysis summary for commits 97dd824..5340604. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript❌ Failure
❗ 6 occurences introduced
🎯 1 occurence resolved
View Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@DaveLuhman DaveLuhman merged commit 25530ab into master May 12, 2024
3 of 5 checks passed
Comment on lines +166 to +179
const {
serialNumber,
modelNumber,
barcode,
description,
toolID,
serviceAssignment,
category,
manufacturer,
width,
height,
length,
weight
},
updatedBy: req.user._id,
createdBy: req.user._id
})
if (!newTool) {
throw new Error({ message: 'Could not create tool', status: 500 })
}
await ToolHistory.create({
_id: newTool._id,
history: [newTool]
})
res.locals.message = 'Successfully Made A New Tool'
res.locals.tools = [newTool]
res.locals.pagination = { pageCount: 1 }
res.status(201)
console.info(`[MW] Tool Successfully Created ${newTool._id}`.green)
console.info('[MW] createTool-out-3'.bgWhite.blue)
next()
} catch (error) {
res.locals.message = error.message
res.status(error.status || 500).redirect('back')
}
}

async function updateToolHistory(toolID) {
const oldTool = await Tool.findById(toolID)
await ToolHistory.findByIdAndUpdate(
{ _id: toolID },
{
$push: { history: oldTool },
$inc: { __v: 1 },
$set: { updatedAt: Date.now() }
}
)
}

/**
*
* @param {*} req.body._id The id of the tool to update
* @param {*} res
* @param {*} next
*/
async function updateTool(req, res, next) {
console.info('[MW] updateTool-in'.bgBlue.white)
const ut = async (newToolData) => {
const {
id,
modelNumber,
description,
toolID,
serviceAssignment,
category,
manufacturer,
width,
height,
length,
weight
} = newToolData
updateToolHistory(id)
const updatedTool = await Tool.findByIdAndUpdate(
{ $eq: id },
{
} = req.body

Check failure

Code scanning / CodeQL

Type confusion through parameter tampering Critical

Potential type confusion as
this HTTP request parameter
may be either an array or a string.
Comment on lines +250 to +262
const {
id,
modelNumber,
description,
toolID,
serviceAssignment,
category,
manufacturer,
width,
height,
length,
weight
} = newToolData

Check failure

Code scanning / CodeQL

Type confusion through parameter tampering Critical

Potential type confusion as
this HTTP request parameter
may be either an array or a string.
}

async function updateToolHistory(toolID) {
const oldTool = await Tool.findById(toolID)

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
This query object depends on a
user-provided value
.
async function updateToolHistory(toolID) {
const oldTool = await Tool.findById(toolID)
await ToolHistory.findByIdAndUpdate(
{ _id: toolID },

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
This query object depends on a
user-provided value
.
} = newToolData
updateToolHistory(id)
const updatedTool = await Tool.findByIdAndUpdate(
{ $eq: id },

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
updateToolHistory(id[i])
newTools.push(
await Tool.findByIdAndUpdate(
{ _id: id[i] },

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
Comment on lines +417 to +421
{
serviceAssignment: newServiceAssignment[i],
$inc: { __v: 1 },
$set: { updatedAt: Date.now() }
},

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant