Skip to content

Commit

Permalink
Merge branch 'main' into de-rule-cancel-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 23, 2022
2 parents eed917f + 55e42ce commit 8d93216
Show file tree
Hide file tree
Showing 225 changed files with 6,857 additions and 1,471 deletions.
2 changes: 1 addition & 1 deletion dev_docs/contributing/standards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Every team should be collecting telemetry metrics on it’s public API usage. Th

### APM

Kibana server and client are instrumented with APM node and APM RUM clients respectively, tracking serveral types of transactions by default, such as `page-load`, `request`, etc.
Kibana server and client are instrumented with APM node and APM RUM clients respectively, tracking several types of transactions by default, such as `page-load`, `request`, etc.
You may introduce custom transactions. Please refer to the [APM documentation](https://www.elastic.co/guide/en/apm/get-started/current/index.html) and follow these guidelines when doing so:

- Use dashed syntax for transaction types and names: `my-transaction-type` and `my-transaction-name`
Expand Down
2 changes: 1 addition & 1 deletion dev_docs/key_concepts/kibana_platform_plugin_intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ plugins to customize the Kibana experience. Examples of extension points are:
- core.overlays.showModal
- embeddables.registerEmbeddableFactory
- uiActions.registerAction
- core.saedObjects.registerType
- core.savedObjects.registerType

## Follow up material

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,31 @@ describe('validateFilePathInput', () => {
describe('windows', () => {
const os = OperatingSystem.WINDOWS;

it('does not warn on valid filenames', () => {
expect(
validateFilePathInput({
os,
value: 'C:\\Windows\\*\\FILENAME.EXE-1231205124.gz',
})
).not.toBeDefined();
expect(
validateFilePathInput({
os,
value: "C:\\Windows\\*\\test$ as2@13---12!@#A,DS.#$^&$!#~ 'as'd.华语.txt",
})
).toEqual(undefined);
});

it('warns on wildcard in file name at the end of the path', () => {
expect(validateFilePathInput({ os, value: 'c:\\path*.exe' })).toEqual(
FILENAME_WILDCARD_WARNING
);
expect(
validateFilePathInput({
os,
value: 'C:\\Windows\\*\\FILENAME.EXE-*.gz',
})
).toEqual(FILENAME_WILDCARD_WARNING);
});

it('warns on unix paths or non-windows paths', () => {
Expand All @@ -34,6 +55,7 @@ describe('validateFilePathInput', () => {
expect(validateFilePathInput({ os, value: 'c:\\path/opt' })).toEqual(FILEPATH_WARNING);
expect(validateFilePathInput({ os, value: '1242' })).toEqual(FILEPATH_WARNING);
expect(validateFilePathInput({ os, value: 'w12efdfa' })).toEqual(FILEPATH_WARNING);
expect(validateFilePathInput({ os, value: 'c:\\folder\\' })).toEqual(FILEPATH_WARNING);
});
});
describe('unix paths', () => {
Expand All @@ -42,8 +64,22 @@ describe('validateFilePathInput', () => {
? OperatingSystem.MAC
: OperatingSystem.LINUX;

it('does not warn on valid filenames', () => {
expect(validateFilePathInput({ os, value: '/opt/*/FILENAME.EXE-1231205124.gz' })).not.toEqual(
FILENAME_WILDCARD_WARNING
);
expect(
validateFilePathInput({
os,
value: "/opt/*/test$ as2@13---12!@#A,DS.#$^&$!#~ 'as'd.华语.txt",
})
).not.toEqual(FILENAME_WILDCARD_WARNING);
});
it('warns on wildcard in file name at the end of the path', () => {
expect(validateFilePathInput({ os, value: '/opt/bin*' })).toEqual(FILENAME_WILDCARD_WARNING);
expect(validateFilePathInput({ os, value: '/opt/FILENAME.EXE-*.gz' })).toEqual(
FILENAME_WILDCARD_WARNING
);
});

it('warns on windows paths', () => {
Expand All @@ -54,6 +90,7 @@ describe('validateFilePathInput', () => {
expect(validateFilePathInput({ os, value: 'opt/bin\\file.exe' })).toEqual(FILEPATH_WARNING);
expect(validateFilePathInput({ os, value: '1242' })).toEqual(FILEPATH_WARNING);
expect(validateFilePathInput({ os, value: 'w12efdfa' })).toEqual(FILEPATH_WARNING);
expect(validateFilePathInput({ os, value: '/folder/' })).toEqual(FILEPATH_WARNING);
});
});
});
Expand Down Expand Up @@ -577,50 +614,82 @@ describe('Unacceptable Mac/Linux exact paths', () => {
});
});

describe('Executable filenames with wildcard PATHS', () => {
describe('hasSimpleExecutableName', () => {
it('should return TRUE when MAC/LINUX wildcard paths have an executable name', () => {
const os =
parseInt((Math.random() * 2).toString(), 10) === 1
? OperatingSystem.MAC
: OperatingSystem.LINUX;

expect(
hasSimpleExecutableName({
os: OperatingSystem.LINUX,
os,
type: 'wildcard',
value: '/opt/*/app',
})
).toEqual(true);
expect(
hasSimpleExecutableName({
os: OperatingSystem.MAC,
os,
type: 'wildcard',
value: '/op*/**/app.dmg',
})
).toEqual(true);
});

it('should return TRUE when WINDOWS wildcards paths have a executable name', () => {
expect(
hasSimpleExecutableName({
os: OperatingSystem.WINDOWS,
os,
type: 'wildcard',
value: 'c:\\**\\path.exe',
value: "/sy*/test$ as2@13---12!@#A,DS.#$^&$!#~ 'as'd.华语.txt",
})
).toEqual(true);
});

it('should return FALSE when MAC/LINUX wildcard paths have a wildcard in executable name', () => {
const os =
parseInt((Math.random() * 2).toString(), 10) === 1
? OperatingSystem.MAC
: OperatingSystem.LINUX;

expect(
hasSimpleExecutableName({
os: OperatingSystem.LINUX,
os,
type: 'wildcard',
value: '/op/*/*pp',
})
).toEqual(false);
expect(
hasSimpleExecutableName({
os: OperatingSystem.MAC,
os,
type: 'wildcard',
value: '/op*/b**/ap.m**',
})
).toEqual(false);
});

it('should return TRUE when WINDOWS wildcards paths have a executable name', () => {
expect(
hasSimpleExecutableName({
os: OperatingSystem.WINDOWS,
type: 'wildcard',
value: 'c:\\**\\path.exe',
})
).toEqual(true);
expect(
hasSimpleExecutableName({
os: OperatingSystem.WINDOWS,
type: 'wildcard',
value: 'C:\\*\\file-name.path华语 1234.txt',
})
).toEqual(true);
expect(
hasSimpleExecutableName({
os: OperatingSystem.WINDOWS,
type: 'wildcard',
value: "C:\\*\\test$ as2@13---12!@#A,DS.#$^&$!#~ 'as'd.华语.txt",
})
).toEqual(true);
});

it('should return FALSE when WINDOWS wildcards paths have a wildcard in executable name', () => {
expect(
hasSimpleExecutableName({
Expand Down
25 changes: 8 additions & 17 deletions packages/kbn-securitysolution-utils/src/path_validations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ export const enum OperatingSystem {
export type EntryTypes = 'match' | 'wildcard' | 'match_any';
export type TrustedAppEntryTypes = Extract<EntryTypes, 'match' | 'wildcard'>;

/*
* regex to match executable names
* starts matching from the eol of the path
* file names with a single or multiple spaces (for spaced names)
* and hyphens and combinations of these that produce complex names
* such as:
* c:\home\lib\dmp.dmp
* c:\home\lib\my-binary-app-+/ some/ x/ dmp.dmp
* /home/lib/dmp.dmp
* /home/lib/my-binary-app+-\ some\ x\ dmp.dmp
*/
export const WIN_EXEC_PATH = /(\\[-\w]+|\\[-\w]+[\.]+[\w]+)$/i;
export const UNIX_EXEC_PATH = /(\/[-\w]+|\/[-\w]+[\.]+[\w]+)$/i;

export const validateFilePathInput = ({
os,
value = '',
Expand All @@ -70,7 +56,7 @@ export const validateFilePathInput = ({
}

if (isValidFilePath) {
if (!hasSimpleFileName) {
if (hasSimpleFileName !== undefined && !hasSimpleFileName) {
return FILENAME_WILDCARD_WARNING;
}
} else {
Expand All @@ -86,9 +72,14 @@ export const hasSimpleExecutableName = ({
os: OperatingSystem;
type: EntryTypes;
value: string;
}): boolean => {
}): boolean | undefined => {
const separator = os === OperatingSystem.WINDOWS ? '\\' : '/';
const lastString = value.split(separator).pop();
if (!lastString) {
return;
}
if (type === 'wildcard') {
return os === OperatingSystem.WINDOWS ? WIN_EXEC_PATH.test(value) : UNIX_EXEC_PATH.test(value);
return (lastString.split('*').length || lastString.split('?').length) === 1;
}
return true;
};
Expand Down
42 changes: 42 additions & 0 deletions x-pack/plugins/apm/common/utils/formatters/alert_url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 { stringify } from 'querystring';
import { ENVIRONMENT_ALL } from '../../environment_filter_values';

const format = ({
pathname,
query,
}: {
pathname: string;
query: Record<string, any>;
}): string => {
return `${pathname}?${stringify(query)}`;
};

export const getAlertUrlErrorCount = (
serviceName: string,
serviceEnv: string | undefined
) =>
format({
pathname: `/app/apm/services/${serviceName}/errors`,
query: {
environment: serviceEnv ?? ENVIRONMENT_ALL.value,
},
});
// This formatter is for TransactionDuration, TransactionErrorRate, and TransactionDurationAnomaly.
export const getAlertUrlTransaction = (
serviceName: string,
serviceEnv: string | undefined,
transactionType: string
) =>
format({
pathname: `/app/apm/services/${serviceName}`,
query: {
transactionType,
environment: serviceEnv ?? ENVIRONMENT_ALL.value,
},
});
1 change: 1 addition & 0 deletions x-pack/plugins/apm/common/utils/formatters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './formatters';
export * from './datetime';
export * from './duration';
export * from './size';
export * from './alert_url';
Loading

0 comments on commit 8d93216

Please sign in to comment.