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

Commit df0a8e7

Browse files
committed
Avoid checking non-object fields for nin/in
1 parent d503806 commit df0a8e7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

service.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,21 @@ require('./migrate-psql-db.js')(function (err) {
129129
}
130130
// Loop over each props
131131
Object.values(args.q).forEach((value, key) => {
132-
const insecureProp = ['nin$', 'in$'];
133-
const detected = Object.keys(value).filter((val) => insecureProp.indexOf(val) > -1);
134-
if (detected.length > 0) {
135-
// Loop over each detected insecureProp being used (nin or in)
136-
detected.forEach((col, key) => {
137-
const ids = value[col];
138-
// Loop over each value of the array of the dangerous field
139-
ids.forEach((id) => {
140-
if (!/^[a-zA-Z0-9-]+$/g.test(id)) {
141-
throw new Error(`Unexpected characters in ${col}`);
142-
}
132+
if (_.isObject(value)) {
133+
const insecureProp = ['nin$', 'in$'];
134+
const detected = Object.keys(value).filter((val) => insecureProp.indexOf(val) > -1);
135+
if (detected.length > 0) {
136+
// Loop over each detected insecureProp being used (nin or in)
137+
detected.forEach((col, key) => {
138+
const ids = value[col];
139+
// Loop over each value of the array of the dangerous field
140+
ids.forEach((id) => {
141+
if (!/^[a-zA-Z0-9-]+$/g.test(id)) {
142+
throw new Error(`Unexpected characters in ${col}`);
143+
}
144+
});
143145
});
144-
});
146+
}
145147
}
146148
});
147149
this.prior(args, cb);

0 commit comments

Comments
 (0)