-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into grouped-alert-table
- Loading branch information
Showing
563 changed files
with
6,879 additions
and
5,460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/kbn-apm-synthtrace/src/scenarios/unstructured_logs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 { LogDocument, log } from '@kbn/apm-synthtrace-client'; | ||
import { Scenario } from '../cli/scenario'; | ||
import { IndexTemplateName } from '../lib/logs/custom_logsdb_index_templates'; | ||
import { withClient } from '../lib/utils/with_client'; | ||
import { parseLogsScenarioOpts } from './helpers/logs_scenario_opts_parser'; | ||
import { getJavaLog, getWebLog } from './helpers/logs_mock_data'; | ||
|
||
const scenario: Scenario<LogDocument> = async (runOptions) => { | ||
const { isLogsDb } = parseLogsScenarioOpts(runOptions.scenarioOpts); | ||
return { | ||
bootstrap: async ({ logsEsClient }) => { | ||
if (isLogsDb) await logsEsClient.createIndexTemplate(IndexTemplateName.LogsDb); | ||
}, | ||
generate: ({ range, clients: { logsEsClient } }) => { | ||
const { logger } = runOptions; | ||
|
||
const datasetJavaLogs = (timestamp: number) => | ||
log.create({ isLogsDb }).dataset('java').message(getJavaLog()).timestamp(timestamp); | ||
|
||
const datasetWebLogs = (timestamp: number) => | ||
log.create({ isLogsDb }).dataset('web').message(getWebLog()).timestamp(timestamp); | ||
|
||
const logs = range | ||
.interval('1m') | ||
.rate(1) | ||
.generator((timestamp) => { | ||
return Array(200) | ||
.fill(0) | ||
.flatMap((_, index) => [datasetJavaLogs(timestamp), datasetWebLogs(timestamp)]); | ||
}); | ||
|
||
return withClient( | ||
logsEsClient, | ||
logger.perf('generating_logs', () => logs) | ||
); | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/kbn-eslint-plugin-eslint/rules/no_unsafe_js_yaml.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
meta: { | ||
fixable: 'code', | ||
schema: [], | ||
}, | ||
create(context) { | ||
const sourceCode = context.getSourceCode(); | ||
const jsYamlIdentifiers = new Set(); | ||
const isUnsafeMethod = (node) => node.name === 'load' || node.name === 'dump'; | ||
|
||
return { | ||
ImportDeclaration(node) { | ||
if (node.source.value === 'js-yaml') { | ||
node.specifiers.forEach((specifier) => { | ||
jsYamlIdentifiers.add(specifier.local.name); | ||
|
||
if (specifier.imported && isUnsafeMethod(specifier.imported)) { | ||
context.report({ | ||
node: specifier, | ||
message: | ||
'Use `safeLoad` instead of `load` and `safeDump` instead of `dump` from `js-yaml`.', | ||
fix(fixer) { | ||
const replacement = | ||
specifier.imported.name === 'load' | ||
? fixer.replaceText(specifier.imported, 'safeLoad') | ||
: fixer.replaceText(specifier.imported, 'safeDump'); | ||
return replacement; | ||
}, | ||
}); | ||
} | ||
}); | ||
} | ||
}, | ||
CallExpression(node) { | ||
const callee = node.callee; | ||
|
||
if (isUnsafeMethod(callee)) { | ||
const scope = sourceCode.getScope(node); | ||
const variable = scope.variables.find((v) => v.name === callee.name); | ||
|
||
if (variable && variable.defs.length) { | ||
const [def] = variable.defs; | ||
|
||
if (def?.parent?.source?.value === 'js-yaml') { | ||
context.report({ | ||
node: callee, | ||
message: | ||
'Use `safeLoad` instead of `load` and `safeDump` instead of `dump` from `js-yaml`.', | ||
fix(fixer) { | ||
const replacement = | ||
callee.name === 'load' | ||
? fixer.replaceText(callee, 'safeLoad') | ||
: fixer.replaceText(callee, 'safeDump'); | ||
return replacement; | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
if ( | ||
callee.type === 'MemberExpression' && | ||
isUnsafeMethod(callee.property) && | ||
jsYamlIdentifiers.has(callee.object.name) | ||
) { | ||
context.report({ | ||
node: callee.property, | ||
message: | ||
'Use `safeLoad` instead of `load` and `safeDump` instead of `dump` from `js-yaml`.', | ||
fix(fixer) { | ||
const replacement = | ||
callee.property.name === 'load' | ||
? fixer.replaceText(callee.property, 'safeLoad') | ||
: fixer.replaceText(callee.property, 'safeDump'); | ||
return replacement; | ||
}, | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
Oops, something went wrong.