mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Neutral-naming in reporting plugin (#77371)
* 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
This commit is contained in:
parent
1140b032f7
commit
ea56a32d51
9 changed files with 32 additions and 32 deletions
|
@ -23,7 +23,7 @@ export const CSV_REPORTING_ACTION = 'downloadCsvReport';
|
|||
export const CSV_BOM_CHARS = '\ufeff';
|
||||
export const CSV_FORMULA_CHARS = ['=', '+', '-', '@'];
|
||||
|
||||
export const WHITELISTED_JOB_CONTENT_TYPES = [
|
||||
export const ALLOWED_JOB_CONTENT_TYPES = [
|
||||
'application/json',
|
||||
'application/pdf',
|
||||
CONTENT_TYPE_CSV,
|
||||
|
@ -34,7 +34,7 @@ export const WHITELISTED_JOB_CONTENT_TYPES = [
|
|||
// See:
|
||||
// https://github.com/chromium/chromium/blob/3611052c055897e5ebbc5b73ea295092e0c20141/services/network/public/cpp/header_util_unittest.cc#L50
|
||||
// For a list of headers that chromium doesn't like
|
||||
export const KBN_SCREENSHOT_HEADER_BLACKLIST = [
|
||||
export const KBN_SCREENSHOT_HEADER_BLOCK_LIST = [
|
||||
'accept-encoding',
|
||||
'connection',
|
||||
'content-length',
|
||||
|
@ -51,7 +51,7 @@ export const KBN_SCREENSHOT_HEADER_BLACKLIST = [
|
|||
'keep-alive',
|
||||
];
|
||||
|
||||
export const KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN = ['proxy-'];
|
||||
export const KBN_SCREENSHOT_HEADER_BLOCK_LIST_STARTS_WITH_PATTERN = ['proxy-'];
|
||||
|
||||
export const UI_SETTINGS_CUSTOM_PDF_LOGO = 'xpackReporting:customPdfLogo';
|
||||
|
||||
|
|
|
@ -109,28 +109,28 @@ describe('Network Policy', () => {
|
|||
expect(allowRequest(url, rules)).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows requests when hosts are whitelisted IP addresses', () => {
|
||||
it('allows requests when hosts are allowed IP addresses', () => {
|
||||
const url = 'http://192.168.1.1/cool/route/bro';
|
||||
const rules = [{ allow: true, host: '192.168.1.1' }, { allow: false }];
|
||||
|
||||
expect(allowRequest(url, rules)).toEqual(true);
|
||||
});
|
||||
|
||||
it('denies requests when hosts are blacklisted IP addresses', () => {
|
||||
it('denies requests when hosts are from blocked IP addresses', () => {
|
||||
const url = 'http://192.168.1.1/cool/route/bro';
|
||||
const rules = [{ allow: false, host: '192.168.1.1' }, { allow: true }];
|
||||
|
||||
expect(allowRequest(url, rules)).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows requests when hosts are IP addresses not blacklisted', () => {
|
||||
it('allows requests when hosts are IP addresses that are not blocked', () => {
|
||||
const url = 'http://192.168.2.1/cool/route/bro';
|
||||
const rules = [{ allow: false, host: '192.168.1.1' }, { allow: true }];
|
||||
|
||||
expect(allowRequest(url, rules)).toEqual(true);
|
||||
});
|
||||
|
||||
it('denies requests when hosts are IP addresses not whitelisted', () => {
|
||||
it('denies requests when hosts are IP addresses not explicitly allowed', () => {
|
||||
const url = 'http://192.168.2.1/cool/route/bro';
|
||||
const rules = [{ allow: true, host: '192.168.1.1' }, { allow: false }];
|
||||
|
||||
|
@ -138,7 +138,7 @@ describe('Network Policy', () => {
|
|||
});
|
||||
|
||||
describe('Common cases', () => {
|
||||
it('allows whitelisting of certain routes based upon protocol', () => {
|
||||
it('allows certain routes based upon protocol', () => {
|
||||
const rules = [
|
||||
{ allow: true, host: 'kibana.com', protocol: 'http:' },
|
||||
{ allow: true, protocol: 'https:' },
|
||||
|
@ -150,7 +150,7 @@ describe('Network Policy', () => {
|
|||
expect(allowRequest('http://bad.com/some/route', rules)).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows blacklisting of certain IPs', () => {
|
||||
it('allows blocking of certain IPs', () => {
|
||||
const rules = [{ allow: false, host: '169.254.0.0' }, { allow: true }];
|
||||
|
||||
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(true);
|
||||
|
@ -158,7 +158,7 @@ describe('Network Policy', () => {
|
|||
expect(allowRequest('https://169.254.0.0/some/route', rules)).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows whitelisting a single host on https', () => {
|
||||
it('allows single host on https', () => {
|
||||
const rules = [{ allow: true, host: 'kibana.com', protocol: 'https:' }, { allow: false }];
|
||||
|
||||
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(false);
|
||||
|
@ -166,7 +166,7 @@ describe('Network Policy', () => {
|
|||
expect(allowRequest('https://kibana.com/some/route', rules)).toEqual(true);
|
||||
});
|
||||
|
||||
it('allows whitelisting a single protocol to http', () => {
|
||||
it('allows single protocol to http', () => {
|
||||
const rules = [{ allow: true, protocol: 'https:' }, { allow: false }];
|
||||
|
||||
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(false);
|
||||
|
@ -174,7 +174,7 @@ describe('Network Policy', () => {
|
|||
expect(allowRequest('https://good.com/some/route', rules)).toEqual(true);
|
||||
});
|
||||
|
||||
it('allows whitelisting a single domain', () => {
|
||||
it('allows single domain', () => {
|
||||
const rules = [{ allow: true, host: 'kibana.com' }, { allow: false }];
|
||||
|
||||
expect(allowRequest('http://kibana.com/some/route', rules)).toEqual(true);
|
||||
|
@ -182,7 +182,7 @@ describe('Network Policy', () => {
|
|||
expect(allowRequest('https://www-kibana.com/some/route', rules)).toEqual(false);
|
||||
});
|
||||
|
||||
it('can blacklist bad protocols', () => {
|
||||
it('can ban bad protocols', () => {
|
||||
const rules = [
|
||||
{ allow: true, protocol: 'http:' },
|
||||
{ allow: true, protocol: 'https:' },
|
||||
|
|
|
@ -8,5 +8,5 @@ export { decryptJobHeaders } from './decrypt_job_headers';
|
|||
export { getConditionalHeaders } from './get_conditional_headers';
|
||||
export { getCustomLogo } from './get_custom_logo';
|
||||
export { getFullUrls } from './get_full_urls';
|
||||
export { omitBlacklistedHeaders } from './omit_blacklisted_headers';
|
||||
export { omitBlockedHeaders } from './omit_blocked_headers';
|
||||
export { validateUrls } from './validate_urls';
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { omitBlacklistedHeaders } from './index';
|
||||
import { omitBlockedHeaders } from './index';
|
||||
|
||||
test(`omits blacklisted headers`, async () => {
|
||||
test(`omits blocked headers`, async () => {
|
||||
const permittedHeaders = {
|
||||
foo: 'bar',
|
||||
baz: 'quix',
|
||||
};
|
||||
|
||||
const blacklistedHeaders = {
|
||||
const blockedHeaders = {
|
||||
'accept-encoding': '',
|
||||
connection: 'upgrade',
|
||||
'content-length': '',
|
||||
|
@ -24,7 +24,7 @@ test(`omits blacklisted headers`, async () => {
|
|||
trailer: 's are for trucks',
|
||||
};
|
||||
|
||||
const filteredHeaders = await omitBlacklistedHeaders({
|
||||
const filteredHeaders = await omitBlockedHeaders({
|
||||
job: {
|
||||
title: 'cool-job-bro',
|
||||
type: 'csv',
|
||||
|
@ -36,7 +36,7 @@ test(`omits blacklisted headers`, async () => {
|
|||
},
|
||||
decryptedHeaders: {
|
||||
...permittedHeaders,
|
||||
...blacklistedHeaders,
|
||||
...blockedHeaders,
|
||||
},
|
||||
});
|
||||
|
|
@ -5,11 +5,11 @@
|
|||
*/
|
||||
import { omitBy } from 'lodash';
|
||||
import {
|
||||
KBN_SCREENSHOT_HEADER_BLACKLIST,
|
||||
KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN,
|
||||
KBN_SCREENSHOT_HEADER_BLOCK_LIST,
|
||||
KBN_SCREENSHOT_HEADER_BLOCK_LIST_STARTS_WITH_PATTERN,
|
||||
} from '../../../common/constants';
|
||||
|
||||
export const omitBlacklistedHeaders = <TaskPayloadType>({
|
||||
export const omitBlockedHeaders = <TaskPayloadType>({
|
||||
job,
|
||||
decryptedHeaders,
|
||||
}: {
|
||||
|
@ -20,8 +20,8 @@ export const omitBlacklistedHeaders = <TaskPayloadType>({
|
|||
decryptedHeaders,
|
||||
(_value, header: string) =>
|
||||
header &&
|
||||
(KBN_SCREENSHOT_HEADER_BLACKLIST.includes(header) ||
|
||||
KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN.some((pattern) =>
|
||||
(KBN_SCREENSHOT_HEADER_BLOCK_LIST.includes(header) ||
|
||||
KBN_SCREENSHOT_HEADER_BLOCK_LIST_STARTS_WITH_PATTERN.some((pattern) =>
|
||||
header?.startsWith(pattern)
|
||||
))
|
||||
);
|
|
@ -13,7 +13,7 @@ import {
|
|||
decryptJobHeaders,
|
||||
getConditionalHeaders,
|
||||
getFullUrls,
|
||||
omitBlacklistedHeaders,
|
||||
omitBlockedHeaders,
|
||||
} from '../../common';
|
||||
import { generatePngObservableFactory } from '../lib/generate_png';
|
||||
import { TaskPayloadPNG } from '../types';
|
||||
|
@ -37,7 +37,7 @@ export const runTaskFnFactory: QueuedPngExecutorFactory = function executeJobFac
|
|||
const jobLogger = logger.clone([jobId]);
|
||||
const process$: Rx.Observable<TaskRunResult> = Rx.of(1).pipe(
|
||||
mergeMap(() => decryptJobHeaders({ encryptionKey, job, logger })),
|
||||
map((decryptedHeaders) => omitBlacklistedHeaders({ job, decryptedHeaders })),
|
||||
map((decryptedHeaders) => omitBlockedHeaders({ job, decryptedHeaders })),
|
||||
map((filteredHeaders) => getConditionalHeaders({ config, job, filteredHeaders })),
|
||||
mergeMap((conditionalHeaders) => {
|
||||
const urls = getFullUrls({ config, job });
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
getConditionalHeaders,
|
||||
getCustomLogo,
|
||||
getFullUrls,
|
||||
omitBlacklistedHeaders,
|
||||
omitBlockedHeaders,
|
||||
} from '../../common';
|
||||
import { generatePdfObservableFactory } from '../lib/generate_pdf';
|
||||
import { TaskPayloadPDF } from '../types';
|
||||
|
@ -40,7 +40,7 @@ export const runTaskFnFactory: QueuedPdfExecutorFactory = function executeJobFac
|
|||
const jobLogger = logger.clone([jobId]);
|
||||
const process$: Rx.Observable<TaskRunResult> = Rx.of(1).pipe(
|
||||
mergeMap(() => decryptJobHeaders({ encryptionKey, job, logger })),
|
||||
map((decryptedHeaders) => omitBlacklistedHeaders({ job, decryptedHeaders })),
|
||||
map((decryptedHeaders) => omitBlockedHeaders({ job, decryptedHeaders })),
|
||||
map((filteredHeaders) => getConditionalHeaders({ config, job, filteredHeaders })),
|
||||
mergeMap((conditionalHeaders) =>
|
||||
getCustomLogo({ reporting, config, job, conditionalHeaders })
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { ReportingCore } from '../..';
|
||||
import { API_DIAGNOSE_URL } from '../../../common/constants';
|
||||
import { omitBlacklistedHeaders } from '../../export_types/common';
|
||||
import { omitBlockedHeaders } from '../../export_types/common';
|
||||
import { getAbsoluteUrlFactory } from '../../export_types/common/get_absolute_url';
|
||||
import { generatePngObservableFactory } from '../../export_types/png/lib/generate_png';
|
||||
import { LevelLogger as Logger } from '../../lib';
|
||||
|
@ -65,7 +65,7 @@ export const registerDiagnoseScreenshot = (reporting: ReportingCore, logger: Log
|
|||
};
|
||||
|
||||
const headers = {
|
||||
headers: omitBlacklistedHeaders({
|
||||
headers: omitBlockedHeaders({
|
||||
job: null,
|
||||
decryptedHeaders,
|
||||
}),
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { kibanaResponseFactory } from 'kibana/server';
|
||||
import { ReportingCore } from '../../';
|
||||
import { WHITELISTED_JOB_CONTENT_TYPES } from '../../../common/constants';
|
||||
import { ALLOWED_JOB_CONTENT_TYPES } from '../../../common/constants';
|
||||
import { ReportingUser } from '../../types';
|
||||
import { getDocumentPayloadFactory } from './get_document_payload';
|
||||
import { jobsQueryFactory } from './jobs_query';
|
||||
|
@ -48,7 +48,7 @@ export function downloadJobResponseHandlerFactory(reporting: ReportingCore) {
|
|||
|
||||
const payload = getDocumentPayload(doc);
|
||||
|
||||
if (!payload.contentType || !WHITELISTED_JOB_CONTENT_TYPES.includes(payload.contentType)) {
|
||||
if (!payload.contentType || !ALLOWED_JOB_CONTENT_TYPES.includes(payload.contentType)) {
|
||||
return res.badRequest({
|
||||
body: `Unsupported content-type of ${payload.contentType} specified by job output`,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue