Skip to content

Commit

Permalink
Merge branch 'main' into alerting/load-maintenance-windows-later
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Sep 19, 2024
2 parents 3dd0eac + dfbd7de commit fc94013
Show file tree
Hide file tree
Showing 267 changed files with 6,357 additions and 3,574 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_security_serverless_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ enabled:
- x-pack/test/security_solution_api_integration/test_suites/genai/knowledge_base/entries/trial_license_complete_tier/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/trial_license_complete_tier/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/basic_license_essentials_tier/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/entity_analytics/entity_store/trial_license_complete_tier/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/exception_lists_items/trial_license_complete_tier/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/lists_items/trial_license_complete_tier/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/configs/serverless.config.ts
Expand Down
1 change: 1 addition & 0 deletions .buildkite/ftr_security_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enabled:
- x-pack/test/security_solution_api_integration/test_suites/detections_response/user_roles/trial_license_complete_tier/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/trial_license_complete_tier/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/basic_license_essentials_tier/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/entity_analytics/entity_store/trial_license_complete_tier/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/exception_lists_items/trial_license_complete_tier/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/lists_items/trial_license_complete_tier/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/configs/ess.config.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

VALIDATION_PACKAGE_DIR="packages/kbn-esql-validation-autocomplete"
EDITOR_PACKAGE_DIR="packages/kbn-text-based-editor"
EDITOR_PACKAGE_DIR="packages/kbn-language-documentation-popover"
GIT_SCOPE="$VALIDATION_PACKAGE_DIR/**/* $EDITOR_PACKAGE_DIR/**/*"

