Skip to content

Commit

Permalink
Sustainable Kibana Architecture: Move modules owned by `@elastic/secu…
Browse files Browse the repository at this point in the history
…rity-defend-workflows` (elastic#202840)
  • Loading branch information
gsoldevila authored Dec 13, 2024
1 parent 42704af commit 42af4e6
Show file tree
Hide file tree
Showing 509 changed files with 95 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .buildkite/scripts/pipelines/pull_request/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ const getPipeline = (filename: string, removeSteps = true) => {

if (
((await doAnyChangesMatch([
/^x-pack\/plugins\/osquery/,
/^x-pack\/platform\/plugins\/shared\/osquery/,
/^x-pack\/test\/osquery_cypress/,
/^x-pack\/plugins\/security_solution/,
])) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildkite-agent meta-data set "${BUILDKITE_JOB_ID}_is_test_execution_step" "true

source .buildkite/scripts/pipelines/security_solution_quality_gate/prepare_vault_entries.sh

cd x-pack/plugins/osquery
cd x-pack/platform/plugins/shared/osquery
set +e

export BK_ANALYTICS_API_KEY=$(vault_get security-solution-quality-gate serverless-cypress-defend-workflows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ source .buildkite/scripts/common/util.sh

echo --- Osquery OpenAPI Code Generation

(cd x-pack/plugins/osquery && yarn openapi:generate)
(cd x-pack/platform/plugins/shared/osquery && yarn openapi:generate)
check_for_changed_files "yarn openapi:generate" true
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/functional/osquery_cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export JOB=kibana-osquery-cypress

echo "--- Osquery Cypress tests"

cd x-pack/plugins/osquery
cd x-pack/platform/plugins/shared/osquery

set +e
yarn cypress:run; status=$?; yarn junit:merge || :; exit $status
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ buildkite-agent meta-data set "${BUILDKITE_JOB_ID}_is_test_execution_step" 'fals

echo "--- Osquery Cypress tests, burning changed specs (Chrome)"

yarn --cwd x-pack/plugins/osquery cypress:changed-specs-only
yarn --cwd x-pack/platform/plugins/shared/osquery cypress:changed-specs-only
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export JOB=kibana-osquery-cypress-serverless

echo "--- Security Osquery Serverless Cypress"

cd x-pack/plugins/osquery
cd x-pack/platform/plugins/shared/osquery

set +e
yarn cypress:serverless:run; status=$?; yarn junit:merge || :; exit $status
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ echo -e "\n[Security Solution OpenAPI Bundling] Elastic Assistant API\n"
(cd x-pack/packages/kbn-elastic-assistant-common && yarn openapi:bundle)

echo -e "\n[Security Solution OpenAPI Bundling] Osquery API\n"
(cd x-pack/plugins/osquery && yarn openapi:bundle)
(cd x-pack/platform/plugins/shared/osquery && yarn openapi:bundle)

check_for_changed_files "yarn openapi:bundle" true
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
],
plugins: ['react', '@typescript-eslint'],
files: ['x-pack/plugins/osquery/**/*.{js,mjs,ts,tsx}'],
files: ['x-pack/platform/plugins/shared/osquery/**/*.{js,mjs,ts,tsx}'],
rules: {
'padding-line-between-statements': [
'error',
Expand All @@ -1812,7 +1812,7 @@ module.exports = {
},
{
// typescript and javascript for front end react performance
files: ['x-pack/plugins/osquery/public/**/!(*.test).{js,mjs,ts,tsx}'],
files: ['x-pack/platform/plugins/shared/osquery/public/**/!(*.test).{js,mjs,ts,tsx}'],
plugins: ['react', 'react-perf'],
rules: {
'react-perf/jsx-no-new-object-as-prop': 'error',
Expand Down Expand Up @@ -2007,7 +2007,7 @@ module.exports = {
'src/dev/build/tasks/install_chromium.ts', // is importing "@kbn/screenshotting-plugin" (platform/private)

// @kbn/osquery-plugin could be categorised as Security, but @kbn/infra-plugin (observability) depends on it!
'x-pack/plugins/osquery/**',
'x-pack/platform/plugins/shared/osquery/**',

// For now, we keep the exception to let tests depend on anythying.
// Ideally, we need to classify the solution specific ones to reduce CI times
Expand Down
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ packages/kbn-apm-synthtrace @elastic/obs-ux-infra_services-team @elastic/obs-ux-
packages/kbn-apm-synthtrace-client @elastic/obs-ux-infra_services-team @elastic/obs-ux-logs-team
packages/kbn-apm-types @elastic/obs-ux-infra_services-team
packages/kbn-apm-utils @elastic/obs-ux-infra_services-team
packages/kbn-avc-banner @elastic/security-defend-workflows
packages/kbn-axe-config @elastic/kibana-qa
packages/kbn-babel-preset @elastic/kibana-operations
packages/kbn-babel-register @elastic/kibana-operations
Expand Down Expand Up @@ -619,6 +618,7 @@ src/platform/packages/private/kbn-esql-editor @elastic/kibana-esql
src/platform/packages/private/kbn-language-documentation @elastic/kibana-esql
src/platform/packages/shared/deeplinks/ml @elastic/ml-ui
src/platform/packages/shared/deeplinks/observability @elastic/obs-ux-management-team
src/platform/packages/shared/kbn-avc-banner @elastic/security-defend-workflows
src/platform/packages/shared/kbn-doc-links @elastic/docs
src/platform/packages/shared/kbn-esql-ast @elastic/kibana-esql
src/platform/packages/shared/kbn-esql-utils @elastic/kibana-esql
Expand Down Expand Up @@ -865,6 +865,7 @@ x-pack/platform/plugins/shared/inference @elastic/appex-ai-infra
x-pack/platform/plugins/shared/integration_assistant @elastic/security-scalability
x-pack/platform/plugins/shared/ml @elastic/ml-ui
x-pack/platform/plugins/shared/observability_solution/observability_ai_assistant @elastic/obs-ai-assistant
x-pack/platform/plugins/shared/osquery @elastic/security-defend-workflows
x-pack/plugins/actions @elastic/response-ops
x-pack/plugins/alerting @elastic/response-ops
x-pack/plugins/asset_inventory @elastic/kibana-cloud-security-posture
Expand Down Expand Up @@ -932,7 +933,6 @@ x-pack/plugins/observability_solution/observability_shared @elastic/observabilit
x-pack/plugins/observability_solution/profiling @elastic/obs-ux-infra_services-team
x-pack/plugins/observability_solution/profiling_data_access @elastic/obs-ux-infra_services-team
x-pack/plugins/observability_solution/slo @elastic/obs-ux-management-team
x-pack/plugins/osquery @elastic/security-defend-workflows
x-pack/plugins/painless_lab @elastic/kibana-management
x-pack/plugins/remote_clusters @elastic/kibana-management
x-pack/plugins/reporting @elastic/appex-sharedux
Expand Down
2 changes: 1 addition & 1 deletion .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ paths-ignore:
- x-pack/plugins/lists/scripts
- x-pack/plugins/lists/server/scripts
- x-pack/plugins/observability_solution/*/scripts
- x-pack/plugins/osquery/scripts
- x-pack/platform/plugins/shared/osquery/scripts
- x-pack/plugins/rule_registry/scripts
- x-pack/plugins/security_solution/scripts
- x-pack/solutions/security/plugins/threat_intelligence/scripts
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ npm-debug.log*
# transpiled cypress config
x-pack/plugins/fleet/cypress.config.d.ts
x-pack/plugins/fleet/cypress.config.js
x-pack/plugins/osquery/cypress.config.d.ts
x-pack/plugins/osquery/cypress.config.js
x-pack/platform/plugins/shared/osquery/cypress.config.d.ts
x-pack/platform/plugins/shared/osquery/cypress.config.js
x-pack/plugins/enterprise_search/cypress.config.d.ts
x-pack/plugins/enterprise_search/cypress.config.js
x-pack/plugins/security_solution/public/management/cypress.config.d.ts
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"alertingTypes": "packages/kbn-alerting-types",
"apmOss": "src/plugins/apm_oss",
"autocomplete": "packages/kbn-securitysolution-autocomplete/src",
"avcBanner": "packages/kbn-avc-banner/src",
"avcBanner": "src/platform/packages/shared/kbn-avc-banner/src",
"bfetch": "src/plugins/bfetch",
"bfetchError": "packages/kbn-bfetch-error",
"cases": ["packages/kbn-cases-components"],
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ Elastic.
|A plugin that contains components and utilities shared by all Observability plugins.
|{kib-repo}blob/{branch}/x-pack/plugins/osquery/README.md[osquery]
|{kib-repo}blob/{branch}/x-pack/platform/plugins/shared/osquery/README.md[osquery]
|This plugin adds extended support to Security Solution Fleet Osquery integration
Expand Down
2 changes: 1 addition & 1 deletion oas_docs/scripts/merge_ess_oas.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const { REPO_ROOT } = require('@kbn/repo-info');
`${REPO_ROOT}/packages/kbn-securitysolution-exceptions-common/docs/openapi/ess/*.schema.yaml`,
`${REPO_ROOT}/packages/kbn-securitysolution-endpoint-exceptions-common/docs/openapi/ess/*.schema.yaml`,
`${REPO_ROOT}/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/ess/*.schema.yaml`,
`${REPO_ROOT}/x-pack/plugins/osquery/docs/openapi/ess/*.schema.yaml`,
`${REPO_ROOT}/x-pack/platform/plugins/shared/osquery/docs/openapi/ess/*.schema.yaml`,
],
outputFilePath: `${REPO_ROOT}/oas_docs/output/kibana.yaml`,
options: {
Expand Down
2 changes: 1 addition & 1 deletion oas_docs/scripts/merge_serverless_oas.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { REPO_ROOT } = require('@kbn/repo-info');
`${REPO_ROOT}/packages/kbn-securitysolution-exceptions-common/docs/openapi/serverless/*.schema.yaml`,
`${REPO_ROOT}/packages/kbn-securitysolution-endpoint-exceptions-common/docs/openapi/serverless/*.schema.yaml`,
`${REPO_ROOT}/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/serverless/*.schema.yaml`,
`${REPO_ROOT}/x-pack/plugins/osquery/docs/openapi/serverless/*.schema.yaml`,
`${REPO_ROOT}/x-pack/platform/plugins/shared/osquery/docs/openapi/serverless/*.schema.yaml`,
],
outputFilePath: `${REPO_ROOT}/oas_docs/output/kibana.serverless.yaml`,
options: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"@kbn/application-usage-test-plugin": "link:x-pack/test/usage_collection/plugins/application_usage_test",
"@kbn/asset-inventory-plugin": "link:x-pack/plugins/asset_inventory",
"@kbn/audit-log-plugin": "link:x-pack/test/security_api_integration/plugins/audit_log",
"@kbn/avc-banner": "link:packages/kbn-avc-banner",
"@kbn/avc-banner": "link:src/platform/packages/shared/kbn-avc-banner",
"@kbn/banners-plugin": "link:x-pack/plugins/banners",
"@kbn/bfetch-error": "link:packages/kbn-bfetch-error",
"@kbn/bfetch-explorer-plugin": "link:examples/bfetch_explorer",
Expand Down Expand Up @@ -715,7 +715,7 @@
"@kbn/open-telemetry-instrumented-plugin": "link:test/common/plugins/otel_metrics",
"@kbn/openapi-common": "link:packages/kbn-openapi-common",
"@kbn/osquery-io-ts-types": "link:src/platform/packages/shared/kbn-osquery-io-ts-types",
"@kbn/osquery-plugin": "link:x-pack/plugins/osquery",
"@kbn/osquery-plugin": "link:x-pack/platform/plugins/shared/osquery",
"@kbn/paertial-results-example-plugin": "link:examples/partial_results_example",
"@kbn/painless-lab-plugin": "link:x-pack/plugins/painless_lab",
"@kbn/palettes": "link:packages/kbn-palettes",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-avc-banner'],
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/packages/shared/kbn-avc-banner'],
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
"@kbn/asset-inventory-plugin/*": ["x-pack/plugins/asset_inventory/*"],
"@kbn/audit-log-plugin": ["x-pack/test/security_api_integration/plugins/audit_log"],
"@kbn/audit-log-plugin/*": ["x-pack/test/security_api_integration/plugins/audit_log/*"],
"@kbn/avc-banner": ["packages/kbn-avc-banner"],
"@kbn/avc-banner/*": ["packages/kbn-avc-banner/*"],
"@kbn/avc-banner": ["src/platform/packages/shared/kbn-avc-banner"],
"@kbn/avc-banner/*": ["src/platform/packages/shared/kbn-avc-banner/*"],
"@kbn/axe-config": ["packages/kbn-axe-config"],
"@kbn/axe-config/*": ["packages/kbn-axe-config/*"],
"@kbn/babel-preset": ["packages/kbn-babel-preset"],
Expand Down Expand Up @@ -1372,8 +1372,8 @@
"@kbn/optimizer-webpack-helpers/*": ["packages/kbn-optimizer-webpack-helpers/*"],
"@kbn/osquery-io-ts-types": ["src/platform/packages/shared/kbn-osquery-io-ts-types"],
"@kbn/osquery-io-ts-types/*": ["src/platform/packages/shared/kbn-osquery-io-ts-types/*"],
"@kbn/osquery-plugin": ["x-pack/plugins/osquery"],
"@kbn/osquery-plugin/*": ["x-pack/plugins/osquery/*"],
"@kbn/osquery-plugin": ["x-pack/platform/plugins/shared/osquery"],
"@kbn/osquery-plugin/*": ["x-pack/platform/plugins/shared/osquery/*"],
"@kbn/paertial-results-example-plugin": ["examples/partial_results_example"],
"@kbn/paertial-results-example-plugin/*": ["examples/partial_results_example/*"],
"@kbn/painless-lab-plugin": ["x-pack/plugins/painless_lab"],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"packages/observability/logs_overview/src/components"
],
"xpack.osquery": [
"plugins/osquery"
"platform/plugins/shared/osquery"
],
"xpack.painlessLab": "plugins/painless_lab",
"xpack.profiling": [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ yarn kbn bootstrap
node scripts/build_kibana_platform_plugins

# launch the cypress test runner
cd x-pack/plugins/osquery
cd x-pack/platform/plugins/shared/osquery
yarn cypress:run-as-ci
```
#### FTR + Interactive
Expand All @@ -51,7 +51,7 @@ yarn kbn bootstrap
node scripts/build_kibana_platform_plugins

# launch the cypress test runner
cd x-pack/plugins/osquery
cd x-pack/platform/plugins/shared/osquery
yarn cypress:open-as-ci
```

Expand Down Expand Up @@ -98,16 +98,16 @@ We use es_archiver to manage the data that our Cypress tests need.

1. Set up a clean instance of kibana and elasticsearch (if this is not possible, try to clean/minimize the data that you are going to archive).
2. With the kibana and elasticsearch instance up and running, create the data that you need for your test.
3. When you are sure that you have all the data you need run the following command from: `x-pack/plugins/osquery`
3. When you are sure that you have all the data you need run the following command from: `x-pack/platform/plugins/shared/osquery`

```sh
node ../../../scripts/es_archiver save <nameOfTheFolderWhereDataIsSaved> <indexPatternsToBeSaved> --dir ../../test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://<elasticsearchUsername>:<elasticsearchPassword>@<elasticsearchHost>:<elasticsearchPort>
node ../../../../../scripts/es_archiver save <nameOfTheFolderWhereDataIsSaved> <indexPatternsToBeSaved> --dir ../../test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://<elasticsearchUsername>:<elasticsearchPassword>@<elasticsearchHost>:<elasticsearchPort>
```

Example:

```sh
node ../../../scripts/es_archiver save custom_rules ".kibana",".siem-signal*" --dir ../../test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://elastic:changeme@localhost:9220
node ../../../../../scripts/es_archiver save custom_rules ".kibana",".siem-signal*" --dir ../../test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://elastic:changeme@localhost:9220
```

Note that the command will create the folder if it does not exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ export const getCypressBaseConfig = (
): Cypress.ConfigOptions =>
merge(
{
reporter: '../../../node_modules/cypress-multi-reporters',
reporter: '../../../../../node_modules/cypress-multi-reporters',
reporterOptions: {
configFile: './cypress/reporter_config.json',
configFile: './reporter_config.json',
},

defaultCommandTimeout: 60000,
execTimeout: 120000,
pageLoadTimeout: 12000,
screenshotsFolder: '../../../target/kibana-osquery/cypress/screenshots',
screenshotsFolder: '../../../../../target/kibana-osquery/cypress/screenshots',
trashAssetsBeforeRuns: false,
video: true,
videosFolder: '../../../target/kibana-osquery/cypress/videos',
videosFolder: '../../../../../target/kibana-osquery/cypress/videos',

retries: {
runMode: 1,
Expand All @@ -53,7 +53,7 @@ export const getCypressBaseConfig = (
},

e2e: {
specPattern: './cypress/e2e/**/*.cy.ts',
specPattern: './e2e/**/*.cy.ts',
experimentalRunAllSpecs: true,
experimentalMemoryManagement: true,
numTestsKeptInMemory: 3,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"reporterEnabled": "mochawesome, mocha-junit-reporter",
"reporterOptions": {
"html": false,
"json": true,
"mochaFile": "../../../../../target/kibana-osquery/cypress/results/TEST-osquery-cypress-[hash].xml",
"overwrite": false,
"reportDir": "../../../../../target/kibana-osquery/cypress/results"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const runKbnArchiverScript = (
hostname: HOSTNAME,
configport: PORT,
} = Cypress.env();
const script = `node ../../../scripts/kbn_archiver.js --space ${space} --kibana-url http://${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}@${HOSTNAME}:${PORT} ${method} ./cypress/fixtures/saved_objects/${fileName}.ndjson`;
const script = `node ../../../../../scripts/kbn_archiver.js --space ${space} --kibana-url http://${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}@${HOSTNAME}:${PORT} ${method} ./cypress/fixtures/saved_objects/${fileName}.ndjson`;

cy.exec(script, { env: { NODE_TLS_REJECT_UNAUTHORIZED: 1 } });
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../../../tsconfig.base.json",
"include": [
"**/*",
"./cypress.config.ts",
"./serverless_cypress.config.ts",
"./serverless_cypress_qa.config.ts",
"../../../test_serverless/shared/lib",
"../../../../../test_serverless/shared/lib",
],
"exclude": [
"target/**/*",
"../../../test_serverless/shared/lib/security/default_http_headers.ts"
"../../../../../test_serverless/shared/lib/security/default_http_headers.ts"
],
"compilerOptions": {
"outDir": "target/types",
Expand All @@ -22,7 +22,7 @@
"kbn_references": [
"@kbn/test-suites-serverless",
{
"path": "../../../test/security_solution_cypress/cypress/tsconfig.json"
"path": "../../../../../test/security_solution_cypress/cypress/tsconfig.json"
},
"@kbn/cypress-config",
// cypress projects that are nested inside of other ts project use code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/x-pack/plugins/osquery'],
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/plugins/osquery',
rootDir: '../../../../..',
roots: ['<rootDir>/x-pack/platform/plugins/shared/osquery'],
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/platform/plugins/shared/osquery',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/osquery/{common,public,server}/**/*.{ts,tsx}'],
collectCoverageFrom: [
'<rootDir>/x-pack/platform/plugins/shared/osquery/{common,public,server}/**/*.{ts,tsx}',
],
};
File renamed without changes.
Loading

0 comments on commit 42af4e6

Please sign in to comment.