Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into security-rule…
Browse files Browse the repository at this point in the history
…-type-threshold
  • Loading branch information
madirey committed Sep 13, 2021
2 parents a352cbb + edc147b commit 04a024d
Show file tree
Hide file tree
Showing 213 changed files with 3,254 additions and 1,179 deletions.
17 changes: 17 additions & 0 deletions docs/setup/access.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,21 @@ image::images/kibana-status-page-7_14_0.png[Kibana server status page]

For JSON-formatted server status details, use the `localhost:5601/api/status` API endpoint.

[float]
[[not-ready]]
=== {kib} not ready

If you receive an error that the {kib} `server is not ready`, check the following:

* The {es} connectivity:
+
[source,sh]
----
`curl -XGET elasticsearch_ip_or_hostname:9200/`
----
* The {kib} logs:
** Linux, DEB or RPM package: `/var/log/kibana/kibana.log`
** Linux, tar.gz package: `$KIBANA_HOME/log/kibana.log`
** Windows: `$KIBANA_HOME\log\kibana.log`
* The health status of `.kibana*` indices

10 changes: 10 additions & 0 deletions docs/setup/docker.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ services:
- ./kibana.yml:/usr/share/kibana/config/kibana.yml
--------------------------------------------

==== Persist the {kib} keystore

By default, {kib] auto-generates a keystore file for secure settings at startup. To persist your {kibana-ref}/secure-settings.html[secure settings], use the `kibana-keystore` utility to bind-mount the parent directory of the keystore to the container. For example:

[source,sh]
----
docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data docker.elastic.co/kibana/kibana:7.14.0 bin/kibana-keystore create
docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data docker.elastic.co/kibana/kibana:7.14.0 bin/kibana-keystore add test_keystore_setting
----

[float]
[[environment-variable-config]]
==== Environment variable configuration
Expand Down
17 changes: 12 additions & 5 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27495,16 +27495,23 @@ function isIdentifierChar(code) {
function isIdentifierName(name) {
let isFirst = true;

for (let _i = 0, _Array$from = Array.from(name); _i < _Array$from.length; _i++) {
const char = _Array$from[_i];
const cp = char.codePointAt(0);
for (let i = 0; i < name.length; i++) {
let cp = name.charCodeAt(i);

if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
const trail = name.charCodeAt(++i);

if ((trail & 0xfc00) === 0xdc00) {
cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
}
}

if (isFirst) {
isFirst = false;

if (!isIdentifierStart(cp)) {
return false;
}

isFirst = false;
} else if (!isIdentifierChar(cp)) {
return false;
}
Expand Down
15 changes: 15 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@
labels: ['Feature:Vega', 'Team:VisEditors'],
enabled: true,
},
{
groupName: 'platform security modules',
packageNames: [
'broadcast-channel',
'jsonwebtoken', '@types/jsonwebtoken',
'node-forge', '@types/node-forge',
'require-in-the-middle',
'tough-cookie', '@types/tough-cookie',
'xml-crypto', '@types/xml-crypto'
],
reviewers: ['team:kibana-security'],
matchBaseBranches: ['master', '7.x'],
labels: ['Team:Security'],
enabled: true,
},
],
},
}
2 changes: 1 addition & 1 deletion src/core/public/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import '@elastic/eui/src/global_styling/variables/header';

// height of the header banner
$kbnHeaderBannerHeight: $euiSizeXL;
$kbnHeaderBannerHeight: $euiSizeXL; // This value is also declared in `/x-pack/plugins/canvas/common/lib/constants.ts`
// total height of the header (when the banner is *not* present)
$kbnHeaderOffset: $euiHeaderHeightCompensation * 2;
// total height of the header when the banner is present
Expand Down
6 changes: 6 additions & 0 deletions src/core/public/rendering/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@

