mirror of
https://github.com/sasjs/lint.git
synced 2026-01-16 16:50:05 +00:00
chore(*): add support for SASENC passwords
This commit is contained in:
@@ -6,6 +6,17 @@ describe('noEncodedPasswords', () => {
|
|||||||
expect(noEncodedPasswords.test(line, 1)).toEqual([])
|
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', () => {
|
it('should return an array with a single diagnostic when the line has an encoded password', () => {
|
||||||
const line = "%put '{SAS001}'; "
|
const line = "%put '{SAS001}'; "
|
||||||
expect(noEncodedPasswords.test(line, 1)).toEqual([
|
expect(noEncodedPasswords.test(line, 1)).toEqual([
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const name = 'noEncodedPasswords'
|
|||||||
const description = 'Disallow encoded passwords in SAS code.'
|
const description = 'Disallow encoded passwords in SAS code.'
|
||||||
const warning = 'Line contains encoded password'
|
const warning = 'Line contains encoded password'
|
||||||
const test = (value: string, lineNumber: number) => {
|
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)
|
const matches = value.match(regex)
|
||||||
if (!matches || !matches.length) return []
|
if (!matches || !matches.length) return []
|
||||||
return matches.map((match) => ({
|
return matches.map((match) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user