Skip to content

Commit 4d4dd79

Browse files
authored
Neutral-naming in reporting plugin (#77371) (#77406)
* refactor: πŸ’‘ remove "blacklist" reference in reporting plugin * refactor: πŸ’‘ remove "whitelist" in reporting plugin * fix: πŸ› correctly import function after refactor * refactor: πŸ’‘ use "blocked" instead of "denied" terminology
1 parent d8a0688 commit 4d4dd79

File tree

9 files changed

+32
-32
lines changed

9 files changed

+32
-32
lines changed

β€Žx-pack/plugins/reporting/common/constants.tsβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const CSV_REPORTING_ACTION = 'downloadCsvReport';
2323
export const CSV_BOM_CHARS = '\ufeff';
2424
export const CSV_FORMULA_CHARS = ['=', '+', '-', '@'];
2525

26-
export const WHITELISTED_JOB_CONTENT_TYPES = [
26+
export const ALLOWED_JOB_CONTENT_TYPES = [
2727
'application/json',
2828
'application/pdf',
2929
CONTENT_TYPE_CSV,
@@ -34,7 +34,7 @@ export const WHITELISTED_JOB_CONTENT_TYPES = [
3434
// See:
3535
// https://github.com/chromium/chromium/blob/3611052c055897e5ebbc5b73ea295092e0c20141/services/network/public/cpp/header_util_unittest.cc#L50
3636
// For a list of headers that chromium doesn't like
37-
export const KBN_SCREENSHOT_HEADER_BLACKLIST = [
37+
export const KBN_SCREENSHOT_HEADER_BLOCK_LIST = [
3838
'accept-encoding',
3939
'connection',
4040
'content-length',
@@ -51,7 +51,7 @@ export const KBN_SCREENSHOT_HEADER_BLACKLIST = [
5151
'keep-alive',
5252
];
5353

54-
export const KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN = ['proxy-'];
54+
export const KBN_SCREENSHOT_HEADER_BLOCK_LIST_STARTS_WITH_PATTERN = ['proxy-'];
5555

5656
export const UI_SETTINGS_CUSTOM_PDF_LOGO = 'xpackReporting:customPdfLogo';
5757

β€Žx-pack/plugins/reporting/server/browsers/network_policy.test.tsβ€Ž

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,36 @@ describe('Network Policy', () => {
109109
expect(allowRequest(url, rules)).toEqual(false);
110110
});
111111

112-
it('allows requests when hosts are whitelisted IP addresses', () => {
112+
it('allows requests when hosts are allowed IP addresses', () => {
113113
const url = 'http://192.168.1.1/cool/route/bro';
114114
const rules = [{ allow: true, host: '192.168.1.1' }, { allow: false }];
115115

116116
expect(allowRequest(url, rules)).toEqual(true);
117117
});
118118

119-
it('denies requests when hosts are blacklisted IP addresses', () => {
119+
it('denies requests when hosts are from blocked IP addresses', () => {
120120
const url = 'http://192.168.1.1/cool/route/bro';
121121
const rules = [{ allow: false, host: '192.168.1.1' }, { allow: true }];
122122

123123
expect(allowRequest(url, rules)).toEqual(false);
124124
});
125125

126-
it('allows requests when hosts are IP addresses not blacklisted', () => {
126+
it('allows requests when hosts are IP addresses that are not blocked', () => {
127127
const url = 'http://192.168.2.1/cool/route/bro';
128128
const rules = [{ allow: false, host: '192.168.1.1' }, { allow: true }];
129129

130130
expect(allowRequest(url, rules)).toEqual(true);
131131
});
132132

133-
it('denies requests when hosts are IP addresses not whitelisted', () => {
133+
it('denies requests when hosts are IP addresses not explicitly allowed', () => {
134134
const url = 'http://192.168.2.1/cool/route/bro';
135135
const rules = [{ allow: true, host: '192.168.1.1' }, { allow: false }];
136136

137137
expect(allowRequest(url, rules)).toEqual(false);
138138
});
139139

140140
describe('Common cases', () => {
141-
it('allows whitelisting of certain routes based upon protocol', () => {
141+
it('allows certain routes based upon protocol', () => {
142142
const rules = [
143143
{ allow: true, host: 'kibana.com', protocol: 'http:' },
144144
{ allow: true, protocol: 'https:' },
@@ -150,39 +150,39 @@ describe('Network Policy', () => {
150150
expect(allowRequest('http://bad.com/some/route', rules)).toEqual(false);
151151
});
152152

153-
it('allows blacklisting of certain IPs', () => {
153+
it('allows blocking of certain IPs', () => {
154154
const rules = [{ allow: false, host: '169.254.0.0' }, { allow: true }];
155155

156156
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(true);
157157
expect(allowRequest('http://bad.com/some/route', rules)).toEqual(true);
158158
expect(allowRequest('https://169.254.0.0/some/route', rules)).toEqual(false);
159159
});
160160

161-
it('allows whitelisting a single host on https', () => {
161+
it('allows single host on https', () => {
162162
const rules = [{ allow: true, host: 'kibana.com', protocol: 'https:' }, { allow: false }];
163163

164164
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(false);
165165
expect(allowRequest('http://bad.com/some/route', rules)).toEqual(false);
166166
expect(allowRequest('https://kibana.com/some/route', rules)).toEqual(true);
167167
});
168168

169-
it('allows whitelisting a single protocol to http', () => {
169+
it('allows single protocol to http', () => {
170170
const rules = [{ allow: true, protocol: 'https:' }, { allow: false }];
171171

172172
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(false);
173173
expect(allowRequest('http://bad.com/some/route', rules)).toEqual(false);
174174
expect(allowRequest('https://good.com/some/route', rules)).toEqual(true);
175175
});
176176

177-
it('allows whitelisting a single domain', () => {
177+
it('allows single domain', () => {
178178
const rules = [{ allow: true, host: 'kibana.com' }, { allow: false }];
179179

180180
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(true);
181181
expect(allowRequest('http://www.kibana.com/some/route', rules)).toEqual(true);
182182
expect(allowRequest('https://www-kibana.com/some/route', rules)).toEqual(false);
183183
});
184184

185-
it('can blacklist bad protocols', () => {
185+
it('can ban bad protocols', () => {
186186
const rules = [
187187
{ allow: true, protocol: 'http:' },
188188
{ allow: true, protocol: 'https:' },

β€Žx-pack/plugins/reporting/server/export_types/common/index.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export { decryptJobHeaders } from './decrypt_job_headers';
88
export { getConditionalHeaders } from './get_conditional_headers';
99
export { getCustomLogo } from './get_custom_logo';
1010
export { getFullUrls } from './get_full_urls';
11-
export { omitBlacklistedHeaders } from './omit_blacklisted_headers';
11+
export { omitBlockedHeaders } from './omit_blocked_headers';
1212
export { validateUrls } from './validate_urls';
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { omitBlacklistedHeaders } from './index';
7+
import { omitBlockedHeaders } from './index';
88

9-
test(`omits blacklisted headers`, async () => {
9+
test(`omits blocked headers`, async () => {
1010
const permittedHeaders = {
1111
foo: 'bar',
1212
baz: 'quix',
1313
};
1414

15-
const blacklistedHeaders = {
15+
const blockedHeaders = {
1616
'accept-encoding': '',
1717
connection: 'upgrade',
1818
'content-length': '',
@@ -24,7 +24,7 @@ test(`omits blacklisted headers`, async () => {
2424
trailer: 's are for trucks',
2525
};
2626

27-
const filteredHeaders = await omitBlacklistedHeaders({
27+
const filteredHeaders = await omitBlockedHeaders({
2828
job: {
2929
title: 'cool-job-bro',
3030
type: 'csv',
@@ -36,7 +36,7 @@ test(`omits blacklisted headers`, async () => {
3636
},
3737
decryptedHeaders: {
3838
...permittedHeaders,
39-
...blacklistedHeaders,
39+
...blockedHeaders,
4040
},
4141
});
4242

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*/
66
import { omitBy } from 'lodash';
77
import {
8-
KBN_SCREENSHOT_HEADER_BLACKLIST,
9-
KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN,
8+
KBN_SCREENSHOT_HEADER_BLOCK_LIST,
9+
KBN_SCREENSHOT_HEADER_BLOCK_LIST_STARTS_WITH_PATTERN,
1010
} from '../../../common/constants';
1111

12-
export const omitBlacklistedHeaders = <TaskPayloadType>({
12+
export const omitBlockedHeaders = <TaskPayloadType>({
1313
job,
1414
decryptedHeaders,
1515
}: {
@@ -20,8 +20,8 @@ export const omitBlacklistedHeaders = <TaskPayloadType>({
2020
decryptedHeaders,
2121
(_value, header: string) =>
2222
header &&
23-
(KBN_SCREENSHOT_HEADER_BLACKLIST.includes(header) ||
24-
KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN.some((pattern) =>
23+
(KBN_SCREENSHOT_HEADER_BLOCK_LIST.includes(header) ||
24+
KBN_SCREENSHOT_HEADER_BLOCK_LIST_STARTS_WITH_PATTERN.some((pattern) =>
2525
header?.startsWith(pattern)
2626
))
2727
);

β€Žx-pack/plugins/reporting/server/export_types/png/execute_job/index.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
decryptJobHeaders,
1414
getConditionalHeaders,
1515
getFullUrls,
16-
omitBlacklistedHeaders,
16+
omitBlockedHeaders,
1717
} from '../../common';
1818
import { generatePngObservableFactory } from '../lib/generate_png';
1919
import { TaskPayloadPNG } from '../types';
@@ -37,7 +37,7 @@ export const runTaskFnFactory: QueuedPngExecutorFactory = function executeJobFac
3737
const jobLogger = logger.clone([jobId]);
3838
const process$: Rx.Observable<TaskRunResult> = Rx.of(1).pipe(
3939
mergeMap(() => decryptJobHeaders({ encryptionKey, job, logger })),
40-
map((decryptedHeaders) => omitBlacklistedHeaders({ job, decryptedHeaders })),
40+
map((decryptedHeaders) => omitBlockedHeaders({ job, decryptedHeaders })),
4141
map((filteredHeaders) => getConditionalHeaders({ config, job, filteredHeaders })),
4242
mergeMap((conditionalHeaders) => {
4343
const urls = getFullUrls({ config, job });

β€Žx-pack/plugins/reporting/server/export_types/printable_pdf/execute_job/index.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
getConditionalHeaders,
1515
getCustomLogo,
1616
getFullUrls,
17-
omitBlacklistedHeaders,
17+
omitBlockedHeaders,
1818
} from '../../common';
1919
import { generatePdfObservableFactory } from '../lib/generate_pdf';
2020
import { TaskPayloadPDF } from '../types';
@@ -40,7 +40,7 @@ export const runTaskFnFactory: QueuedPdfExecutorFactory = function executeJobFac
4040
const jobLogger = logger.clone([jobId]);
4141
const process$: Rx.Observable<TaskRunResult> = Rx.of(1).pipe(
4242
mergeMap(() => decryptJobHeaders({ encryptionKey, job, logger })),
43-
map((decryptedHeaders) => omitBlacklistedHeaders({ job, decryptedHeaders })),
43+
map((decryptedHeaders) => omitBlockedHeaders({ job, decryptedHeaders })),
4444
map((filteredHeaders) => getConditionalHeaders({ config, job, filteredHeaders })),
4545
mergeMap((conditionalHeaders) =>
4646
getCustomLogo({ reporting, config, job, conditionalHeaders })

β€Žx-pack/plugins/reporting/server/routes/diagnostic/screenshot.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { i18n } from '@kbn/i18n';
88
import { ReportingCore } from '../..';
99
import { API_DIAGNOSE_URL } from '../../../common/constants';
10-
import { omitBlacklistedHeaders } from '../../export_types/common';
10+
import { omitBlockedHeaders } from '../../export_types/common';
1111
import { getAbsoluteUrlFactory } from '../../export_types/common/get_absolute_url';
1212
import { generatePngObservableFactory } from '../../export_types/png/lib/generate_png';
1313
import { LevelLogger as Logger } from '../../lib';
@@ -65,7 +65,7 @@ export const registerDiagnoseScreenshot = (reporting: ReportingCore, logger: Log
6565
};
6666

6767
const headers = {
68-
headers: omitBlacklistedHeaders({
68+
headers: omitBlockedHeaders({
6969
job: null,
7070
decryptedHeaders,
7171
}),

β€Žx-pack/plugins/reporting/server/routes/lib/job_response_handler.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { kibanaResponseFactory } from 'kibana/server';
88
import { ReportingCore } from '../../';
9-
import { WHITELISTED_JOB_CONTENT_TYPES } from '../../../common/constants';
9+
import { ALLOWED_JOB_CONTENT_TYPES } from '../../../common/constants';
1010
import { ReportingUser } from '../../types';
1111
import { getDocumentPayloadFactory } from './get_document_payload';
1212
import { jobsQueryFactory } from './jobs_query';
@@ -48,7 +48,7 @@ export function downloadJobResponseHandlerFactory(reporting: ReportingCore) {
4848

4949
const payload = getDocumentPayload(doc);
5050

51-
if (!payload.contentType || !WHITELISTED_JOB_CONTENT_TYPES.includes(payload.contentType)) {
51+
if (!payload.contentType || !ALLOWED_JOB_CONTENT_TYPES.includes(payload.contentType)) {
5252
return res.badRequest({
5353
body: `Unsupported content-type of ${payload.contentType} specified by job output`,
5454
});

0 commit comments

Comments
Β (0)