-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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() | ||
}) | ||
|
||
}) |
c9247f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@decyjphr This commit is breaking safe settings. We are currently dealing with an issue where safe settings malfunction and updated repos on the enterprise which are not configured via safe settings.
I can talk more about the issue that we are facing.
c9247f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sorry for the trouble. Can you open an issue and if there is an example that I can use to recreate the tests it would be great. I made the change after all the tests passed but want to know about your use case.