Skip to content

Commit

Permalink
fix: throw on elevated request with unknown collectionId (#1542)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matte22 authored Feb 26, 2025
1 parent bddadb7 commit 0b07300
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 63 deletions.
4 changes: 2 additions & 2 deletions api/source/controllers/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ module.exports.getAssetsByStig = async function getAssetsByStig (req, res, next)
const labelMatch = req.query.labelMatch
const projections = req.query.projection

const {collectionId, grant} = Collection.getCollectionInfoAndCheckPermission(req, Security.ROLES.Restricted)
const {collectionId, grant} = await Collection.getCollectionInfoAndCheckPermission(req, Security.ROLES.Restricted)
const response = await AssetService.getAssetsByStig({
collectionId,
benchmarkId,
Expand Down Expand Up @@ -309,7 +309,7 @@ module.exports.attachAssetsToStig = async function attachAssetsToStig (req, res,
let assetIds = req.body
let projections = req.query.projection

const { collectionId, grant } = Collection.getCollectionInfoAndCheckPermission(req, Security.ROLES.Manage)
const { collectionId, grant } = await Collection.getCollectionInfoAndCheckPermission(req, Security.ROLES.Manage)
let collection = await CollectionService.getCollection( collectionId, ['assets'], false, req.userObject)
let collectionAssets = collection.assets.map( a => a.assetId)
if (assetIds.every( a => collectionAssets.includes(a))) {
Expand Down
Loading

0 comments on commit 0b07300

Please sign in to comment.