Skip to content

Commit

Permalink
Tried to fix possible prototype pollution reported by Deepcode.ai.
Browse files Browse the repository at this point in the history
Thanks to Deepcode.ai and xet7 !
  • Loading branch information
xet7 committed Jan 22, 2021
1 parent 0373da4 commit 8f55349
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions client/components/main/globalSearch.js
Expand Up @@ -247,44 +247,46 @@ BlazeComponent.extendComponent({
} else {
op = m.groups.abbrev;
}
if (op in operatorMap) {
let value = m.groups.value;
if (operatorMap[op] === 'labels') {
if (value in this.colorMap) {
value = this.colorMap[value];
}
} else if (
['dueAt', 'createdAt', 'modifiedAt'].includes(operatorMap[op])
) {
const days = parseInt(value, 10);
if (isNaN(days)) {
if (['day', 'week', 'month', 'quarter', 'year'].includes(value)) {
if (op !== "__proto__") {
if (op in operatorMap) {
let value = m.groups.value;
if (operatorMap[op] === 'labels') {
if (value in this.colorMap) {
value = this.colorMap[value];
}
} else if (
['dueAt', 'createdAt', 'modifiedAt'].includes(operatorMap[op])
) {
const days = parseInt(value, 10);
if (isNaN(days)) {
if (['day', 'week', 'month', 'quarter', 'year'].includes(value)) {
value = moment()
.subtract(1, value)
.format();
} else {
this.parsingErrors.push({
tag: 'operator-number-expected',
value: { operator: op, value },
});
value = null;
}
} else {
value = moment()
.subtract(1, value)
.subtract(days, 'days')
.format();
} else {
this.parsingErrors.push({
tag: 'operator-number-expected',
value: { operator: op, value },
});
value = null;
}
}
if (Array.isArray(params[operatorMap[op]])) {
params[operatorMap[op]].push(value);
} else {
value = moment()
.subtract(days, 'days')
.format();
params[operatorMap[op]] = value;
}
}
if (Array.isArray(params[operatorMap[op]])) {
params[operatorMap[op]].push(value);
} else {
params[operatorMap[op]] = value;
this.parsingErrors.push({
tag: 'operator-unknown-error',
value: op,
});
}
} else {
this.parsingErrors.push({
tag: 'operator-unknown-error',
value: op,
});
}
continue;
}
Expand Down

0 comments on commit 8f55349

Please sign in to comment.