Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 246efb2

Browse files
committed
Avoid checking non-object fields for nin/in
1 parent 5a81506 commit 246efb2

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

service.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,21 @@ require('./migrate-psql-db.js')(function (err) {
137137
}
138138
// Loop over each props
139139
Object.values(args.q).forEach((value, key) => {
140-
const insecureProp = ['nin$', 'in$'];
141-
const detected = Object.keys(value).filter((val) => insecureProp.indexOf(val) > -1);
142-
if (detected.length > 0) {
143-
// Loop over each detected insecureProp being used (nin or in)
144-
detected.forEach((col, key) => {
145-
const ids = value[col];
146-
// Loop over each value of the array of the dangerous field
147-
ids.forEach((id) => {
148-
if (!/^[a-zA-Z0-9-]+$/g.test(id)) {
149-
throw new Error(`Unexpected characters in ${col}`);
150-
}
140+
if (_.isObject(value)) {
141+
const insecureProp = ['nin$', 'in$'];
142+
const detected = Object.keys(value).filter((val) => insecureProp.indexOf(val) > -1);
143+
if (detected.length > 0) {
144+
// Loop over each detected insecureProp being used (nin or in)
145+
detected.forEach((col, key) => {
146+
const ids = value[col];
147+
// Loop over each value of the array of the dangerous field
148+
ids.forEach((id) => {
149+
if (!/^[a-zA-Z0-9-]+$/g.test(id)) {
150+
throw new Error(`Unexpected characters in ${col}`);
151+
}
152+
});
151153
});
152-
});
154+
}
153155
}
154156
});
155157
this.prior(args, cb);

0 commit comments

Comments
 (0)