Skip to content

Commit

Permalink
Merge branch 'master' into migrate-siem-detection-engine-rule-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Oct 5, 2021
2 parents d8b75db + 68afc9b commit d675e9e
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 91 deletions.
28 changes: 0 additions & 28 deletions docs/settings/reporting-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ You can configure `xpack.reporting` settings in your `kibana.yml` to:

* <<general-reporting-settings,Enable the {report-features}>>
* <<encryption-keys,Configure the encryption key>>
* <<report-indices,Configure the reporting index>>
* <<reporting-kibana-server-settings,Control how the {report-features} communicate with the {kib} server>>
* <<reporting-job-queue-settings,Manage background jobs>>
* <<reporting-capture-settings,Capture screenshots>>
Expand Down Expand Up @@ -47,33 +46,6 @@ The static encryption key for reporting. Use an alphanumeric text string that is
xpack.reporting.encryptionKey: "something_secret"
--------------------------------------------------------------------------------

[float]
[[report-indices]]
==== Reporting index setting



`xpack.reporting.index`::
deprecated:[7.11.0,This setting will be removed in 8.0.0.] Multitenancy by changing `kibana.index` is unsupported starting in 8.0.0. For more details, refer to https://ela.st/kbn-remove-legacy-multitenancy[8.0 Breaking Changes]. When you divide workspaces in an Elastic cluster using multiple {kib} instances with a different `kibana.index` setting per instance, you must set a unique `xpack.reporting.index` setting per `kibana.index`. Otherwise, report generation periodically fails if a report is queued through an instance with one `kibana.index` setting, and an instance with a different `kibana.index` attempts to claim the job. Reporting uses a weekly index in {es} to store the reporting job and the report content. The index is automatically created if it does not already exist. Configure a unique value for `xpack.reporting.index`, beginning with `.reporting-`, for every {kib} instance that has a unique <<kibana-index, `kibana.index`>> setting. Defaults to `.reporting`.

{kib} instance A:
[source,yaml]
--------------------------------------------------------------------------------
kibana.index: ".kibana-a"
xpack.reporting.index: ".reporting-a"
xpack.reporting.encryptionKey: "something_secret"
--------------------------------------------------------------------------------

{kib} instance B:
[source,yaml]
--------------------------------------------------------------------------------
kibana.index: ".kibana-b"
xpack.reporting.index: ".reporting-b"
xpack.reporting.encryptionKey: "something_secret"
--------------------------------------------------------------------------------

NOTE: If security is enabled, the `xpack.reporting.index` setting should begin with `.reporting-` for the `kibana_system` role to have the necessary privileges over the index.

[float]
[[reporting-kibana-server-settings]]
==== {kib} server settings
Expand Down
50 changes: 0 additions & 50 deletions docs/setup/configuring-reporting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -148,56 +148,6 @@ reporting_user:
- "cn=Bill Murray,dc=example,dc=com"
--------------------------------------------------------------------------------

[float]
==== Grant access with a custom index

If you are using a custom index, the `xpack.reporting.index` setting must begin with `.reporting-*`. The default {kib} system user has `all` privileges against the `.reporting-*` pattern of indices.

If you use a different pattern for the `xpack.reporting.index` setting, you must create a custom `kibana_system` user with appropriate access to the index.

NOTE: In the next major version of Kibana, granting access with a custom index is unsupported.

. Create the reporting role.

.. Open the main menu, then click *Stack Management*.

.. Click *Roles > Create role*.

. Specify the role settings.

.. Enter the *Role name*. For example, `custom-reporting-user`.

.. From the *Indices* dropdown, select the custom index.

.. From the *Privileges* dropdown, select *all*.

.. Click *Add Kibana privilege*.

.. Select one or more *Spaces* that you want to grant reporting privileges to.

.. Click *Customize*, then click *Analytics*.

.. Next to each application you want to grant reporting privileges to, click *All*.

.. Click *Add {kib} privilege*, then click *Create role*.

. Assign the reporting role to a user.

.. Open the main menu, then click *Stack Management*.

.. Click *Users*, then click the user you want to assign the reporting role to.

.. From the *Roles* dropdown, select *kibana_system* and *custom-reporting-user*.

.. Click *Update user*.

. Configure {kib} to use the new account.
+
[source,js]
--------------------------------------------------------------------------------
elasticsearch.username: 'custom_kibana_system'
--------------------------------------------------------------------------------

