Skip to content

Commit

Permalink
Merge branch 'main' into apm-logs-only-dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes authored Oct 16, 2024
2 parents fc07ba5 + e6569f0 commit 85cdc49
Show file tree
Hide file tree
Showing 98 changed files with 1,295 additions and 395 deletions.
12 changes: 12 additions & 0 deletions oas_docs/output/kibana.serverless.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35266,6 +35266,10 @@ paths:
schema:
nullable: true
type: string
- in: query
name: associatedFilter
schema:
$ref: '#/components/schemas/Security_Timeline_API_AssociatedFilterType'
responses:
'200':
content:
Expand Down Expand Up @@ -49419,6 +49423,14 @@ components:
Security_Osquery_API_VersionOrUndefined:
$ref: '#/components/schemas/Security_Osquery_API_Version'
nullable: true
Security_Timeline_API_AssociatedFilterType:
description: Filter notes based on their association with a document or saved object.
enum:
- document_only
- saved_object_only
- document_and_saved_object
- orphan
type: string
Security_Timeline_API_BareNote:
type: object
properties:
Expand Down
12 changes: 12 additions & 0 deletions oas_docs/output/kibana.serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35266,6 +35266,10 @@ paths:
schema:
nullable: true
type: string
- in: query
name: associatedFilter
schema:
$ref: '#/components/schemas/Security_Timeline_API_AssociatedFilterType'
responses:
'200':
content:
Expand Down Expand Up @@ -49419,6 +49423,14 @@ components:
Security_Osquery_API_VersionOrUndefined:
$ref: '#/components/schemas/Security_Osquery_API_Version'
nullable: true
Security_Timeline_API_AssociatedFilterType:
description: Filter notes based on their association with a document or saved object.
enum:
- document_only
- saved_object_only
- document_and_saved_object
- orphan
type: string
Security_Timeline_API_BareNote:
type: object
properties:
Expand Down
12 changes: 12 additions & 0 deletions oas_docs/output/kibana.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38697,6 +38697,10 @@ paths:
schema:
nullable: true
type: string
- in: query
name: associatedFilter
schema:
$ref: '#/components/schemas/Security_Timeline_API_AssociatedFilterType'
responses:
'200':
content:
Expand Down Expand Up @@ -58185,6 +58189,14 @@ components:
Security_Osquery_API_VersionOrUndefined:
$ref: '#/components/schemas/Security_Osquery_API_Version'
nullable: true
Security_Timeline_API_AssociatedFilterType:
description: Filter notes based on their association with a document or saved object.
enum:
- document_only
- saved_object_only
- document_and_saved_object
- orphan
type: string
Security_Timeline_API_BareNote:
type: object
properties:
Expand Down
12 changes: 12 additions & 0 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38697,6 +38697,10 @@ paths:
schema:
nullable: true
type: string
- in: query
name: associatedFilter
schema:
$ref: '#/components/schemas/Security_Timeline_API_AssociatedFilterType'
responses:
'200':
content:
Expand Down Expand Up @@ -58185,6 +58189,14 @@ components:
Security_Osquery_API_VersionOrUndefined:
$ref: '#/components/schemas/Security_Osquery_API_Version'
nullable: true
Security_Timeline_API_AssociatedFilterType:
description: Filter notes based on their association with a document or saved object.
enum:
- document_only
- saved_object_only
- document_and_saved_object
- orphan
type: string
Security_Timeline_API_BareNote:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-es-types/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ export interface ESQLSearchParams {
query: string;
filter?: unknown;
locale?: string;
include_ccs_metadata?: boolean;
dropNullColumns?: boolean;
params?: Array<Record<string, string | undefined>>;
}
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/columns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';

