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

Commit d503806

Browse files
authored
Bugfix/ensure guid nin (#291)
* Ensure nin is used only with guid * Fix typo * Linting
1 parent 56d2e7f commit d503806

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

service.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ require('./migrate-psql-db.js')(function (err) {
127127
args.q.fields$[index] = '\"' + escape(field) + '\"';
128128
});
129129
}
130+
// Loop over each props
131+
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+
}
143+
});
144+
});
145+
}
146+
});
130147
this.prior(args, cb);
131148
} catch (err) {
132149
// cb to avoid seneca-transport to hang while waiting for timeout error

0 commit comments

Comments
 (0)