Skip to content

Commit edcdf21

Browse files
Merge branch 'master' into 58621-alert-rate
2 parents ad56872 + 2b9dc43 commit edcdf21

514 files changed

Lines changed: 4993 additions & 8263 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,7 @@
195195
/x-pack/test/detection_engine_api_integration @elastic/siem
196196
/x-pack/test/api_integration/apis/siem @elastic/siem
197197
/x-pack/plugins/case @elastic/siem
198+
199+
# Security Intelligence And Analytics
200+
/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules @elastic/security-intelligence-analytics
201+
/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules @elastic/security-intelligence-analytics

docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export interface SavedObjectsServiceSetup
1616

1717
When plugins access the Saved Objects client, a new client is created using the factory provided to `setClientFactory` and wrapped by all wrappers registered through `addClientWrapper`<!-- -->.
1818

19+
All the setup APIs will throw if called after the service has started, and therefor cannot be used from legacy plugin code. Legacy plugins should use the legacy savedObject service until migrated.
20+
1921
## Example 1
2022

2123

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeMappingDefinition](./kibana-plugin-server.savedobjectstypemappingdefinition.md) &gt; [dynamic](./kibana-plugin-server.savedobjectstypemappingdefinition.dynamic.md)
4+
5+
## SavedObjectsTypeMappingDefinition.dynamic property
6+
7+
The dynamic property of the mapping. either `false` or 'strict'. Defaults to strict
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
dynamic?: false | 'strict';
13+
```

docs/development/core/server/kibana-plugin-server.savedobjectstypemappingdefinition.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ const typeDefinition: SavedObjectsTypeMappingDefinition = {
4141

4242
| Property | Type | Description |
4343
| --- | --- | --- |
44-
| [properties](./kibana-plugin-server.savedobjectstypemappingdefinition.properties.md) | <code>SavedObjectsMappingProperties</code> | |
44+
| [dynamic](./kibana-plugin-server.savedobjectstypemappingdefinition.dynamic.md) | <code>false &#124; 'strict'</code> | The dynamic property of the mapping. either <code>false</code> or 'strict'. Defaults to strict |
45+
| [properties](./kibana-plugin-server.savedobjectstypemappingdefinition.properties.md) | <code>SavedObjectsMappingProperties</code> | The underlying properties of the type mapping |
4546

docs/development/core/server/kibana-plugin-server.savedobjectstypemappingdefinition.properties.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## SavedObjectsTypeMappingDefinition.properties property
66

7+
The underlying properties of the type mapping
8+
79
<b>Signature:</b>
810

911
```typescript

src/cli/serve/integration_tests/reload_logging_config.test.ts

Lines changed: 156 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -84,180 +84,174 @@ function createConfigManager(configPath: string) {
8484
}
8585

