fix: negative sentiment → neutral language (#39522)
The existing terminology carries negative sentiment that can be interpreted in a racial or sense. Updating the name to have no potential for such a connection. Co-authored-by: Justin Rogers <justrog@gmail.com>
This commit is contained in:
committed by
GitHub
parent
b93785be5d
commit
c23c4ef8e4
@ -11,10 +11,10 @@ const pathsOfNoReturn = [
|
||||
'css'
|
||||
];
|
||||
|
||||
const pathsWhiteList = ['challenges', 'map', 'commit'];
|
||||
const pathsAllowedList = ['challenges', 'map', 'commit'];
|
||||
|
||||
const pathsOfNoReturnRegex = new RegExp(pathsOfNoReturn.join('|'), 'i');
|
||||
const whiteListRegex = new RegExp(pathsWhiteList.join('|'), 'i');
|
||||
const pathsAllowedRegex = new RegExp(pathsAllowedList.join('|'), 'i');
|
||||
|
||||
export default function addReturnToUrl() {
|
||||
return function(req, res, next) {
|
||||
@ -24,7 +24,7 @@ export default function addReturnToUrl() {
|
||||
if (
|
||||
req.method !== 'GET' ||
|
||||
pathsOfNoReturnRegex.test(path) ||
|
||||
!whiteListRegex.test(path) ||
|
||||
!pathsAllowedRegex.test(path) ||
|
||||
/hot/i.test(req.path)
|
||||
) {
|
||||
return next();
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { homeLocation } from '../../../config/env';
|
||||
import { whitelistOrigins } from '../../../config/cors-settings';
|
||||
import { allowedOrigins } from '../../../config/cors-settings';
|
||||
|
||||
export default function constantHeaders() {
|
||||
return function(req, res, next) {
|
||||
if (
|
||||
req.headers &&
|
||||
req.headers.origin &&
|
||||
whitelistOrigins.includes(req.headers.origin)
|
||||
allowedOrigins.includes(req.headers.origin)
|
||||
) {
|
||||
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
||||
} else {
|
||||
|
@ -28,7 +28,7 @@ const updateHooksRE = /^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/;
|
||||
// note: this would be replaced by webhooks later
|
||||
const donateRE = /^\/donate\/charge-stripe$/;
|
||||
|
||||
const _whiteListREs = [
|
||||
const _pathsAllowedREs = [
|
||||
authRE,
|
||||
confirmEmailRE,
|
||||
newsShortLinksRE,
|
||||
@ -44,14 +44,14 @@ const _whiteListREs = [
|
||||
donateRE
|
||||
];
|
||||
|
||||
export function isWhiteListedPath(path, whiteListREs = _whiteListREs) {
|
||||
return whiteListREs.some(re => re.test(path));
|
||||
export function isAllowedPath(path, pathsAllowedREs = _pathsAllowedREs) {
|
||||
return pathsAllowedREs.some(re => re.test(path));
|
||||
}
|
||||
|
||||
export default ({ jwtSecret = _jwtSecret, getUserById = _getUserById } = {}) =>
|
||||
function requestAuthorisation(req, res, next) {
|
||||
const { path } = req;
|
||||
if (!isWhiteListedPath(path)) {
|
||||
if (!isAllowedPath(path)) {
|
||||
const { accessToken, error, jwt } = getAccessTokenFromRequest(
|
||||
req,
|
||||
jwtSecret
|
||||
|
@ -4,7 +4,7 @@ import { mockReq, mockRes } from 'sinon-express-mock';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import createRequestAuthorization, {
|
||||
isWhiteListedPath
|
||||
isAllowedPath
|
||||
} from './request-authorization';
|
||||
|
||||
const validJWTSecret = 'this is a super secret string';
|
||||
@ -27,7 +27,7 @@ const mockGetUserById = id =>
|
||||
id in users ? Promise.resolve(users[id]) : Promise.reject('No user found');
|
||||
|
||||
describe('request-authorization', () => {
|
||||
describe('isWhiteListedPath', () => {
|
||||
describe('isAllowedPath', () => {
|
||||
const authRE = /^\/auth\//;
|
||||
const confirmEmailRE = /^\/confirm-email$/;
|
||||
const newsShortLinksRE = /^\/n\/|^\/p\//;
|
||||
@ -42,7 +42,7 @@ describe('request-authorization', () => {
|
||||
const unsubscribeRE = /^\/u\/|^\/unsubscribe\/|^\/ue\//;
|
||||
const updateHooksRE = /^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/;
|
||||
|
||||
const whiteList = [
|
||||
const allowedPathsList = [
|
||||
authRE,
|
||||
confirmEmailRE,
|
||||
newsShortLinksRE,
|
||||
@ -58,18 +58,21 @@ describe('request-authorization', () => {
|
||||
];
|
||||
|
||||
it('returns a boolean', () => {
|
||||
const result = isWhiteListedPath();
|
||||
const result = isAllowedPath();
|
||||
expect(typeof result).toBe('boolean');
|
||||
});
|
||||
|
||||
it('returns true for a white listed path', () => {
|
||||
const resultA = isWhiteListedPath(
|
||||
const resultA = isAllowedPath(
|
||||
'/auth/auth0/callback?code=yF_mGjswLsef-_RLo',
|
||||
whiteList
|
||||
allowedPathsList
|
||||
);
|
||||
const resultB = isWhiteListedPath('/ue/WmjInLerysPrcon6fMb/', whiteList);
|
||||
const resultC = isWhiteListedPath('/hooks/update-paypal', whiteList);
|
||||
const resultD = isWhiteListedPath('/hooks/update-stripe', whiteList);
|
||||
const resultB = isAllowedPath(
|
||||
'/ue/WmjInLerysPrcon6fMb/',
|
||||
allowedPathsList
|
||||
);
|
||||
const resultC = isAllowedPath('/hooks/update-paypal', allowedPathsList);
|
||||
const resultD = isAllowedPath('/hooks/update-stripe', allowedPathsList);
|
||||
expect(resultA).toBe(true);
|
||||
expect(resultB).toBe(true);
|
||||
expect(resultC).toBe(true);
|
||||
@ -77,8 +80,11 @@ describe('request-authorization', () => {
|
||||
});
|
||||
|
||||
it('returns false for a non-white-listed path', () => {
|
||||
const resultA = isWhiteListedPath('/hax0r-42/no-go', whiteList);
|
||||
const resultB = isWhiteListedPath('/update-current-challenge', whiteList);
|
||||
const resultA = isAllowedPath('/hax0r-42/no-go', allowedPathsList);
|
||||
const resultB = isAllowedPath(
|
||||
'/update-current-challenge',
|
||||
allowedPathsList
|
||||
);
|
||||
expect(resultA).toBe(false);
|
||||
expect(resultB).toBe(false);
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
exports.whitelistOrigins = [
|
||||
exports.allowedOrigins = [
|
||||
'https://www.freecodecamp.dev',
|
||||
'https://www.freecodecamp.org',
|
||||
'https://beta.freecodecamp.dev',
|
||||
|
@ -37,7 +37,7 @@ tests:
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
|
@ -67,7 +67,7 @@ tests:
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
|
@ -75,7 +75,7 @@ tests:
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
@ -103,7 +103,7 @@ const resultDisplayArray = makeList(result.failure);
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
|
@ -8,7 +8,7 @@ forumTopicId: 301585
|
||||
## Description
|
||||
<section id='description'>
|
||||
As a reminder, this project is being built upon the following starter project on <a href="https://repl.it/github/freeCodeCamp/boilerplate-infosec">Repl.it</a>, or cloned from <a href='https://github.com/freeCodeCamp/boilerplate-infosec/'>GitHub</a>.
|
||||
This challenge highlights one promising new defense that can significantly reduce the risk and impact of many type of attacks in modern browsers. By setting and configuring a Content Security Policy you can prevent the injection of anything unintended into your page. This will protect your app from XSS vulnerabilities, undesired tracking, malicious frames, and much more. CSP works by defining a whitelist of content sources which are trusted. You can configure them for each kind of resource a web page may need (scripts, stylesheets, fonts, frames, media, and so on…). There are multiple directives available, so a website owner can have a granular control. See HTML 5 Rocks, KeyCDN for more details. Unfortunately CSP is unsupported by older browser.
|
||||
This challenge highlights one promising new defense that can significantly reduce the risk and impact of many type of attacks in modern browsers. By setting and configuring a Content Security Policy you can prevent the injection of anything unintended into your page. This will protect your app from XSS vulnerabilities, undesired tracking, malicious frames, and much more. CSP works by defining an allowed list of content sources which are trusted. You can configure them for each kind of resource a web page may need (scripts, stylesheets, fonts, frames, media, and so on…). There are multiple directives available, so a website owner can have a granular control. See HTML 5 Rocks, KeyCDN for more details. Unfortunately CSP is unsupported by older browser.
|
||||
By default, directives are wide open, so it’s important to set the defaultSrc directive as a fallback. Helmet supports both defaultSrc and default-src naming styles. The fallback applies for most of the unspecified directives.
|
||||
</section>
|
||||
|
||||
|
@ -37,7 +37,7 @@ tests:
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
|
@ -43,7 +43,7 @@ tests:
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
@ -75,7 +75,7 @@ const resultDisplayArray = makeList(result.failure);
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
|
@ -37,7 +37,7 @@ tests:
|
||||
const result = {
|
||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||
failure: ["no-var", "var-on-top", "linebreak"],
|
||||
skipped: ["id-blacklist", "no-dup-keys"]
|
||||
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||
};
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
|
@ -40,7 +40,7 @@ describe('isValidUsername', () => {
|
||||
});
|
||||
|
||||
it('rejects all other ASCII characters', () => {
|
||||
const whiteList = ['-', '_', '+'];
|
||||
const allowedCharactersList = ['-', '_', '+'];
|
||||
const numbers = [48, 57];
|
||||
const upperCase = [65, 90];
|
||||
const lowerCase = [97, 122];
|
||||
@ -50,7 +50,7 @@ describe('isValidUsername', () => {
|
||||
for (let code = 0; code <= finalCode; code++) {
|
||||
let char = String.fromCharCode(code);
|
||||
let expected = invalidCharError;
|
||||
if (whiteList.includes(char)) expected = validationSuccess;
|
||||
if (allowedCharactersList.includes(char)) expected = validationSuccess;
|
||||
if (inRange(code, numbers)) expected = validationSuccess;
|
||||
if (inRange(code, upperCase)) expected = validationSuccess;
|
||||
if (inRange(code, lowerCase)) expected = validationSuccess;
|
||||
|
Reference in New Issue
Block a user