-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What if checking for changes was easy?
Rationale
- Quick feedback loop while iterating and adding/fixing stuff.
- Easy to test with stats generated after diff.
- Currently these tangible statistics are still a work in progress
...
==> No callback hell detected. Code looks good!
==> Code NOT vulnerable to Brute force Attack
- ==> NO RegExp object detected with ReDoS-prone patterns
+ ==> Following dangerous function detected:
+ > RegExp detected at line: 1 Ensure: Regular expression to match only letters
+ =====> Ignore above errors if you already made changes to your code <=====
==> Code has proper input validation
==> No dangerous function detected
==> NO Insecure Authentication detected
- ==> No Insecure Security Headers found
+ ==> NO Insecure Security Headers found
...Future improvements
- While in development, strip directory path that is logged for each TestFolder file, as they vary depending on the machine.
- For example,
/home/user/project/NodejsSecurify/TestFolder/foobar.js->/TestFolder/foobar.js
- For example,
References
A WIP commit is linked here and the code provided below.
Edit: Hope it helps the project if it's useful.
View code
export function diffLogs(a: string, b: string): Map<number, [string, string]> {
const changedObjects: Change[] = diffLines(a, b);
const stats = new Map<number, [string, string]>();
changedObjects.forEach((part: Change) => {
let prefix = part.added ? "+" : part.removed ? "-" : " ";
prefix += " "; // add inline-start padding
if (!IS_PREFIX_ENABLE) {
prefix = "";
}
// Highlighted changed line parts.
const lines = part.value.split("\n");
blk: for (let i = 0, n = lines.length; i < n; i++) {
const line = lines[i];
const lineno = i + 1; //> Ln 1, Col 1
const isLastEmptyLine = line === "" && i === n - 1;
if (isLastEmptyLine) continue blk;
const changeKind = part.added ? "added" : part.removed ? "removed" : "none";
// if (changeKind === "none" && !(!part.added && !part.removed)) throw new Error("oops");
stats.set(lineno, [changeKind as string, line]);
const removedChange: string = part.removed ? colors.bgRed(prefix + line) : prefix + line;
const addedChange: string = colors.bgGreen(prefix + line);
const data = part.added ? addedChange : removedChange;
const isFlushOrQueued = process.stderr.write(`${data}\n`, "utf-8");
if (!isFlushOrQueued) console.warn("Failed to write to stderr.");
}
});
return stats;
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request