Skip to content

Commit 57211c7

Browse files
mcfiredrillkiwiupover
authored andcommitted
replace term whitelist with allowlist
I followed the RFC from awhile back that has since been merged, so hopefully this can be changed here in ember-cli-fastboot as well.
1 parent 2a6ed5d commit 57211c7

File tree

11 files changed

+35
-35
lines changed

11 files changed

+35
-35
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ server.start();
9292

9393
## Using Node/npm Dependencies
9494

95-
### Whitelisting Packages
95+
### Allowlisting Packages
9696

9797
When your app is running in FastBoot, it may need to use Node packages
9898
to replace features that are available only in the browser.
9999

100100
For security reasons, your Ember app running in FastBoot can only access
101-
packages that you have explicitly whitelisted.
101+
packages that you have explicitly listed as allowed.
102102

103103
To allow your app to require a package, add it to the
104104
`fastbootDependencies` array in your app's `package.json`:
@@ -132,14 +132,14 @@ hash.** Built-in modules (`path`, `fs`, etc.) only need to be added to
132132

133133
From your Ember.js app, you can run `FastBoot.require()` to require a
134134
package. This is identical to the CommonJS `require` except it checks
135-
all requests against the whitelist first.
135+
all requests against the allowlist first.
136136

137137
```js
138138
let path = FastBoot.require('path');
139139
let filePath = path.join('tmp', session.getID());
140140
```
141141

142-
If you attempt to require a package that is not in the whitelist,
142+
If you attempt to require a package that is not in the allowlist,
143143
FastBoot will raise an exception.
144144

145145
Note that the `FastBoot` global is **only** available when running in
@@ -273,23 +273,23 @@ module.exports = function(environment) {
273273
},
274274

