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'
|
'css'
|
||||||
];
|
];
|
||||||
|
|
||||||
const pathsWhiteList = ['challenges', 'map', 'commit'];
|
const pathsAllowedList = ['challenges', 'map', 'commit'];
|
||||||
|
|
||||||
const pathsOfNoReturnRegex = new RegExp(pathsOfNoReturn.join('|'), 'i');
|
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() {
|
export default function addReturnToUrl() {
|
||||||
return function(req, res, next) {
|
return function(req, res, next) {
|
||||||
@ -24,7 +24,7 @@ export default function addReturnToUrl() {
|
|||||||
if (
|
if (
|
||||||
req.method !== 'GET' ||
|
req.method !== 'GET' ||
|
||||||
pathsOfNoReturnRegex.test(path) ||
|
pathsOfNoReturnRegex.test(path) ||
|
||||||
!whiteListRegex.test(path) ||
|
!pathsAllowedRegex.test(path) ||
|
||||||
/hot/i.test(req.path)
|
/hot/i.test(req.path)
|
||||||
) {
|
) {
|
||||||
return next();
|
return next();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { homeLocation } from '../../../config/env';
|
import { homeLocation } from '../../../config/env';
|
||||||
import { whitelistOrigins } from '../../../config/cors-settings';
|
import { allowedOrigins } from '../../../config/cors-settings';
|
||||||
|
|
||||||
export default function constantHeaders() {
|
export default function constantHeaders() {
|
||||||
return function(req, res, next) {
|
return function(req, res, next) {
|
||||||
if (
|
if (
|
||||||
req.headers &&
|
req.headers &&
|
||||||
req.headers.origin &&
|
req.headers.origin &&
|
||||||
whitelistOrigins.includes(req.headers.origin)
|
allowedOrigins.includes(req.headers.origin)
|
||||||
) {
|
) {
|
||||||
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,7 +28,7 @@ const updateHooksRE = /^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/;
|
|||||||
// note: this would be replaced by webhooks later
|
// note: this would be replaced by webhooks later
|
||||||
const donateRE = /^\/donate\/charge-stripe$/;
|
const donateRE = /^\/donate\/charge-stripe$/;
|
||||||
|
|
||||||
const _whiteListREs = [
|
const _pathsAllowedREs = [
|
||||||
authRE,
|
authRE,
|
||||||
confirmEmailRE,
|
confirmEmailRE,
|
||||||
newsShortLinksRE,
|
newsShortLinksRE,
|
||||||
@ -44,14 +44,14 @@ const _whiteListREs = [
|
|||||||
donateRE
|
donateRE
|
||||||
];
|
];
|
||||||
|
|
||||||
export function isWhiteListedPath(path, whiteListREs = _whiteListREs) {
|
export function isAllowedPath(path, pathsAllowedREs = _pathsAllowedREs) {
|
||||||
return whiteListREs.some(re => re.test(path));
|
return pathsAllowedREs.some(re => re.test(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ({ jwtSecret = _jwtSecret, getUserById = _getUserById } = {}) =>
|
export default ({ jwtSecret = _jwtSecret, getUserById = _getUserById } = {}) =>
|
||||||
function requestAuthorisation(req, res, next) {
|
function requestAuthorisation(req, res, next) {
|
||||||
const { path } = req;
|
const { path } = req;
|
||||||
if (!isWhiteListedPath(path)) {
|
if (!isAllowedPath(path)) {
|
||||||
const { accessToken, error, jwt } = getAccessTokenFromRequest(
|
const { accessToken, error, jwt } = getAccessTokenFromRequest(
|
||||||
req,
|
req,
|
||||||
jwtSecret
|
jwtSecret
|
||||||
|
@ -4,7 +4,7 @@ import { mockReq, mockRes } from 'sinon-express-mock';
|
|||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
import createRequestAuthorization, {
|
import createRequestAuthorization, {
|
||||||
isWhiteListedPath
|
isAllowedPath
|
||||||
} from './request-authorization';
|
} from './request-authorization';
|
||||||
|
|
||||||
const validJWTSecret = 'this is a super secret string';
|
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');
|
id in users ? Promise.resolve(users[id]) : Promise.reject('No user found');
|
||||||
|
|
||||||
describe('request-authorization', () => {
|
describe('request-authorization', () => {
|
||||||
describe('isWhiteListedPath', () => {
|
describe('isAllowedPath', () => {
|
||||||
const authRE = /^\/auth\//;
|
const authRE = /^\/auth\//;
|
||||||
const confirmEmailRE = /^\/confirm-email$/;
|
const confirmEmailRE = /^\/confirm-email$/;
|
||||||
const newsShortLinksRE = /^\/n\/|^\/p\//;
|
const newsShortLinksRE = /^\/n\/|^\/p\//;
|
||||||
@ -42,7 +42,7 @@ describe('request-authorization', () => {
|
|||||||
const unsubscribeRE = /^\/u\/|^\/unsubscribe\/|^\/ue\//;
|
const unsubscribeRE = /^\/u\/|^\/unsubscribe\/|^\/ue\//;
|
||||||
const updateHooksRE = /^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/;
|
const updateHooksRE = /^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/;
|
||||||
|
|
||||||
const whiteList = [
|
const allowedPathsList = [
|
||||||
authRE,
|
authRE,
|
||||||
confirmEmailRE,
|
confirmEmailRE,
|
||||||
newsShortLinksRE,
|
newsShortLinksRE,
|
||||||
@ -58,18 +58,21 @@ describe('request-authorization', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
it('returns a boolean', () => {
|
it('returns a boolean', () => {
|
||||||
const result = isWhiteListedPath();
|
const result = isAllowedPath();
|
||||||
expect(typeof result).toBe('boolean');
|
expect(typeof result).toBe('boolean');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns true for a white listed path', () => {
|
it('returns true for a white listed path', () => {
|
||||||
const resultA = isWhiteListedPath(
|
const resultA = isAllowedPath(
|
||||||
'/auth/auth0/callback?code=yF_mGjswLsef-_RLo',
|
'/auth/auth0/callback?code=yF_mGjswLsef-_RLo',
|
||||||
whiteList
|
allowedPathsList
|
||||||
);
|
);
|
||||||
const resultB = isWhiteListedPath('/ue/WmjInLerysPrcon6fMb/', whiteList);
|
const resultB = isAllowedPath(
|
||||||
const resultC = isWhiteListedPath('/hooks/update-paypal', whiteList);
|
'/ue/WmjInLerysPrcon6fMb/',
|
||||||
const resultD = isWhiteListedPath('/hooks/update-stripe', whiteList);
|
allowedPathsList
|
||||||
|
);
|
||||||
|
const resultC = isAllowedPath('/hooks/update-paypal', allowedPathsList);
|
||||||
|
const resultD = isAllowedPath('/hooks/update-stripe', allowedPathsList);
|
||||||
expect(resultA).toBe(true);
|
expect(resultA).toBe(true);
|
||||||
expect(resultB).toBe(true);
|
expect(resultB).toBe(true);
|
||||||
expect(resultC).toBe(true);
|
expect(resultC).toBe(true);
|
||||||
@ -77,8 +80,11 @@ describe('request-authorization', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns false for a non-white-listed path', () => {
|
it('returns false for a non-white-listed path', () => {
|
||||||
const resultA = isWhiteListedPath('/hax0r-42/no-go', whiteList);
|
const resultA = isAllowedPath('/hax0r-42/no-go', allowedPathsList);
|
||||||
const resultB = isWhiteListedPath('/update-current-challenge', whiteList);
|
const resultB = isAllowedPath(
|
||||||
|
'/update-current-challenge',
|
||||||
|
allowedPathsList
|
||||||
|
);
|
||||||
expect(resultA).toBe(false);
|
expect(resultA).toBe(false);
|
||||||
expect(resultB).toBe(false);
|
expect(resultB).toBe(false);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
exports.whitelistOrigins = [
|
exports.allowedOrigins = [
|
||||||
'https://www.freecodecamp.dev',
|
'https://www.freecodecamp.dev',
|
||||||
'https://www.freecodecamp.org',
|
'https://www.freecodecamp.org',
|
||||||
'https://beta.freecodecamp.dev',
|
'https://beta.freecodecamp.dev',
|
||||||
|
@ -37,7 +37,7 @@ tests:
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -67,7 +67,7 @@ tests:
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -75,7 +75,7 @@ tests:
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -103,7 +103,7 @@ const resultDisplayArray = makeList(result.failure);
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -8,7 +8,7 @@ forumTopicId: 301585
|
|||||||
## Description
|
## Description
|
||||||
<section id='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>.
|
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.
|
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>
|
</section>
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
/**
|
/**
|
||||||
Backend challenges don't need solutions,
|
Backend challenges don't need solutions,
|
||||||
because they would need to be tested against a full working project.
|
because they would need to be tested against a full working project.
|
||||||
Please check our contributing guidelines to learn more.
|
Please check our contributing guidelines to learn more.
|
||||||
*/
|
*/
|
||||||
```
|
```
|
||||||
|
@ -37,7 +37,7 @@ tests:
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -43,7 +43,7 @@ tests:
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -75,7 +75,7 @@ const resultDisplayArray = makeList(result.failure);
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -37,7 +37,7 @@ tests:
|
|||||||
const result = {
|
const result = {
|
||||||
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
success: ["max-length", "no-amd", "prefer-arrow-functions"],
|
||||||
failure: ["no-var", "var-on-top", "linebreak"],
|
failure: ["no-var", "var-on-top", "linebreak"],
|
||||||
skipped: ["id-blacklist", "no-dup-keys"]
|
skipped: ["no-extra-semi", "no-dup-keys"]
|
||||||
};
|
};
|
||||||
function makeList(arr) {
|
function makeList(arr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -40,7 +40,7 @@ describe('isValidUsername', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('rejects all other ASCII characters', () => {
|
it('rejects all other ASCII characters', () => {
|
||||||
const whiteList = ['-', '_', '+'];
|
const allowedCharactersList = ['-', '_', '+'];
|
||||||
const numbers = [48, 57];
|
const numbers = [48, 57];
|
||||||
const upperCase = [65, 90];
|
const upperCase = [65, 90];
|
||||||
const lowerCase = [97, 122];
|
const lowerCase = [97, 122];
|
||||||
@ -50,7 +50,7 @@ describe('isValidUsername', () => {
|
|||||||
for (let code = 0; code <= finalCode; code++) {
|
for (let code = 0; code <= finalCode; code++) {
|
||||||
let char = String.fromCharCode(code);
|
let char = String.fromCharCode(code);
|
||||||
let expected = invalidCharError;
|
let expected = invalidCharError;
|
||||||
if (whiteList.includes(char)) expected = validationSuccess;
|
if (allowedCharactersList.includes(char)) expected = validationSuccess;
|
||||||
if (inRange(code, numbers)) expected = validationSuccess;
|
if (inRange(code, numbers)) expected = validationSuccess;
|
||||||
if (inRange(code, upperCase)) expected = validationSuccess;
|
if (inRange(code, upperCase)) expected = validationSuccess;
|
||||||
if (inRange(code, lowerCase)) expected = validationSuccess;
|
if (inRange(code, lowerCase)) expected = validationSuccess;
|
||||||
|
Reference in New Issue
Block a user