Skip to content

Commit

Permalink
Merge branch 'main' into licensing/unskip-license-change-test
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan authored Aug 4, 2023
2 parents 2852465 + b1f30e5 commit 3beaa8f
Show file tree
Hide file tree
Showing 69 changed files with 935 additions and 367 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management @elastic/security-defend-workflows
/x-pack/test_serverless/functional/test_suites/security/cypress/screens/endpoint_management @elastic/security-defend-workflows
/x-pack/test_serverless/functional/test_suites/security/cypress/tasks/endpoint_management @elastic/security-defend-workflows
/x-pack/plugins/security_solution_serverless/public/upselling/sections/endpoint_management @elastic/security-defend-workflows

## Security Solution sub teams - security-telemetry (Data Engineering)
x-pack/plugins/security_solution/server/usage/ @elastic/security-data-analytics
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"del": "^6.1.0",
"elastic-apm-node": "^3.48.0",
"elastic-apm-node": "^3.49.0",
"email-addresses": "^5.0.0",
"execa": "^4.0.2",
"expiry-js": "0.1.7",
Expand Down Expand Up @@ -935,7 +935,7 @@
"query-string": "^6.13.2",
"rbush": "^3.0.1",
"re-resizable": "^6.9.9",
"re2": "1.17.7",
"re2": "1.20.1",
"react": "^17.0.2",
"react-ace": "^7.0.5",
"react-beautiful-dnd": "^13.1.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-io-ts-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ export {
} from './src/is_greater_or_equal';

export { datemathStringRt } from './src/datemath_string_rt';

export { createPlainError, decodeOrThrow, formatErrors, throwErrors } from './src/decode_or_throw';
54 changes: 54 additions & 0 deletions packages/kbn-io-ts-utils/src/decode_or_throw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { fold } from 'fp-ts/lib/Either';
import { identity } from 'fp-ts/lib/function';
import { pipe } from 'fp-ts/lib/pipeable';
import { Context, Errors, IntersectionType, Type, UnionType, ValidationError } from 'io-ts';

type ErrorFactory = (message: string) => Error;

const getErrorPath = ([first, ...rest]: Context): string[] => {
if (typeof first === 'undefined') {
return [];
} else if (first.type instanceof IntersectionType) {
const [, ...next] = rest;
return getErrorPath(next);
} else if (first.type instanceof UnionType) {
const [, ...next] = rest;
return [first.key, ...getErrorPath(next)];
}

return [first.key, ...getErrorPath(rest)];
};

const getErrorType = ({ context }: ValidationError) =>
context[context.length - 1]?.type?.name ?? 'unknown';

const formatError = (error: ValidationError) =>
error.message ??
`in ${getErrorPath(error.context).join('/')}: ${JSON.stringify(
error.value
)} does not match expected type ${getErrorType(error)}`;

export const formatErrors = (errors: ValidationError[]) =>
`Failed to validate: \n${errors.map((error) => ` ${formatError(error)}`).join('\n')}`;

export const createPlainError = (message: string) => new Error(message);

export const throwErrors = (createError: ErrorFactory) => (errors: Errors) => {
throw createError(formatErrors(errors));
};

export const decodeOrThrow =
<DecodedValue, EncodedValue, InputValue>(
runtimeType: Type<DecodedValue, EncodedValue, InputValue>,
createError: ErrorFactory = createPlainError
) =>
(inputValue: InputValue) =>
pipe(runtimeType.decode(inputValue), fold(throwErrors(createError), identity));
39 changes: 39 additions & 0 deletions scripts/download_re2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

args=("$@")
re2_version=${args[0]}

if [ -z "$re2_version" ]; then
echo "Usage: ./download_re2.sh [re2_version]"
exit 1
fi

archs=(
"darwin-arm64"
"darwin-x64"
"linux-musl-x64"
"linux-x64"
"win32-x64"
)
node_api_versions=( 108 115 )
formats=( "br" "gz" )

echo "Downloading builds of re2 version ${re2_version} to /tmp/re2"
mkdir /tmp/re2

for node_api_version in "${node_api_versions[@]}"; do
echo " Node.js API version ${node_api_version}"

for arch in "${archs[@]}"; do
for format in "${formats[@]}"; do
url="https://github.com/uhop/node-re2/releases/download/${re2_version}/${arch}-${node_api_version}.${format}"
echo " ${url}"
(cd /tmp/re2 && curl -s -L -O "${url}")
done
done
done