275275
fastboot: {
276-
hostWhitelist: ['example.com', 'subdomain.example.com', /^localhost:\d+$/]
276+
hostAllowlist: ['example.com', 'subdomain.example.com', /^localhost:\d+$/]
277277
}
278278
};
279279
// ...
280280
};
281281
```
282282

283-
The `hostWhitelist` can be a string or RegExp to match multiple hosts.
283+
The `hostAllowlist` can be a string or RegExp to match multiple hosts.
284284
Care should be taken when using a RegExp, as the host function relies on
285285
the `Host` HTTP header, which can be forged. You could potentially allow
286286
a malicious request if your RegExp is too permissive when using the `host`
287287
when making subsequent requests.
288288

289289
Retrieving `host` will error on 2 conditions:
290290

291-
1. you do not have a `hostWhitelist` defined
292-
2. the `Host` header does not match an entry in your `hostWhitelist`
291+
1. you do not have a `hostAllowlist` defined
292+
2. the `Host` header does not match an entry in your `hostAllowlist`
293293

294294
### Query Parameters
295295

packages/ember-cli-fastboot/fastboot/initializers/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var nodeAjax = function(options) {
1414
try {
1515
options.url = protocol + '//' + get(this, 'fastboot.request.host') + options.url;
1616
} catch (fbError) {
17-
throw new Error('You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostWhitelist property for in your environment.js. FastBoot Error: ' + fbError.message);
17+
throw new Error('You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostAllowlist property for in your environment.js. FastBoot Error: ' + fbError.message);
1818
}
1919
}
2020

packages/ember-cli-fastboot/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ module.exports = {
240240

241241
/**
242242
* Need to handroll our own clone algorithm since JSON.stringy changes regex
243-
* to empty objects which breaks hostWhiteList property of fastboot.
243+
* to empty objects which breaks hostAllowList property of fastboot.
244244
*
245245
* @param {Object} config
246246
*/

packages/ember-cli-fastboot/lib/broccoli/fastboot-config.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = class FastBootConfig extends Plugin {
5050
this.buildConfig();
5151
this.buildDependencies();
5252
this.buildManifest();
53-
this.buildHostWhitelist();
53+
this.buildHostAllowlist();
5454

5555
let outputPath = path.join(this.outputPath, 'package.json');
5656
this.writeFileIfContentChanged(outputPath, this.toJSONString());
@@ -85,7 +85,7 @@ module.exports = class FastBootConfig extends Plugin {
8585

8686
buildDependencies() {
8787
let dependencies = {};
88-
let moduleWhitelist = [];
88+
let moduleAllowlist = [];
8989
let ui = this.ui;
9090

9191
eachAddonPackage(this.project, pkg => {
@@ -101,7 +101,7 @@ module.exports = class FastBootConfig extends Plugin {
101101
return;
102102
}
103103

104-
moduleWhitelist.push(dep);
104+
moduleAllowlist.push(dep);
105105

106106
if (version) {
107107
dependencies[dep] = version;
@@ -115,7 +115,7 @@ module.exports = class FastBootConfig extends Plugin {
115115

116116
if (projectDeps) {
117117
projectDeps.forEach(dep => {
118-
moduleWhitelist.push(dep);
118+
moduleAllowlist.push(dep);
119119

120120
let version = pkg.dependencies && pkg.dependencies[dep];
121121
if (version) {
@@ -125,7 +125,7 @@ module.exports = class FastBootConfig extends Plugin {
125125
}
126126

127127
this.dependencies = dependencies;
128-
this.moduleWhitelist = uniq(moduleWhitelist);
128+
this.moduleAllowlist = uniq(moduleAllowlist);
129129
}
130130

131131
updateFastBootManifest(manifest) {
@@ -160,32 +160,32 @@ module.exports = class FastBootConfig extends Plugin {
160160
this.manifest = this.updateFastBootManifest(manifest);
161161
}
162162

163-
buildHostWhitelist() {
163+
buildHostAllowlist() {
164164
if (this.fastbootAppConfig) {
165-
this.hostWhitelist = this.fastbootAppConfig.hostWhitelist;
165+
this.hostAllowlist = this.fastbootAppConfig.hostAllowlist;
166166
}
167167
}
168168

169169
toJSONString() {
170170
return stringify({
171171
dependencies: this.dependencies,
172172
fastboot: {
173-
moduleWhitelist: this.moduleWhitelist,
173+
moduleAllowlist: this.moduleAllowlist,
174174
schemaVersion: LATEST_SCHEMA_VERSION,
175175
manifest: this.manifest,
176-
hostWhitelist: this.normalizeHostWhitelist(),
176+
hostAllowlist: this.normalizeHostAllowlist(),
177177
config: this.fastbootConfig,
178178
appName: this.appName,
179179
}
180180
}, null, 2);
181181
}
182182

183-
normalizeHostWhitelist() {
184-
if (!this.hostWhitelist) {
183+
normalizeHostAllowlist() {
184+
if (!this.hostAllowlist) {
185185
return;
186186
}
187187

188-
return this.hostWhitelist.map(function(entry) {
188+
return this.hostAllowlist.map(function(entry) {
189189
// Is a regex
190190
if (entry.source) {
191191
return '/' + entry.source + '/';

packages/ember-cli-fastboot/test/fixtures/fastboot-config/config/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = function(environment) {
1919
},
2020

2121
fastboot: {
22-
hostWhitelist: ['example.com', 'subdomain.example.com', /localhost:\d+/]
22+
hostAllowlist: ['example.com', 'subdomain.example.com', /localhost:\d+/]
2323
}
2424
};
2525

packages/ember-cli-fastboot/test/fixtures/fastboot-location-config/config/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function(environment) {
88
modulePrefix: 'fastboot-location-config',
99
fastboot: {
1010
fastbootHeaders: false,
11-
hostWhitelist: [/localhost:\d+/],
11+
hostAllowlist: [/localhost:\d+/],
1212
redirectCode: 302,
1313
}
1414
};

packages/ember-cli-fastboot/test/fixtures/fastboot-location/config/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function(environment) {
88
modulePrefix: 'fastboot-location',
99
fastboot: {
1010
fastbootHeaders: true,
11-
hostWhitelist: [/localhost:\d+/]
11+
hostAllowlist: [/localhost:\d+/]
1212
}
1313
};
1414

packages/ember-cli-fastboot/test/fixtures/request/config/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = function(environment) {
1919
},
2020

2121
fastboot: {
22-
hostWhitelist: ['example.com', 'subdomain.example.com', /localhost:\d+/]
22+
hostAllowlist: ['example.com', 'subdomain.example.com', /localhost:\d+/]
2323
}
2424
};
2525

packages/ember-cli-fastboot/test/new-package-json-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('FastbootConfig', function() {
5353
expect(
5454
output.read()
5555
).to.deep.equal({
56-
'package.json': `{"dependencies":{},"fastboot":{"appName":"app","config":{"app":{"modulePrefix":"app"}},"manifest":{"appFiles":["app.js","app-fastboot.js"],"htmlFile":"index.html","vendorFiles":["vendor.js"]},"moduleWhitelist":[],"schemaVersion":3}}`
56+
'package.json': `{"dependencies":{},"fastboot":{"appName":"app","config":{"app":{"modulePrefix":"app"}},"manifest":{"appFiles":["app.js","app-fastboot.js"],"htmlFile":"index.html","vendorFiles":["vendor.js"]},"moduleAllowlist":[],"schemaVersion":3}}`
5757
});
5858

5959
yield output.build();
@@ -84,7 +84,7 @@ describe('FastbootConfig', function() {
8484
expect(
8585
output.read()
8686
).to.deep.equal({
87-
'package.json': `{"dependencies":{"apple":"*","orange":"^1.0.0"},"fastboot":{"appName":"app","config":{"app":{"modulePrefix":"app"}},"manifest":{"appFiles":["app.js","app-fastboot.js"],"htmlFile":"index.html","vendorFiles":["vendor.js"]},"moduleWhitelist":["apple","orange"],"schemaVersion":3}}`
87+
'package.json': `{"dependencies":{"apple":"*","orange":"^1.0.0"},"fastboot":{"appName":"app","config":{"app":{"modulePrefix":"app"}},"manifest":{"appFiles":["app.js","app-fastboot.js"],"htmlFile":"index.html","vendorFiles":["vendor.js"]},"moduleAllowlist":["apple","orange"],"schemaVersion":3}}`
8888
});
8989

9090
project.pkg.fastbootDependencies = [
@@ -107,7 +107,7 @@ describe('FastbootConfig', function() {
107107
expect(
108108
output.read()
109109
).to.deep.equal({
110-
'package.json': `{"dependencies":{"apple":"^3.0.0","orange":"^1.0.0"},"fastboot":{"appName":"app","config":{"app":{"modulePrefix":"app"}},"manifest":{"appFiles":["app.js","app-fastboot.js"],"htmlFile":"index.html","vendorFiles":["vendor.js"]},"moduleWhitelist":["apple","orange"],"schemaVersion":3}}`
110+
'package.json': `{"dependencies":{"apple":"^3.0.0","orange":"^1.0.0"},"fastboot":{"appName":"app","config":{"app":{"modulePrefix":"app"}},"manifest":{"appFiles":["app.js","app-fastboot.js"],"htmlFile":"index.html","vendorFiles":["vendor.js"]},"moduleAllowlist":["apple","orange"],"schemaVersion":3}}`
111111
});
112112
}));
113113
});

test-packages/basic-app/config/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function(environment) {
2323
},
2424

2525
fastboot: {
26-
hostWhitelist: [
26+
hostAllowlist: [
2727
'example.com',
2828
'subdomain.example.com',
2929
'/localhost:\\d+/',

0 commit comments

Comments
 (0)