forked from FoundKeyGang/FoundKey
server: Add recursion limit to resolver
Changelog: Security
This commit is contained in:
parent
97288cb75f
commit
d3af00a912
1 changed files with 6 additions and 2 deletions
|
@ -19,9 +19,11 @@ import { parseUri } from './db-resolver.js';
|
|||
export default class Resolver {
|
||||
private history: Set<string>;
|
||||
private user?: ILocalUser;
|
||||
private recursionLimit?: number;
|
||||
|
||||
constructor() {
|
||||
constructor(recursionLimit = 100) {
|
||||
this.history = new Set();
|
||||
this.recursionLimit = recursionLimit;
|
||||
}
|
||||
|
||||
public getHistory(): string[] {
|
||||
|
@ -59,7 +61,9 @@ export default class Resolver {
|
|||
if (this.history.has(value)) {
|
||||
throw new Error('cannot resolve already resolved one');
|
||||
}
|
||||
|
||||
if (this.recursionLimit && this.history.size > this.recursionLimit) {
|
||||
throw new Error('hit recursion limit');
|
||||
}
|
||||
this.history.add(value);
|
||||
|
||||
const host = extractDbHost(value);
|
||||
|
|
Loading…
Reference in a new issue