&.kbnBody--hasHeaderBanner {
@include kbnAffordForHeader($kbnHeaderOffsetWithBanner);

// Prevents banners from covering full screen data grids
.euiDataGrid--fullScreen {
height: calc(100vh - #{$kbnHeaderBannerHeight});
top: $kbnHeaderBannerHeight;
}
}
&.kbnBody--chromeHidden {
@include kbnAffordForHeader(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ describe('Field', function () {
it('spec snapshot', () => {
const field = new IndexPatternField(fieldValues);
const getFormatterForField = () =>
({
(({
toJSON: () => ({
id: 'number',
params: {
pattern: '$0,0.[00]',
},
}),
} as FieldFormat);
} as unknown) as FieldFormat);
expect(field.toSpec({ getFormatterForField })).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ describe('flattenHit', () => {
fields: {
date: ['1'],
zzz: ['z'],
_abc: ['a'],
},
});
const expectedOrder = ['date', 'name', 'zzz', '_id', '_routing', '_score', '_type'];
const expectedOrder = ['_abc', 'date', 'name', 'zzz', '_id', '_routing', '_score', '_type'];
expect(Object.keys(response)).toEqual(expectedOrder);
expect(Object.entries(response).map(([key]) => key)).toEqual(expectedOrder);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function decorateFlattenedWrapper(hit: Record<string, any>, metaFields: Record<s

// unwrap computed fields
_.forOwn(hit.fields, function (val, key: any) {
if (key[0] === '_' && !_.includes(metaFields, key)) return;
// Flatten an array with 0 or 1 elements to a single value.
if (Array.isArray(val) && val.length <= 1) {
flattened[key] = val[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,17 @@ describe('IndexPattern', () => {

describe('toSpec', () => {
test('should match snapshot', () => {
const formatter = {
const formatter = ({
toJSON: () => ({ id: 'number', params: { pattern: '$0,0.[00]' } }),
} as FieldFormat;
} as unknown) as FieldFormat;
indexPattern.getFormatterForField = () => formatter;
expect(indexPattern.toSpec()).toMatchSnapshot();
});

test('can restore from spec', async () => {
const formatter = {
const formatter = ({
toJSON: () => ({ id: 'number', params: { pattern: '$0,0.[00]' } }),
} as FieldFormat;
} as unknown) as FieldFormat;
indexPattern.getFormatterForField = () => formatter;
const spec = indexPattern.toSpec();
const restoredPattern = new IndexPattern({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ export class SearchSource {
body.query = buildEsQuery(index, query, filters, esQueryConfigs);

if (highlightAll && body.query) {
body.highlight = getHighlightRequest(body.query, getConfig(UI_SETTINGS.DOC_HIGHLIGHT));
body.highlight = getHighlightRequest(getConfig(UI_SETTINGS.DOC_HIGHLIGHT));
delete searchRequest.highlightAll;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface FieldDescriptor {
type: string;
esTypes: string[];
subType?: FieldSubType;
metadata_field?: boolean;
}

interface FieldSubType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ describe('index_patterns/field_capabilities/field_capabilities', () => {
});

describe('response order', () => {
it('supports fields that start with an underscore', async () => {
const fields = ['_field_a', '_field_b'];

stubDeps({
fieldsFromFieldCaps: fields.map((name) => ({ name })),
});

const fieldNames = (await getFieldCapabilities()).map((field) => field.name);
expect(fieldNames).toEqual(fields);
});

it('always returns fields in alphabetical order', async () => {
const letters = 'ambcdfjopngihkel'.split('');
const sortedLetters = sortBy(letters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ export async function getFieldCapabilities(
const fieldsFromFieldCapsByName = keyBy(readFieldCapsResponse(esFieldCaps.body), 'name');

const allFieldsUnsorted = Object.keys(fieldsFromFieldCapsByName)
.filter((name) => !name.startsWith('_'))
// not all meta fields are provided, so remove and manually add
.filter((name) => !fieldsFromFieldCapsByName[name].metadata_field)
.concat(metaFields)
.reduce<{ names: string[]; hash: Record<string, string> }>(
.reduce<{ names: string[]; map: Map<string, string> }>(
(agg, value) => {
// This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes
if (agg.hash[value] != null) {
// This is intentionally using a Map to be highly optimized with very large indexes AND be safe for user provided data
if (agg.map.get(value) != null) {
return agg;
} else {
agg.hash[value] = value;
agg.map.set(value, value);
agg.names.push(value);
return agg;
}
},
{ names: [], hash: {} }
{ names: [], map: new Map<string, string>() }
)
.names.map<FieldDescriptor>((name) =>
defaults({}, fieldsFromFieldCapsByName[name], {
Expand All @@ -56,6 +57,7 @@ export async function getFieldCapabilities(
searchable: false,
aggregatable: false,
readFromDocValues: false,
metadata_field: metaFields.includes(name),
})
)
.map(mergeOverrides);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
'searchable',
'aggregatable',
'readFromDocValues',
'metadata_field',
]);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export function readFieldCapsResponse(
}),
{}
),
// @ts-expect-error
metadata_field: capsByType[types[0]].metadata_field,
};
// This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes
agg.array.push(field);
Expand All @@ -131,6 +133,8 @@ export function readFieldCapsResponse(
searchable: isSearchable,
aggregatable: isAggregatable,
readFromDocValues: shouldReadFieldFromDocValues(isAggregatable, esType),
// @ts-expect-error
metadata_field: capsByType[types[0]].metadata_field,
};
// This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes
agg.array.push(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const formatTopLevelObject = (
const displayKey = fields.getByName ? fields.getByName(key)?.displayName : undefined;
const formatter = field
? indexPattern.getFormatterForField(field)
: { convert: (v: string, ...rest: unknown[]) => String(v) };
: { convert: (v: unknown, ...rest: unknown[]) => String(v) };
if (!values.map) return;
const formatted = values
.map((val: unknown) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const getRenderCellValueFn = (
: undefined;
const formatter = subField
? indexPattern.getFormatterForField(subField)
: { convert: (v: string, ...rest: unknown[]) => String(v) };
: { convert: (v: unknown, ...rest: unknown[]) => String(v) };
const formatted = (values as unknown[])
.map((val: unknown) =>
formatter.convert(val, 'html', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const setup = (
return convert.call(format, value, options);
}

const subValues = value.map((v: any) => recurse(v, options));
const subValues = value.map((v: unknown) => recurse(v, options));
const useMultiLine = subValues.some((sub: string) => sub.indexOf('\n') > -1);

return subValues.join(',' + (useMultiLine ? '\n' : ' '));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { BoolFormat } from './boolean';

describe('Boolean Format', () => {
let boolean: Record<string, any>;
let boolean: BoolFormat;

beforeEach(() => {
boolean = new BoolFormat({}, jest.fn());
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/field_formats/common/converters/boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class BoolFormat extends FieldFormat {
});
static fieldType = [KBN_FIELD_TYPES.BOOLEAN, KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING];

textConvert: TextContextTypeConvert = (value) => {
textConvert: TextContextTypeConvert = (value: string | number | boolean) => {
if (typeof value === 'string') {
value = value.trim().toLowerCase();
}
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/field_formats/common/converters/bytes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import { BytesFormat } from './bytes';
import { FORMATS_UI_SETTINGS } from '../constants/ui_settings';
import { FieldFormatsGetConfigFn } from '../types';

describe('BytesFormat', () => {
const config: Record<string, any> = {};
const config: { [key: string]: string } = {
[FORMATS_UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN]: '0,0.[000]b',
};

config[FORMATS_UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN] = '0,0.[000]b';

const getConfig = (key: string) => config[key];
const getConfig: FieldFormatsGetConfigFn = (key: string) => config[key];

test('default pattern', () => {
const formatter = new BytesFormat({}, getConfig);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/field_formats/common/converters/color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export class ColorFormat extends FieldFormat {
};
}

findColorRuleForVal(val: any) {
findColorRuleForVal(val: string | number) {
switch (this.param('fieldType')) {
case 'string':
return findLast(this.param('colors'), (colorParam: typeof DEFAULT_CONVERTER_COLOR) => {
return new RegExp(colorParam.regex).test(val);
return new RegExp(colorParam.regex).test(val as string);
});

case 'number':
Expand All @@ -50,7 +50,7 @@ export class ColorFormat extends FieldFormat {
}
}

htmlConvert: HtmlContextTypeConvert = (val) => {
htmlConvert: HtmlContextTypeConvert = (val: string | number) => {
const color = this.findColorRuleForVal(val) as typeof DEFAULT_CONVERTER_COLOR;

const displayVal = escape(asPrettyString(val));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@

import moment from 'moment-timezone';
import { DateNanosFormat, analysePatternForFract, formatWithNanos } from './date_nanos_shared';
import { FieldFormatsGetConfigFn } from '../types';

describe('Date Nanos Format', () => {
let convert: Function;
let mockConfig: Record<string, any>;
let mockConfig: {
dateNanosFormat: string;
'dateFormat:tz': string;
[other: string]: string;
};

beforeEach(() => {
mockConfig = {};
mockConfig.dateNanosFormat = 'MMMM Do YYYY, HH:mm:ss.SSSSSSSSS';
mockConfig['dateFormat:tz'] = 'Browser';
mockConfig = {
dateNanosFormat: 'MMMM Do YYYY, HH:mm:ss.SSSSSSSSS',
'dateFormat:tz': 'Browser',
};

const getConfig = (key: string) => mockConfig[key];
const getConfig: FieldFormatsGetConfigFn = (key: string) => mockConfig[key];
const date = new DateNanosFormat({}, getConfig);

convert = date.convert.bind(date);
Expand Down
Loading

0 comments on commit 04a024d

Please sign in to comment.