echo
echo "Calculating shasums for downloaded artifacts..."
echo
shasum -a 256 /tmp/re2/*
39 changes: 15 additions & 24 deletions src/dev/build/tasks/patch_native_modules_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ interface Package {

const packages: Package[] = [
{
// Tip: use `scripts/download_re2.sh` to download binary artifacts from GitHub
name: 're2',
version: '1.17.7',
version: '1.20.1',
destinationPath: 'node_modules/re2/build/Release/re2.node',
extractMethod: 'gunzip',
archives: {
'linux-x64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/linux-x64-108.gz',
sha256: 'e0b62ff7c415c95f57232f2726711c0fd71056c848538f095ba3fa1126ef5e31',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.20.1/linux-x64-108.gz',
sha256: 'e14f274f73ede22f170bfe9e57a0645ebf7ed320042a27361fa158bc239a5563',
},

// ARM builds are currently done manually as Github Actions used in upstream project
// do not natively support an ARM target.

// Linux ARM builds are currently done manually as Github Actions used in upstream project
// do not natively support an Linux ARM target.
//
// From an AWS Graviton instance running Ubuntu or a GCE T2A instance running Debian:
// * install build-essential package: `sudo apt-get update` + `sudo apt install build-essential`
// * install nvm and the node version used by the Kibana repository
Expand All @@ -63,29 +63,20 @@ const packages: Package[] = [
// * capture the sha256 with: `shasum -a 256 linux-arm64-*`
// * upload the `linux-arm64-*.gz` artifact to the `yarn-prebuilt-artifacts` bucket in GCS using the correct version number
'linux-arm64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/linux-arm64-108.gz',
sha256: 'e2025ead87be9f1ec4a9d892d1cce69c573101762720d56f52b1d52ed7ae0fef',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.20.1/linux-arm64-108.gz',
sha256: 'cbdf3f75a331c601ac0bd34715814d0a1fd17612c6d6b5269f176d46044defd5',
},

'darwin-x64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/darwin-x64-108.gz',
sha256: '4ed378c5a7fe6134b717afe7642254aff1ed7a881cbcaa53a012ac3efab49f99',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.20.1/darwin-x64-108.gz',
sha256: 'f88c09e98f152ac15c593b3b923b7fbe28d448cfde5986da40c34461bede5a09',
},

// A similar process is necessary for building on ARM macs:
// * bootstrap and re2 will build itself on install
// * `cp node_modules/re2/build/Release/re2.node darwin-arm64-$(node -e "console.log(process.versions.modules)")`
// * `gzip darwin-arm64-*`
// * capture the sha256 with: `shasum -a 256 darwin-arm64-*`
// * upload the `darwin-arm64-*.gz` artifact to the `yarn-prebuilt-artifacts` bucket in GCS using the correct version number
'darwin-arm64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/darwin-arm64-108.gz',
sha256: '42afc32137ff5c5bebae5d68347a9786906748c2f28e06194d8950707f2ae90e',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.20.1/darwin-arm64-108.gz',
sha256: '80700aecbe63052149aba721449a8ce30c24d884e414025124bb4602efe708be',
},

'win32-x64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/win32-x64-108.gz',
sha256: 'ff72fe02de652262659c8e17e44a932f3c873362233756b40d1a97538d05de92',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.20.1/win32-x64-108.gz',
sha256: 'cadc4713907f3ad1de45f470810ec8e13e08f32c1a1e45e5d5ab5e9d7fcb9763',
},
},
},
Expand Down
1 change: 1 addition & 0 deletions src/dev/ci_setup/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export PATH="$PATH:$yarnGlobalDir"
# use a proxy to fetch chromedriver/geckodriver asset
export GECKODRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CHROMEDRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CHROMEDRIVER_CDNBINARIESURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export RE2_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CYPRESS_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/cypress"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export const ControlEditor = ({
<EuiFormRow
label={ControlGroupStrings.manageControl.displaySettings.getWidthInputTitle()}
>
<>
<div>
<EuiButtonGroup
color="primary"
legend={ControlGroupStrings.management.controlWidth.getWidthSwitchLegend()}
Expand All @@ -275,7 +275,7 @@ export const ControlEditor = ({
onChange={() => setCurrentGrow(!currentGrow)}
data-test-subj="control-editor-grow-switch"
/>
</>
</div>
</EuiFormRow>
)}
</EuiDescribedFormGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
* Side Public License, v 1.
*/

import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
import { EuiPopover, EuiPopoverTitle, EuiSelectable, EuiSelectableProps } from '@elastic/eui';
import { EuiSelectable, EuiInputPopover, EuiSelectableProps } from '@elastic/eui';
import { DataViewListItem } from '@kbn/data-views-plugin/common';

import { ToolbarButton, ToolbarButtonProps } from '@kbn/kibana-react-plugin/public';

