Switching to new security rules
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Fabian Stamm
2020-10-28 01:00:39 +01:00
parent b3465ea96d
commit 22cb90b6f6
18 changed files with 1094 additions and 301 deletions

36
src/rules/error.ts Normal file
View File

@ -0,0 +1,36 @@
export interface RuleError {
line: number;
column: number;
message: string;
original_err: Error;
}
function indexToLineAndCol(src: string, index: number) {
let line = 1;
let col = 1;
for (let i = 0; i < index; i++) {
if (src.charAt(i) === "\n") {
line++;
col = 1;
} else {
col++;
}
}
return { line, col };
}
export function transformError(
err: Error,
data: string,
idx: number
): RuleError {
let loc = indexToLineAndCol(data, idx);
return {
line: loc.line,
column: loc.col,
message: err.message,
original_err: err,
};
}