[float]
[[securing-reporting]]
=== Secure the reporting endpoints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ kibana_vars=(
xpack.reporting.csv.useByteOrderMarkEncoding
xpack.reporting.enabled
xpack.reporting.encryptionKey
xpack.reporting.index
xpack.reporting.kibanaApp
xpack.reporting.kibanaServer.hostname
xpack.reporting.kibanaServer.port
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/es_ui_shared/public/request/use_request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,24 @@ describe('useRequest hook', () => {
expect(getSendRequestSpy().callCount).toBe(2);
});

it(`changing pollIntervalMs to undefined cancels the poll`, async () => {
const { setupErrorRequest, setErrorResponse, completeRequest, getSendRequestSpy } = helpers;
// Send initial request.
setupErrorRequest({ pollIntervalMs: REQUEST_TIME });

// Setting the poll to undefined will cancel subsequent requests.
setErrorResponse({ pollIntervalMs: undefined });

// Complete initial request.
await completeRequest();

// If there were another scheduled poll request, this would complete it.
await completeRequest();

// But because we canceled the poll, we only see 1 request instead of 2.
expect(getSendRequestSpy().callCount).toBe(1);
});

it('when the path changes after a request is scheduled, the scheduled request is sent with that path', async () => {
const {
setupSuccessRequest,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/reporting/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

export const PLUGIN_ID = 'reporting';

export const REPORTING_SYSTEM_INDEX = '.reporting';

export const JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY =
'xpack.reporting.jobCompletionNotifications';

Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/reporting/server/config/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ describe('Reporting Config Schema', () => {
},
"enabled": true,
"encryptionKey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"index": ".reporting",
"kibanaServer": Object {},
"poll": Object {
"jobCompletionNotifier": Object {
Expand Down Expand Up @@ -189,7 +188,6 @@ describe('Reporting Config Schema', () => {
"useByteOrderMarkEncoding": false,
},
"enabled": true,
"index": ".reporting",
"kibanaServer": Object {},
"poll": Object {
"jobCompletionNotifier": Object {
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/reporting/server/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ const RolesSchema = schema.object({
allow: schema.arrayOf(schema.string(), { defaultValue: ['reporting_user'] }),
});

const IndexSchema = schema.string({ defaultValue: '.reporting' });

// Browser side polling: job completion notifier, management table auto-refresh
// NOTE: can not use schema.duration, a bug prevents it being passed to the browser correctly
const PollSchema = schema.object({
Expand All @@ -178,7 +176,6 @@ export const ConfigSchema = schema.object({
csv: CsvSchema,
encryptionKey: EncryptionKeySchema,
roles: RolesSchema,
index: IndexSchema,
poll: PollSchema,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('CSV Execute Job', function () {
stream = { write: jest.fn((chunk) => (content += chunk)) } as unknown as typeof stream;
configGetStub = sinon.stub();
configGetStub.withArgs('queue', 'timeout').returns(moment.duration('2m'));
configGetStub.withArgs('index').returns('.reporting-foo-test');
configGetStub.withArgs('encryptionKey').returns(encryptionKey);
configGetStub.withArgs('csv', 'maxSizeBytes').returns(1024 * 1000); // 1mB
configGetStub.withArgs('csv', 'scroll').returns({});
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/reporting/server/lib/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IndexResponse, UpdateResponse } from '@elastic/elasticsearch/api/types'
import { ElasticsearchClient } from 'src/core/server';
import { LevelLogger, statuses } from '../';
import { ReportingCore } from '../../';
import { ILM_POLICY_NAME } from '../../../common/constants';
import { ILM_POLICY_NAME, REPORTING_SYSTEM_INDEX } from '../../../common/constants';
import { JobStatus, ReportOutput, ReportSource } from '../../../common/types';
import { ReportTaskParams } from '../tasks';
import { Report, ReportDocument, SavedReport } from './';
Expand Down Expand Up @@ -87,7 +87,7 @@ export class ReportingStore {
constructor(private reportingCore: ReportingCore, private logger: LevelLogger) {
const config = reportingCore.getConfig();

this.indexPrefix = config.get('index');
this.indexPrefix = REPORTING_SYSTEM_INDEX;
this.indexInterval = config.get('queue', 'indexInterval');
this.logger = logger.clone(['store']);
}
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/reporting/server/routes/lib/jobs_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { UnwrapPromise } from '@kbn/utility-types';
import { ElasticsearchClient } from 'src/core/server';
import { PromiseType } from 'utility-types';
import { ReportingCore } from '../../';
import { REPORTING_SYSTEM_INDEX } from '../../../common/constants';
import { ReportApiJSON, ReportSource } from '../../../common/types';
import { statuses } from '../../lib/statuses';
import { Report } from '../../lib/store';
Expand Down Expand Up @@ -54,9 +55,7 @@ interface JobsQueryFactory {

export function jobsQueryFactory(reportingCore: ReportingCore): JobsQueryFactory {
function getIndex() {
const config = reportingCore.getConfig();

return `${config.get('index')}-*`;
return `${REPORTING_SYSTEM_INDEX}-*`;
}

async function execQuery<
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/reporting/server/usage/get_reporting_usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { estypes } from '@elastic/elasticsearch';
import type { ElasticsearchClient } from 'kibana/server';
import { get } from 'lodash';
import type { ReportingConfig } from '../';
import { REPORTING_SYSTEM_INDEX } from '../../common/constants';
import type { ExportTypesRegistry } from '../lib/export_types_registry';
import type { GetLicense } from './';
import { getExportStats } from './get_export_stats';
Expand Down Expand Up @@ -144,7 +145,7 @@ export async function getReportingUsage(
esClient: ElasticsearchClient,
exportTypesRegistry: ExportTypesRegistry
): Promise<ReportingUsageType> {
const reportingIndex = config.get('index');
const reportingIndex = REPORTING_SYSTEM_INDEX;
const params = {
index: `${reportingIndex}-*`,
filterPath: 'aggregations.*.buckets',
Expand Down

0 comments on commit d675e9e

Please sign in to comment.