forked from github/safe-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix code scanning alerts (github#669)
* fix alerts * fix alerts * fix alerts * fix alerts * add tests and simplify Glob * fix import to lowercase file * removed debugging code
- Loading branch information
Showing
4 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const Glob = require('../../../lib/glob') | ||
|
||
describe('glob test', function () { | ||
|
||
test('Test Glob **', () => { | ||
let pattern = new Glob('**/xss') | ||
let str = 'test/web/xss' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = 'test/web/xsssss' | ||
expect(str.search(pattern)>=0).toBeFalsy() | ||
|
||
pattern = new Glob('**/*.txt') | ||
str = 'sub/3.txt' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = '/sub1/sub2/sub3/3.txt' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
|
||
pattern = new Glob('**/csrf-protection-disabled') | ||
str = 'java/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = '/java/test/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
}) | ||
|
||
test('Test Glob *', () => { | ||
let str = 'web/xss' | ||
let pattern = new Glob('*/xss') | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
|
||
pattern = new Glob('./[0-9].*') | ||
str = './1.gif' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = './2.gif' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = './2.' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
|
||
pattern = new Glob('*/csrf-protection-disabled') | ||
str = 'java/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = 'rb/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
|
||
pattern = new Glob('*/hardcoded-credential*') | ||
str = 'java/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeFalsy() | ||
str = 'rb/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeFalsy() | ||
str = 'cs/hardcoded-credentials' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = 'java/hardcoded-credential-api-call' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
|
||
}) | ||
|
||
test('Test Glob no *', () => { | ||
let pattern = new Glob('csrf-protection-disabled') | ||
let str = 'java/hardcoded-credential-api-call' | ||
expect(str.search(pattern)>=0).toBeFalsy() | ||
str = 'cs/test/hardcoded-credentials' | ||
expect(str.search(pattern)>=0).toBeFalsy() | ||
str = 'rb/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = 'java/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
|
||
pattern = new Glob('csrf') | ||
str = 'java/hardcoded-credential-api-call' | ||
expect(str.search(pattern)>=0).toBeFalsy() | ||
str = 'cs/test/hardcoded-credentials' | ||
expect(str.search(pattern)>=0).toBeFalsy() | ||
str = 'rb/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
str = 'java/csrf-protection-disabled' | ||
expect(str.search(pattern)>=0).toBeTruthy() | ||
}) | ||
|
||
}) |