1
0
mirror of https://github.com/sasjs/lint.git synced 2026-01-09 13:30:05 +00:00

chore(*): add support for SASENC passwords

This commit is contained in:
Krishna Acondy
2021-03-23 09:10:19 +00:00
parent fb541423ee
commit 022e18a13f
2 changed files with 12 additions and 1 deletions

View File

@@ -6,6 +6,17 @@ describe('noEncodedPasswords', () => {
expect(noEncodedPasswords.test(line, 1)).toEqual([])
})
it('should return an array with a single diagnostic when the line has a SASENC password', () => {
const line = "%put '{SASENC}'; "
expect(noEncodedPasswords.test(line, 1)).toEqual([
{
warning: 'Line contains encoded password',
lineNumber: 1,
columnNumber: 7
}
])
})
it('should return an array with a single diagnostic when the line has an encoded password', () => {
const line = "%put '{SAS001}'; "
expect(noEncodedPasswords.test(line, 1)).toEqual([

View File

@@ -5,7 +5,7 @@ const name = 'noEncodedPasswords'
const description = 'Disallow encoded passwords in SAS code.'
const warning = 'Line contains encoded password'
const test = (value: string, lineNumber: number) => {
const regex = new RegExp(/{sas\d{2,4}}[^;"'\s]*/, 'gi')
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) => ({