8686
describe('Server logging configuration', function() {
87-
let child: Child.ChildProcess;
87+
let child: undefined | Child.ChildProcess;
88+
8889
beforeEach(() => {
8990
Fs.mkdirSync(tempDir, { recursive: true });
9091
});
9192

9293
afterEach(async () => {
9394
if (child !== undefined) {
94-
child.kill();
95-
// wait for child to be killed otherwise jest complains that process not finished
96-
await new Promise(res => setTimeout(res, 1000));
95+
const exitPromise = new Promise(resolve => child?.once('exit', resolve));
96+
child.kill('SIGKILL');
97+
await exitPromise;
9798
}
99+
98100
Del.sync(tempDir, { force: true });
99101
});
100102

101-
const isWindows = /^win/.test(process.platform);
102-
if (isWindows) {
103+
if (process.platform.startsWith('win')) {
103104
it('SIGHUP is not a feature of Windows.', () => {
104105
// nothing to do for Windows
105106
});
106-
} else {
107-
describe('legacy logging', () => {
108-
it(
109-
'should be reloadable via SIGHUP process signaling',
110-
async function() {
111-
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
112-
Fs.copyFileSync(legacyConfig, configFilePath);
113-
114-
child = Child.spawn(process.execPath, [
115-
kibanaPath,
116-
'--oss',
117-
'--config',
118-
configFilePath,
119-
'--verbose',
120-
]);
121-
122-
const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
123-
map(messages =>
124-
String(messages)
125-
.split('\n')
126-
.filter(Boolean)
127-
)
128-
);
129-
130-
await message$
131-
.pipe(
132-
// We know the sighup handler will be registered before this message logged
133-
filter(messages => messages.some(m => m.includes('setting up root'))),
134-
take(1)
135-
)
136-
.toPromise();
137-
138-
const lastMessage = await message$.pipe(take(1)).toPromise();
139-
expect(containsJsonOnly(lastMessage)).toBe(true);
140-
141-
createConfigManager(configFilePath).modify(oldConfig => {
142-
oldConfig.logging.json = false;
143-
return oldConfig;
144-
});
145-
146-
child.kill('SIGHUP');
147-
148-
await message$
149-
.pipe(
150-
filter(messages => !containsJsonOnly(messages)),
151-
take(1)
152-
)
153-
.toPromise();
154-
},
155-
minute
156-
);
157-
158-
it(
159-
'should recreate file handle on SIGHUP',
160-
async function() {
161-
const logPath = Path.resolve(tempDir, 'kibana.log');
162-
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');
163-
164-
child = Child.spawn(process.execPath, [
165-
kibanaPath,
166-
'--oss',
167-
'--config',
168-
legacyConfig,
169-
'--logging.dest',
170-
logPath,
171-
'--verbose',
172-
]);
173-
174-
await watchFileUntil(logPath, /setting up root/, 30 * second);
175-
// once the server is running, archive the log file and issue SIGHUP
176-
Fs.renameSync(logPath, logPathArchived);
177-
child.kill('SIGHUP');
178-
179-
await watchFileUntil(
180-
logPath,
181-
/Reloaded logging configuration due to SIGHUP/,
182-
30 * second
183-
);
184-
},
185-
minute
186-
);
187-
});
188-
189-
describe('platform logging', () => {
190-
it(
191-
'should be reloadable via SIGHUP process signaling',
192-
async function() {
193-
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
194-
Fs.copyFileSync(configFileLogConsole, configFilePath);
195-
196-
child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);
197-
198-
const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
199-
map(messages =>
200-
String(messages)
201-
.split('\n')
202-
.filter(Boolean)
203-
)
204-
);
205-
206-
await message$
207-
.pipe(
208-
// We know the sighup handler will be registered before this message logged
209-
filter(messages => messages.some(m => m.includes('setting up root'))),
210-
take(1)
211-
)
212-
.toPromise();
213-
214-
const lastMessage = await message$.pipe(take(1)).toPromise();
215-
expect(containsJsonOnly(lastMessage)).toBe(true);
216-
217-
createConfigManager(configFilePath).modify(oldConfig => {
218-
oldConfig.logging.appenders.console.layout.kind = 'pattern';
219-
return oldConfig;
220-
});
221-
child.kill('SIGHUP');
222-
223-
await message$
224-
.pipe(
225-
filter(messages => !containsJsonOnly(messages)),
226-
take(1)
227-
)
228-
.toPromise();
229-
},
230-
30 * second
231-
);
232-
it(
233-
'should recreate file handle on SIGHUP',
234-
async function() {
235-
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
236-
Fs.copyFileSync(configFileLogFile, configFilePath);
237-
238-
const logPath = Path.resolve(tempDir, 'kibana.log');
239-
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');
240-
241-
createConfigManager(configFilePath).modify(oldConfig => {
242-
oldConfig.logging.appenders.file.path = logPath;
243-
return oldConfig;
244-
});
245-
246-
child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);
247-
248-
await watchFileUntil(logPath, /setting up root/, 30 * second);
249-
// once the server is running, archive the log file and issue SIGHUP
250-
Fs.renameSync(logPath, logPathArchived);
251-
child.kill('SIGHUP');
252-
253-
await watchFileUntil(
254-
logPath,
255-
/Reloaded logging configuration due to SIGHUP/,
256-
30 * second
257-
);
258-
},
259-
minute
260-
);
261-
});
107+
return;
262108
}
109+
110+
describe('legacy logging', () => {
111+
it(
112+
'should be reloadable via SIGHUP process signaling',
113+
async function() {
114+
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
115+
Fs.copyFileSync(legacyConfig, configFilePath);
116+
117+
child = Child.spawn(process.execPath, [
118+
kibanaPath,
119+
'--oss',
120+
'--config',
121+
configFilePath,
122+
'--verbose',
123+
]);
124+
125+
const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
126+
map(messages =>
127+
String(messages)
128+
.split('\n')
129+
.filter(Boolean)
130+
)
131+
);
132+
133+
await message$
134+
.pipe(
135+
// We know the sighup handler will be registered before this message logged
136+
filter(messages => messages.some(m => m.includes('setting up root'))),
137+
take(1)
138+
)
139+
.toPromise();
140+
141+
const lastMessage = await message$.pipe(take(1)).toPromise();
142+
expect(containsJsonOnly(lastMessage)).toBe(true);
143+
144+
createConfigManager(configFilePath).modify(oldConfig => {
145+
oldConfig.logging.json = false;
146+
return oldConfig;
147+
});
148+
149+
child.kill('SIGHUP');
150+
151+
await message$
152+
.pipe(
153+
filter(messages => !containsJsonOnly(messages)),
154+
take(1)
155+
)
156+
.toPromise();
157+
},
158+
minute
159+
);
160+
161+
it(
162+
'should recreate file handle on SIGHUP',
163+
async function() {
164+
const logPath = Path.resolve(tempDir, 'kibana.log');
165+
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');
166+
167+
child = Child.spawn(process.execPath, [
168+
kibanaPath,
169+
'--oss',
170+
'--config',
171+
legacyConfig,
172+
'--logging.dest',
173+
logPath,
174+
'--verbose',
175+
]);
176+
177+
await watchFileUntil(logPath, /setting up root/, 30 * second);
178+
// once the server is running, archive the log file and issue SIGHUP
179+
Fs.renameSync(logPath, logPathArchived);
180+
child.kill('SIGHUP');
181+
182+
await watchFileUntil(logPath, /Reloaded logging configuration due to SIGHUP/, 30 * second);
183+
},
184+
minute
185+
);
186+
});
187+
188+
describe('platform logging', () => {
189+
it(
190+
'should be reloadable via SIGHUP process signaling',
191+
async function() {
192+
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
193+
Fs.copyFileSync(configFileLogConsole, configFilePath);
194+
195+
child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);
196+
197+
const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
198+
map(messages =>
199+
String(messages)
200+
.split('\n')
201+
.filter(Boolean)
202+
)
203+
);
204+
205+
await message$
206+
.pipe(
207+
// We know the sighup handler will be registered before this message logged
208+
filter(messages => messages.some(m => m.includes('setting up root'))),
209+
take(1)
210+
)
211+
.toPromise();
212+
213+
const lastMessage = await message$.pipe(take(1)).toPromise();
214+
expect(containsJsonOnly(lastMessage)).toBe(true);
215+
216+
createConfigManager(configFilePath).modify(oldConfig => {
217+
oldConfig.logging.appenders.console.layout.kind = 'pattern';
218+
return oldConfig;
219+
});
220+
child.kill('SIGHUP');
221+
222+
await message$
223+
.pipe(
224+
filter(messages => !containsJsonOnly(messages)),
225+
take(1)
226+
)
227+
.toPromise();
228+
},
229+
30 * second
230+
);
231+
it(
232+
'should recreate file handle on SIGHUP',
233+
async function() {
234+
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
235+
Fs.copyFileSync(configFileLogFile, configFilePath);
236+
237+
const logPath = Path.resolve(tempDir, 'kibana.log');
238+
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');
239+
240+
createConfigManager(configFilePath).modify(oldConfig => {
241+
oldConfig.logging.appenders.file.path = logPath;
242+
return oldConfig;
243+
});
244+
245+
child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);
246+
247+
await watchFileUntil(logPath, /setting up root/, 30 * second);
248+
// once the server is running, archive the log file and issue SIGHUP
249+
Fs.renameSync(logPath, logPathArchived);
250+
child.kill('SIGHUP');
251+
252+
await watchFileUntil(logPath, /Reloaded logging configuration due to SIGHUP/, 30 * second);
253+
},
254+
minute
255+
);
256+
});
263257
});

src/core/MIGRATION_EXAMPLES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,4 +917,10 @@ Would be converted to:
917917
918918
```typescript
919919
const migration: SavedObjectMigrationFn = (doc, { log }) => {...}
920-
```
920+
```
921+
922+
### Remarks
923+
924+
The `registerType` API will throw if called after the service has started, and therefor cannot be used from
925+
legacy plugin code. Legacy plugins should use the legacy savedObjects service and the legacy way to register
926+
saved object types until migrated.

0 commit comments

Comments
 (0)