import './data_view_picker.scss';

export type DataViewTriggerProps = ToolbarButtonProps & {
label: string;
title?: string;
Expand All @@ -26,6 +23,7 @@ export function DataViewPicker({
onChangeDataViewId,
trigger,
selectableProps,
...other
}: {
dataViews: DataViewListItem[];
selectedDataViewId?: string;
Expand Down Expand Up @@ -61,20 +59,19 @@ export function DataViewPicker({
};

return (
<EuiPopover
button={createTrigger()}
isOpen={isPopoverOpen}
closePopover={() => setPopoverIsOpen(false)}
<EuiInputPopover
{...other}
ownFocus
fullWidth
display="block"
panelPaddingSize="s"
ownFocus
panelClassName="presDataViewPicker__panel"
isOpen={isPopoverOpen}
input={createTrigger()}
closePopover={() => setPopoverIsOpen(false)}
panelProps={{
'data-test-subj': 'data-view-picker-popover',
}}
>
<EuiPopoverTitle data-test-subj="data-view-picker-title">
{i18n.translate('presentationUtil.dataViewPicker.changeDataViewTitle', {
defaultMessage: 'Data view',
})}
</EuiPopoverTitle>
<EuiSelectable<{
key?: string;
label: string;
Expand Down Expand Up @@ -110,7 +107,7 @@ export function DataViewPicker({
</>
)}
</EuiSelectable>
</EuiPopover>
</EuiInputPopover>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

.presFieldPickerFieldButtonActive {
background-color: transparentize($euiColorPrimary, .9);
}

.fieldPickerSelectable {
height: $euiSizeXXL * 9; // 40 * 9 = 360px

.presFieldPicker__fieldButton[aria-checked='true'] {
background-color: transparentize($euiColorPrimary, .9);
}

.euiSelectableMessage {
height: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import classNames from 'classnames';
import { sortBy, uniq } from 'lodash';
import React, { useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';

import { i18n } from '@kbn/i18n';
import { FieldIcon } from '@kbn/react-field';
Expand Down Expand Up @@ -39,8 +39,12 @@ export const FieldPicker = ({
filterPredicate,
selectedFieldName,
selectableProps,
...other
}: FieldPickerProps) => {
const initialSelection = useRef(selectedFieldName);

const [typesFilter, setTypesFilter] = useState<string[]>([]);
const [searchRef, setSearchRef] = useState<HTMLInputElement | null>(null);
const [fieldSelectableOptions, setFieldSelectableOptions] = useState<EuiSelectableOption[]>([]);

const availableFields = useMemo(
Expand All @@ -50,7 +54,7 @@ export const FieldPicker = ({
.filter((f) => typesFilter.length === 0 || typesFilter.includes(f.type as string))
.filter((f) => (filterPredicate ? filterPredicate(f) : true)),
['name']
),
).sort((f) => (f.name === initialSelection.current ? -1 : 1)),
[dataView, filterPredicate, typesFilter]
);

Expand All @@ -60,9 +64,8 @@ export const FieldPicker = ({
return {
key: field.name,
label: field.displayName ?? field.name,
className: classNames('presFieldPicker__fieldButton', {
presFieldPickerFieldButtonActive: field.name === selectedFieldName,
}),
className: 'presFieldPicker__fieldButton',
checked: field.name === selectedFieldName ? 'on' : undefined,
'data-test-subj': `field-picker-select-${field.name}`,
prepend: (
<FieldIcon
Expand All @@ -89,9 +92,14 @@ export const FieldPicker = ({
[dataView, filterPredicate]
);

const setFocusToSearch = useCallback(() => {
searchRef?.focus();
}, [searchRef]);

const fieldTypeFilter = (
<EuiFormRow fullWidth={true}>
<FieldTypeFilter
setFocusToSearch={setFocusToSearch}
onFieldTypesChange={(types) => setTypesFilter(types)}
fieldTypesValue={typesFilter}
availableFieldTypes={uniqueTypes}
Expand All @@ -102,6 +110,7 @@ export const FieldPicker = ({

return (
<EuiSelectable
{...other}
{...selectableProps}
className={classNames('fieldPickerSelectable', {
fieldPickerSelectableLoading: selectableProps?.isLoading,
Expand All @@ -126,6 +135,7 @@ export const FieldPicker = ({
defaultMessage: 'Search field names',
}),
disabled: Boolean(selectableProps?.isLoading),
inputRef: setSearchRef,
}}
listProps={{
isVirtualized: true,
Expand Down

This file was deleted.

Loading

0 comments on commit 3beaa8f

Please sign in to comment.