Skip to content

Commit

Permalink
fix: select security bug (#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
awaismehmood88 authored Feb 27, 2024
1 parent c052d15 commit 6f47f0c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/paginate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,13 @@ export async function paginate<T extends ObjectLiteral>(

// When we partial select the columns (main or relation) we must add the primary key column otherwise
// typeorm will not be able to map the result.
const selectParams =
let selectParams =
config.select && query.select && !config.ignoreSelectInQueryParam
? config.select.filter((column) => query.select.includes(column))
: config.select
if (!includesAllPrimaryKeyColumns(queryBuilder, query.select)) {
selectParams = config.select
}
if (selectParams?.length > 0 && includesAllPrimaryKeyColumns(queryBuilder, selectParams)) {
const cols: string[] = selectParams.reduce((cols, currentCol) => {
const columnProperties = getPropertiesByColumnName(currentCol)
Expand Down

0 comments on commit 6f47f0c

Please # to comment.