Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-1477 Wildcard/Regex Whitelisting #501

Merged
merged 8 commits into from Mar 3, 2020

Update tests for checking if a regex is safe

  • Loading branch information
benstrumeyer committed Feb 25, 2020
commit 359ed37958174854d5d9f4d04b205355d392799a
@@ -161,33 +161,21 @@ describe('app/panel/components/Settings/', () => {
const wrapper = shallow(<TrustAndRestrict />);

let input = '/^(\w+\s?)*$/';
let fn = jest.spyOn(wrapper.instance(), 'isSafe');
let fn = jest.spyOn(wrapper.instance(), 'isValidUrlWildcardOrRegex');
when(fn).calledWith(input);
let returnValue = wrapper.instance().isSafe(input);
let returnValue = wrapper.instance().isValidUrlWildcardOrRegex(input);
expect(returnValue).toBe(false);

input = '/^([0-9]+)*$/';
fn = jest.spyOn(wrapper.instance(), 'isSafe');
when(fn).calledWith(input);
returnValue = wrapper.instance().isSafe(input);
expect(returnValue).toBe(false);

input = '(?:.\s*)*?';
fn = jest.spyOn(wrapper.instance(), 'isSafe');
fn = jest.spyOn(wrapper.instance(), 'isValidUrlWildcardOrRegex');
when(fn).calledWith(input);
returnValue = wrapper.instance().isSafe(input);
returnValue = wrapper.instance().isValidUrlWildcardOrRegex(input);
expect(returnValue).toBe(false);

input = '(x\w{1,10})+y';
fn = jest.spyOn(wrapper.instance(), 'isSafe');
when(fn).calledWith(input);
returnValue = wrapper.instance().isSafe(input);
expect(returnValue).toBe(false);

input = '^((ab)*)+$';
fn = jest.spyOn(wrapper.instance(), 'isSafe');
fn = jest.spyOn(wrapper.instance(), 'isValidUrlWildcardOrRegex');
when(fn).calledWith(input);
returnValue = wrapper.instance().isSafe(input);
returnValue = wrapper.instance().isValidUrlWildcardOrRegex(input);
expect(returnValue).toBe(false);
});
});
ProTip! Use n and p to navigate between commits in a pull request.