report_main_step () {
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
# Kibana Platform Security
/.github/codeql @elastic/kibana-security
/.github/workflows/codeql.yml @elastic/kibana-security
/.github/workflows/codeql-stats.yml @elastic/kibana-security
/src/dev/eslint/security_eslint_rule_tests.ts @elastic/kibana-security
/src/core/server/integration_tests/config/check_dynamic_config.test.ts @elastic/kibana-security
/src/plugins/telemetry/server/config/telemetry_labels.ts @elastic/kibana-security
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/codeql-stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CodeQL statistics

on:
schedule:
- cron: '27 0 * * 1' # At 00:27 every Monday

jobs:
stats:
name: CodeQL statistics
runs-on: ubuntu-latest
if: github.repository == 'elastic/kibana' # Hack: Do not run on forks
steps:
- name: Checkout kibana-operations
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: 'elastic/kibana-operations'
ref: main
path: ./kibana-operations
token: ${{secrets.KIBANAMACHINE_TOKEN}}

- name: CodeQL alert statistics
working-directory: ./kibana-operations/triage
env:
GITHUB_TOKEN: ${{secrets.KIBANAMACHINE_TOKEN}}
SLACK_TOKEN: ${{secrets.CODE_SCANNING_SLACK_TOKEN}}
run: |
npm ci --omit=dev
node codeql-alert-stats
9 changes: 0 additions & 9 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,3 @@ jobs:
run: |
npm ci --omit=dev
node codeql-alert
- name: CodeQL alert statistics
working-directory: ./kibana-operations/triage
env:
GITHUB_TOKEN: ${{secrets.KIBANAMACHINE_TOKEN}}
SLACK_TOKEN: ${{secrets.CODE_SCANNING_SLACK_TOKEN}}
run: |
npm ci --omit=dev
node codeql-alert-stats
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const createOpts = async (props: KibanaConnectionDetailsProviderProps) => {
const { http, docLinks, analytics } = start.core;
const locator = start.plugins?.share?.url?.locators.get('MANAGEMENT_APP_LOCATOR');
const manageKeysLink = await locator?.getUrl({ sectionId: 'security', appId: 'api_keys' });
const elasticsearchConfig = await start.plugins?.cloud?.fetchElasticsearchConfig();
const result: ConnectionDetailsOpts = {
...options,
navigateToUrl: start.core.application
Expand All @@ -35,7 +36,7 @@ const createOpts = async (props: KibanaConnectionDetailsProviderProps) => {
},
endpoints: {
id: start.plugins?.cloud?.cloudId,
url: start.plugins?.cloud?.elasticsearchUrl,
url: elasticsearchConfig?.elasticsearchUrl,
cloudIdLearMoreLink: docLinks?.links?.cloud?.beatsAndLogstashConfiguration,
...options?.endpoints,
},
Expand Down
15 changes: 11 additions & 4 deletions packages/cloud/deployment_details/services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React, { FC, PropsWithChildren, useContext } from 'react';
import React, { FC, PropsWithChildren, useContext, useEffect } from 'react';

export interface DeploymentDetailsContextValue {
cloudId?: string;
Expand Down Expand Up @@ -58,7 +57,7 @@ export interface DeploymentDetailsKibanaDependencies {
cloud: {
isCloudEnabled: boolean;
cloudId?: string;
elasticsearchUrl?: string;
fetchElasticsearchConfig: () => Promise<{ elasticsearchUrl?: string }>;
};
/** DocLinksStart contract */
docLinks: {
Expand All @@ -79,11 +78,19 @@ export interface DeploymentDetailsKibanaDependencies {
export const DeploymentDetailsKibanaProvider: FC<
PropsWithChildren<DeploymentDetailsKibanaDependencies>
> = ({ children, ...services }) => {
const [elasticsearchUrl, setElasticsearchUrl] = React.useState<string>('');

useEffect(() => {
services.cloud.fetchElasticsearchConfig().then((config) => {
setElasticsearchUrl(config.elasticsearchUrl || '');
});
}, [services.cloud]);

const {
core: {
application: { navigateToUrl },
},
cloud: { isCloudEnabled, cloudId, elasticsearchUrl },
cloud: { isCloudEnabled, cloudId },
share: {
url: { locators },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test('set correct defaults', () => {
"maxSockets": 800,
"password": undefined,
"pingTimeout": "PT30S",
"publicBaseUrl": undefined,
"requestHeadersWhitelist": Array [
"authorization",
"es-client-authentication",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ export class ElasticsearchConfig implements IElasticsearchConfig {
*/
public readonly hosts: string[];

/**
* Optional host that users can use to connect to your Elasticsearch cluster,
* this URL will be shown in Kibana as the Elasticsearch URL
*/

public readonly publicBaseUrl?: string;

/**
* List of Kibana client-side headers to send to Elasticsearch when request
* scoped cluster client is used. If this is an empty array then *no* client-side
Expand Down Expand Up @@ -473,6 +480,7 @@ export class ElasticsearchConfig implements IElasticsearchConfig {
this.skipStartupConnectionCheck = rawConfig.skipStartupConnectionCheck;
this.apisToRedactInLogs = rawConfig.apisToRedactInLogs;
this.dnsCacheTtl = rawConfig.dnsCacheTtl;
this.publicBaseUrl = rawConfig.publicBaseUrl;

const { alwaysPresentCertificate, verificationMode } = rawConfig.ssl;
const { key, keyPassphrase, certificate, certificateAuthorities } = readKeyAndCerts(rawConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class ElasticsearchService
agentStatsProvider: {
getAgentsStats: agentManager.getAgentsStats.bind(agentManager),
},
publicBaseUrl: config.publicBaseUrl,
};
}

Expand Down Expand Up @@ -194,6 +195,7 @@ export class ElasticsearchService
metrics: {
elasticsearchWaitTime,
},
publicBaseUrl: config.publicBaseUrl,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ export interface ElasticsearchServiceStart {
* Returns the capabilities for the default cluster.
*/
getCapabilities: () => ElasticsearchCapabilities;

/**
* The public base URL (if any) that should be used by end users to access the Elasticsearch cluster.
*/

readonly publicBaseUrl?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>({
docLinks: deps.docLinks,
elasticsearch: {
legacy: deps.elasticsearch.legacy,
publicBaseUrl: deps.elasticsearch.publicBaseUrl,
setUnauthorizedErrorHandler: deps.elasticsearch.setUnauthorizedErrorHandler,
},
executionContext: {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-utils/src/utils/append_to_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function appendWhereClauseToESQLQuery(
default:
operator = '==';
}
let filterValue = typeof value === 'string' ? `"${value.replace(/"/g, '\\"')}"` : value;
let filterValue = typeof value === 'string' ? `"${value.replace(/\"/g, '\\"')}"` : value;
// Adding the backticks here are they are needed for special char fields
let fieldName = `\`${field}\``;

Expand Down
9 changes: 5 additions & 4 deletions packages/kbn-language-documentation-popover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { LanguageDocumentationPopover } from './src/components/documentation_popover';
export { LanguageDocumentationPopoverContent } from './src/components/documentation_content';
export type { LanguageDocumentationSections } from './src/components/documentation_content';
export { LanguageDocumentationPopover } from './src/components/as_popover';
export { LanguageDocumentationPopoverContent } from './src/components/as_popover/popover_content';
export { LanguageDocumentationFlyout } from './src/components/as_flyout';
export { LanguageDocumentationInline } from './src/components/as_inline';
export type { LanguageDocumentationSections } from './src/types';
9 changes: 7 additions & 2 deletions packages/kbn-language-documentation-popover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
"private": true,
"sideEffects": [
"*.scss"
]
}
],
"scripts": {
"make:docs": "ts-node --transpileOnly scripts/generate_esql_docs.ts",
"postmake:docs": "yarn run lint:fix",
"lint:fix": "cd ../.. && node ./scripts/eslint --fix ./packages/kbn-language-documentation-popover/src/sections/generated"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import * as recast from 'recast';
const n = recast.types.namedTypes;
import fs from 'fs';
import path from 'path';
import { functions } from '../src/inline_documentation/generated/scalar_functions';
import { functions } from '../src/sections/generated/scalar_functions';

(function () {
const pathToElasticsearch = process.argv[2];
const { scalarFunctions, aggregationFunctions } = loadFunctionDocs(pathToElasticsearch);
writeFunctionDocs(
scalarFunctions,
path.join(__dirname, '../src/inline_documentation/generated/scalar_functions.tsx')
path.join(__dirname, '../src/sections/generated/scalar_functions.tsx')
);
writeFunctionDocs(
aggregationFunctions,
path.join(__dirname, '../src/inline_documentation/generated/aggregation_functions.tsx')
path.join(__dirname, '../src/sections/generated/aggregation_functions.tsx')
);
})();

Expand Down Expand Up @@ -86,7 +86,7 @@ function writeFunctionDocs(functionDocs: Map<string, string>, pathToDocsFile: st
// Do not edit manually... automatically generated by scripts/generate_esql_docs.ts
{
label: i18n.translate(
'textBasedEditor.query.textBasedLanguagesEditor.documentationESQL.${name}',
'languageDocumentationPopover.documentationESQL.${name}',
{
defaultMessage: '${name.toUpperCase()}',
}
Expand All @@ -97,7 +97,7 @@ function writeFunctionDocs(functionDocs: Map<string, string>, pathToDocsFile: st
readOnly
enableSoftLineBreaks
markdownContent={i18n.translate(
'textBasedEditor.query.textBasedLanguagesEditor.documentationESQL.${name}.markdown',
'languageDocumentationPopover.documentationESQL.${name}.markdown',
{
defaultMessage: \`${docWithoutLinks.replaceAll('`', '\\`')}\`,
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { pluginServices } from './plugin_services';
// eslint-disable-next-line import/no-extraneous-dependencies
import '@testing-library/jest-dom';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import React from 'react';
import { storiesOf } from '@storybook/react';
import { LanguageDocumentationPopover } from '../components/documentation_popover';
import { LanguageDocumentationPopover } from '../components/as_popover';

const sections = {
groups: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React from 'react';
import { screen, render, fireEvent, waitFor } from '@testing-library/react';
import { LanguageDocumentationFlyout } from '.';

jest.mock('../../sections', () => {
const module = jest.requireActual('../../sections');
return {
...module,
getESQLDocsSections: () => ({
groups: [
{
label: 'Section one',
description: 'Section 1 description',
items: [],
},
{
label: 'Section two',
items: [
{
label: 'Section two item 1',
description: 'Section two item 1 description',
},
{
label: 'Section two item 2',
description: 'Section two item 2 description',
},
],
},
{
label: 'Section three',
items: [
{
label: 'Section three item 1',
description: 'Section three item 1 description',
},
{
label: 'Section three item 2',
description: 'Section three item 2 description',
},
],
},
],
initialSection: <span>Here is the initial section</span>,
}),
};
});

describe('###Documentation flyout component', () => {
const renderFlyout = (linkToDocumentation?: string) => {
return render(
<LanguageDocumentationFlyout
isHelpMenuOpen={true}
onHelpMenuVisibilityChange={jest.fn()}
linkToDocumentation={linkToDocumentation}
/>
);
};
it('has a header element for navigation through the sections', () => {
renderFlyout();
expect(screen.getByTestId('language-documentation-navigation-search')).toBeInTheDocument();
expect(screen.getByTestId('language-documentation-navigation-dropdown')).toBeInTheDocument();
expect(screen.queryByTestId('language-documentation-navigation-link')).not.toBeInTheDocument();
});

it('has a link if linkToDocumentation prop is given', () => {
renderFlyout('meow');
expect(screen.getByTestId('language-documentation-navigation-link')).toBeInTheDocument();
});

it('contains the two last sections', async () => {
renderFlyout();
await waitFor(() => {
expect(screen.getByText('Section two')).toBeInTheDocument();
expect(screen.getByText('Section three')).toBeInTheDocument();
});
});

it('contains the correct section if user updates the search input', async () => {
renderFlyout();
const input = screen.getByTestId('language-documentation-navigation-search');
fireEvent.change(input, { target: { value: 'two' } });
await waitFor(() => {
expect(screen.getByText('Section two')).toBeInTheDocument();
});
});
});
Loading

0 comments on commit fc94013

Please sign in to comment.