-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat(experimental): kick off inventory project #808
base: main
Are you sure you want to change the base?
Conversation
Track projects and their licenses Docker compose configuration for dev with logging tracing and metrics (mostly done) CRUD for mongo
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
router.post('/create', async (req, res) => { | ||
const { error, data } = await createSchema.safeParseAsync(req); | ||
if (error) { | ||
req.log.error(error); | ||
res.status(500).json({ error: 'invalid format' }).end(); | ||
return; | ||
} | ||
const { body: submittedLicense } = data; | ||
if (submittedLicense.spdxID) { | ||
const spdxMatch = await License.findOne({ spdxID: data.body.spdxID }).exec(); | ||
// already exists | ||
if (spdxMatch !== null) { | ||
res.status(500).json({ error: 'license with SPDX ID already exists' }).end(); | ||
return; | ||
} | ||
} | ||
const _id = uuidv4(); | ||
await License.create({ | ||
_id, | ||
...submittedLicense, | ||
}); | ||
res.status(200).json({ created: _id }).end(); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a database access
router.get('/read/:id', async (req, res) => { | ||
const { error, data } = await readSchema.safeParseAsync(req); | ||
if (error) { | ||
req.log.error(error); | ||
res.status(500).json({ error: 'invalid format' }).end(); | ||
return; | ||
} | ||
const { | ||
params: { id }, | ||
} = data; | ||
const license = await License.findOne({ _id: id }).lean().exec(); | ||
res.status(200).json({ license }).end(); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a database access
router.patch('/update/:id', async (req, res) => { | ||
const { error, data } = await updateSchema.safeParseAsync(req); | ||
if (error) { | ||
req.log.error(error); | ||
res.status(500).json({ error: 'invalid format' }).end(); | ||
return; | ||
} | ||
const { | ||
body: updateLicense, | ||
params: { id }, | ||
} = data; | ||
await License.findOneAndUpdate({ _id: id }, updateLicense); | ||
res.setHeader('Content-Location', `/api/v0/licenses/read/{id}`); | ||
res.status(204).json({ status: 'ok' }).end(); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a database access
router.post('/delete/:id', async (req, res) => { | ||
const { error, data } = await deleteSchema.safeParseAsync(req); | ||
if (error) { | ||
req.log.error(error); | ||
res.status(500).json({ error: 'invalid format' }).end(); | ||
return; | ||
} | ||
const { | ||
params: { id }, | ||
} = data; | ||
await License.deleteOne({ _id: id }).exec(); | ||
res.status(204).json({ status: 'ok' }).end(); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a database access
router.get('/list', async (req, res) => { | ||
req.log.info('root'); | ||
// lean forces raw objects, not UUID buffers | ||
const result = await License.find().lean(true).exec(); | ||
res.status(200).json(result).end(); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a database access
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #808 +/- ##
=======================================
Coverage 63.11% 63.11%
=======================================
Files 47 47
Lines 1681 1681
=======================================
Hits 1061 1061
Misses 620 620 ☔ View full report in Codecov by Sentry. |
Track projects and their licenses
Docker compose configuration for dev with logging tracing and metrics (mostly done)
CRUD for mongo