refactor: 💡 use allow-list in AppArch codebase (#71400)

This commit is contained in:
Vadim Dalecky 2020-07-13 01:53:31 -07:00 committed by GitHub
parent 79df8e01ad
commit 0c04d98206
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -30,7 +30,7 @@ import {
} from '../types';
const templateMatchRE = /{{([\s\S]+?)}}/g;
const whitelistUrlSchemes = ['http://', 'https://'];
const allowedUrlSchemes = ['http://', 'https://'];
const URL_TYPES = [
{
@ -161,7 +161,7 @@ export class UrlFormat extends FieldFormat {
return this.generateImgHtml(url, imageLabel);
default:
const inWhitelist = whitelistUrlSchemes.some((scheme) => url.indexOf(scheme) === 0);
const inWhitelist = allowedUrlSchemes.some((scheme) => url.indexOf(scheme) === 0);
if (!inWhitelist && !parsedUrl) {
return url;
}

View file

@ -116,7 +116,7 @@ describe('hash unhash url', () => {
expect(mockStorage.length).toBe(3);
});
it('hashes only whitelisted properties', () => {
it('hashes only allow-listed properties', () => {
const stateParamKey1 = '_g';
const stateParamValue1 = '(yes:!t)';
const stateParamKey2 = '_a';
@ -227,7 +227,7 @@ describe('hash unhash url', () => {
);
});
it('unhashes only whitelisted properties', () => {
it('un-hashes only allow-listed properties', () => {
const stateParamKey1 = '_g';
const stateParamValueHashed1 = 'h@4e60e02';
const state1 = { yes: true };

View file

@ -35,7 +35,7 @@ export const hashUrl = createQueryReplacer(hashQuery);
// naive hack, but this allows to decouple these utils from AppState, GlobalState for now
// when removing AppState, GlobalState and migrating to IState containers,
// need to make sure that apps explicitly passing this whitelist to hash
// need to make sure that apps explicitly passing this allow-list to hash
const __HACK_HARDCODED_LEGACY_HASHABLE_PARAMS = ['_g', '_a', '_s'];
function createQueryMapper(queryParamMapper: (q: string) => string | null) {
return (