0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Replaced white/black list terminology

refs 92986b77e3

- I thought we did this a while ago, but uses in comments and elsewhere in the codebase were missed
This commit is contained in:
Hannah Wolfe 2022-04-19 11:01:19 +01:00
parent ad45773d70
commit 1d121c52f4
No known key found for this signature in database
GPG key ID: AB586C3B5AE5C037
14 changed files with 21 additions and 25 deletions

View file

@ -187,9 +187,8 @@ function ampContent() {
// Use cheerio to traverse through HTML and make little clean-ups // Use cheerio to traverse through HTML and make little clean-ups
$ = cheerio.load(ampHTML); $ = cheerio.load(ampHTML);
// We have to remove source children in video, as source // We have to remove source children in video, as source is allowed for audio,
// is whitelisted for audio, but causes validation // but causes validation errors in video, because video will be stripped out.
// errors in video, because video will be stripped out.
// @TODO: remove this, when Amperize support video transform // @TODO: remove this, when Amperize support video transform
$('video').children('source').remove(); $('video').children('source').remove();
$('video').children('track').remove(); $('video').children('track').remove();

View file

@ -4,18 +4,18 @@ const constants = require('@tryghost/constants');
const themeEngine = require('../../services/theme-engine'); const themeEngine = require('../../services/theme-engine');
const express = require('../../../shared/express'); const express = require('../../../shared/express');
function isBlackListedFileType(file) { function isDeniedFile(file) {
const blackListedFileTypes = ['.hbs', '.md', '.json']; const deniedFileTypes = ['.hbs', '.md', '.json'];
const ext = path.extname(file); const ext = path.extname(file);
return blackListedFileTypes.includes(ext); return deniedFileTypes.includes(ext);
} }
function isWhiteListedFile(file) { function isAllowedFile(file) {
const whiteListedFiles = ['manifest.json']; const allowedFiles = ['manifest.json'];
const base = path.basename(file); const base = path.basename(file);
return whiteListedFiles.includes(base); return allowedFiles.includes(base);
} }
function forwardToExpressStatic(req, res, next) { function forwardToExpressStatic(req, res, next) {
@ -31,8 +31,8 @@ function forwardToExpressStatic(req, res, next) {
} }
function staticTheme() { function staticTheme() {
return function blackListStatic(req, res, next) { return function denyStatic(req, res, next) {
if (!isWhiteListedFile(req.path) && isBlackListedFileType(req.path)) { if (!isAllowedFile(req.path) && isDeniedFile(req.path)) {
return next(); return next();
} }

View file

@ -80,9 +80,6 @@ class SettingsImporter extends BaseImporter {
}; };
} }
/**
* - 'core' and 'theme' are blacklisted
*/
beforeImport() { beforeImport() {
debug('beforeImport'); debug('beforeImport');

View file

@ -92,7 +92,7 @@ Label = ghostBookshelf.Model.extend({
permittedOptions: function permittedOptions(methodName) { permittedOptions: function permittedOptions(methodName) {
let options = ghostBookshelf.Model.permittedOptions.call(this, methodName); let options = ghostBookshelf.Model.permittedOptions.call(this, methodName);
// whitelists for the `options` hash argument on methods, by method name. // allowlists for the `options` hash argument on methods, by method name.
// these are the only options that can be passed to Bookshelf / Knex. // these are the only options that can be passed to Bookshelf / Knex.
const validOptions = { const validOptions = {
findAll: ['columns'], findAll: ['columns'],

View file

@ -1019,7 +1019,7 @@ Post = ghostBookshelf.Model.extend({
permittedOptions: function permittedOptions(methodName) { permittedOptions: function permittedOptions(methodName) {
let options = ghostBookshelf.Model.permittedOptions.call(this, methodName); let options = ghostBookshelf.Model.permittedOptions.call(this, methodName);
// whitelists for the `options` hash argument on methods, by method name. // allowlists for the `options` hash argument on methods, by method name.
// these are the only options that can be passed to Bookshelf / Knex. // these are the only options that can be passed to Bookshelf / Knex.
const validOptions = { const validOptions = {
findOne: ['columns', 'importing', 'withRelated', 'require', 'filter'], findOne: ['columns', 'importing', 'withRelated', 'require', 'filter'],

View file

@ -42,7 +42,7 @@ Role = ghostBookshelf.Model.extend({
permittedOptions: function permittedOptions(methodName) { permittedOptions: function permittedOptions(methodName) {
let options = ghostBookshelf.Model.permittedOptions.call(this, methodName); let options = ghostBookshelf.Model.permittedOptions.call(this, methodName);
// whitelists for the `options` hash argument on methods, by method name. // allowlists for the `options` hash argument on methods, by method name.
// these are the only options that can be passed to Bookshelf / Knex. // these are the only options that can be passed to Bookshelf / Knex.
const validOptions = { const validOptions = {
findOne: ['withRelated'], findOne: ['withRelated'],

View file

@ -163,7 +163,7 @@ Tag = ghostBookshelf.Model.extend({
permittedOptions: function permittedOptions(methodName) { permittedOptions: function permittedOptions(methodName) {
let options = ghostBookshelf.Model.permittedOptions.call(this, methodName); let options = ghostBookshelf.Model.permittedOptions.call(this, methodName);
// whitelists for the `options` hash argument on methods, by method name. // allowlists for the `options` hash argument on methods, by method name.
// these are the only options that can be passed to Bookshelf / Knex. // these are the only options that can be passed to Bookshelf / Knex.
const validOptions = { const validOptions = {
findAll: ['columns'], findAll: ['columns'],

View file

@ -392,7 +392,7 @@ User = ghostBookshelf.Model.extend({
permittedOptions: function permittedOptions(methodName, options) { permittedOptions: function permittedOptions(methodName, options) {
let permittedOptionsToReturn = ghostBookshelf.Model.permittedOptions.call(this, methodName); let permittedOptionsToReturn = ghostBookshelf.Model.permittedOptions.call(this, methodName);
// whitelists for the `options` hash argument on methods, by method name. // allowlists for the `options` hash argument on methods, by method name.
// these are the only options that can be passed to Bookshelf / Knex. // these are the only options that can be passed to Bookshelf / Knex.
const validOptions = { const validOptions = {
findOne: ['withRelated', 'status'], findOne: ['withRelated', 'status'],

View file

@ -72,7 +72,7 @@ function handleCORS(req, cb) {
return cb(null, DISABLE_CORS); return cb(null, DISABLE_CORS);
} }
// Origin matches whitelist // Origin matches allowlist
if (getAllowlist().indexOf(url.parse(origin).hostname) > -1) { if (getAllowlist().indexOf(url.parse(origin).hostname) > -1) {
return cb(null, ENABLE_CORS); return cb(null, ENABLE_CORS);
} }

View file

@ -3,7 +3,7 @@
* This has been misused - unsplash and slack are incorrectly stored there * This has been misused - unsplash and slack are incorrectly stored there
* https://github.com/TryGhost/Ghost/issues/10318 * https://github.com/TryGhost/Ghost/issues/10318
* *
* This file acts as a new whitelist for "public" settings * This file acts as an allowlist for "public" settings
*/ */
module.exports = { module.exports = {

View file

@ -6,7 +6,7 @@ const testUtils = require('../../utils');
* *
* If this test fails for you, you have modified the default settings. * If this test fails for you, you have modified the default settings.
* When you make a change or add new setting, please ensure that: * When you make a change or add new setting, please ensure that:
* - If a new `core` setting is added/removed/renamed, update the below whitelist * - If a new `core` setting is added/removed/renamed, update the allowlist below
* - If a new non-`core` setting is added, it includes corresponding migration to populate its `group` and `flags` * - If a new non-`core` setting is added, it includes corresponding migration to populate its `group` and `flags`
*/ */

View file

@ -107,7 +107,7 @@ describe('staticTheme', function () {
}); });
}); });
it('should NOT skip if file is on whitelist', function (done) { it('should NOT skip if file is allowed', function (done) {
req.path = 'manifest.json'; req.path = 'manifest.json';
staticTheme()(req, res, function next() { staticTheme()(req, res, function next() {

View file

@ -166,7 +166,7 @@ describe('Exporter', function () {
}); });
}); });
describe('Export table whitelists', function () { describe('Export table allowlists', function () {
it('should be fixed when db schema introduces new tables', function () { it('should be fixed when db schema introduces new tables', function () {
const { const {
BACKUP_TABLES, BACKUP_TABLES,

View file

@ -77,7 +77,7 @@ describe('cors', function () {
done(); done();
}); });
it('should not be enabled the if origin is not whitelisted', function (done) { it('should not be enabled the if origin is not allowed', function (done) {
const origin = 'http://not-trusted.com'; const origin = 'http://not-trusted.com';
req.get = sinon.stub().withArgs('origin').returns(origin); req.get = sinon.stub().withArgs('origin').returns(origin);