describe('Column Identifier Expressions', () => {
it('can parse un-quoted identifiers', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';

describe('commands', () => {
describe('correctly formatted, basic usage', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/from.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';

describe('FROM', () => {
describe('correctly formatted', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';
import { Walker } from '../../walker';

describe('function AST nodes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';
import { ESQLFunction, ESQLInlineCast, ESQLSingleAstItem } from '../../types';

describe('Inline cast (::)', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/literal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';
import { ESQLLiteral } from '../../types';

describe('literal expression', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';

describe('METRICS', () => {
describe('correctly formatted', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/params.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';
import { Walker } from '../../walker';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/rename.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';

describe('RENAME', () => {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/sort.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';

describe('SORT', () => {
describe('correctly formatted', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/parser/__tests__/where.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getAstAndSyntaxErrors as parse } from '..';
import { parse } from '..';

describe('WHERE', () => {
describe('correctly formatted', () => {
Expand Down
85 changes: 59 additions & 26 deletions packages/kbn-esql-ast/src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,66 @@ export interface ParseResult {
}

export const parse = (text: string | undefined, options: ParseOptions = {}): ParseResult => {
if (text == null) {
const commands: ESQLAstQueryExpression['commands'] = [];
return { ast: commands, root: Builder.expression.query(commands), errors: [], tokens: [] };
try {
if (text == null) {
const commands: ESQLAstQueryExpression['commands'] = [];
return { ast: commands, root: Builder.expression.query(commands), errors: [], tokens: [] };
}
const errorListener = new ESQLErrorListener();
const parseListener = new ESQLAstBuilderListener();
const { tokens, parser } = getParser(
CharStreams.fromString(text),
errorListener,
parseListener
);

parser[GRAMMAR_ROOT_RULE]();

const errors = errorListener.getErrors().filter((error) => {
return !SYNTAX_ERRORS_TO_IGNORE.includes(error.message);
});
const { ast: commands } = parseListener.getAst();
const root = Builder.expression.query(commands, {
location: {
min: 0,
max: text.length - 1,
},
});

if (options.withFormatting) {
const decorations = collectDecorations(tokens);
attachDecorations(root, tokens.tokens, decorations.lines);
}

return { root, ast: commands, errors, tokens: tokens.tokens };
} catch (error) {
/**
* Parsing should never fail, meaning this branch should never execute. But
* if it does fail, we want to log the error message for easier debugging.
*/
// eslint-disable-next-line no-console
console.error(error);

const root = Builder.expression.query();

return {
root,
ast: root.commands,
errors: [
{
startLineNumber: 0,
endLineNumber: 0,
startColumn: 0,
endColumn: 0,
message:
'Parsing internal error: ' +
(!!error && typeof error === 'object' ? String(error.message) : String(error)),
severity: 'error',
},
],
tokens: [],
};
}
const errorListener = new ESQLErrorListener();
const parseListener = new ESQLAstBuilderListener();
const { tokens, parser } = getParser(CharStreams.fromString(text), errorListener, parseListener);

parser[GRAMMAR_ROOT_RULE]();

const errors = errorListener.getErrors().filter((error) => {
return !SYNTAX_ERRORS_TO_IGNORE.includes(error.message);
});
const { ast: commands } = parseListener.getAst();
const root = Builder.expression.query(commands, {
location: {
min: 0,
max: text.length - 1,
},
});

if (options.withFormatting) {
const decorations = collectDecorations(tokens);
attachDecorations(root, tokens.tokens, decorations.lines);
}

return { root, ast: commands, errors, tokens: tokens.tokens };
};

export const parseErrors = (text: string) => {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/common/search/expressions/esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
query,
// time_zone: timezone,
locale,
include_ccs_metadata: true,
};
if (input) {
const esQueryConfigs = getEsQueryConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
const security = getService('security');

describe('discover data grid context tests', () => {
// Failing: See https://github.com/elastic/kibana/issues/196120
describe.skip('discover data grid context tests', () => {
before(async () => {
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']);
await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] });
Expand Down
1 change: 1 addition & 0 deletions x-pack/packages/security/plugin_types_public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export type {
} from './src/roles';
export { PrivilegesAPIClientPublicContract } from './src/privileges';
export type { PrivilegesAPIClientGetAllArgs } from './src/privileges';
export type { SecurityLicense } from './src/license';
10 changes: 10 additions & 0 deletions x-pack/packages/security/plugin_types_public/src/license/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { SecurityPluginSetup } from '../plugin';

export type SecurityLicense = SecurityPluginSetup['license'];
Loading

0 comments on commit 85cdc49

Please sign in to comment.