@sasjs/lint
Version:
Linting and formatting for SAS code
33 lines • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.noEncodedPasswords = void 0;
const LintRuleType_1 = require("../../types/LintRuleType");
const Severity_1 = require("../../types/Severity");
const name = 'noEncodedPasswords';
const description = 'Disallow encoded passwords in SAS code.';
const message = 'Line contains encoded password';
const test = (value, lineNumber, config) => {
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Error;
const regex = new RegExp(/{sas(\d{2,4}|enc)}[^;"'\s]*/, 'gi');
const matches = value.match(regex);
if (!matches || !matches.length)
return [];
return matches.map((match) => ({
message,
lineNumber,
startColumnNumber: value.indexOf(match) + 1,
endColumnNumber: value.indexOf(match) + match.length + 1,
severity
}));
};
/**
* Lint rule that checks for the presence of encoded password(s) in a given line of text.
*/
exports.noEncodedPasswords = {
type: LintRuleType_1.LintRuleType.Line,
name,
description,
message,
test
};
//# sourceMappingURL=noEncodedPasswords.js.map