Skip to content

Commit

Permalink
Cleanup Security plugin imports (#93056)
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Mar 2, 2021
1 parent 3c4a3b8 commit 6ecffcc
Show file tree
Hide file tree
Showing 505 changed files with 2,467 additions and 1,977 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ x-pack/plugins/telemetry_collection_xpack/schema/ @elastic/kibana-core @elastic/
# Security
/src/core/server/csp/ @elastic/kibana-security @elastic/kibana-core
/src/plugins/security_oss/ @elastic/kibana-security
/src/plugins/spaces_oss/ @elastic/kibana-security
/test/security_functional/ @elastic/kibana-security
/x-pack/plugins/spaces/ @elastic/kibana-security
/x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/security_oss/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/consistent-type-imports": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import { coreMock } from '../../../../core/public/mocks';
import { coreMock } from 'src/core/public/mocks';

import { AppStateService } from './app_state_service';

describe('AppStateService', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

import { CoreStart } from 'kibana/public';
import { AppState } from '../../common';
import type { CoreStart } from 'src/core/public';

import type { AppState } from '../../common';

const DEFAULT_APP_STATE = Object.freeze({
insecureClusterAlert: { displayAlert: false },
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/security_oss/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* Side Public License, v 1.
*/

import { PluginInitializerContext } from 'kibana/public';
import type { PluginInitializerContext } from 'src/core/public';

import { SecurityOssPlugin } from './plugin';

export { SecurityOssPluginSetup, SecurityOssPluginStart } from './plugin';

export const plugin = (initializerContext: PluginInitializerContext) =>
new SecurityOssPlugin(initializerContext);
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { I18nProvider, FormattedMessage } from '@kbn/i18n/react';
import { MountPoint } from 'kibana/public';
import React, { useState } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';

import { i18n } from '@kbn/i18n';
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
import type { MountPoint } from 'src/core/public';

export const defaultAlertTitle = i18n.translate('security.checkup.insecureClusterTitle', {
defaultMessage: 'Your data is not secure',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import {
import type {
InsecureClusterServiceSetup,
InsecureClusterServiceStart,
} from './insecure_cluster_service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*/

import { nextTick } from '@kbn/test/jest';
import { coreMock } from '../../../../core/public/mocks';

import { coreMock } from 'src/core/public/mocks';

import { mockAppStateService } from '../app_state/app_state_service.mock';
import type { ConfigType } from '../config';
import { InsecureClusterService } from './insecure_cluster_service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* Side Public License, v 1.
*/

import { CoreSetup, CoreStart, MountPoint, Toast } from 'kibana/public';

import { BehaviorSubject, combineLatest, from } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';

import type { CoreSetup, CoreStart, MountPoint, Toast } from 'src/core/public';

import type { ConfigType } from '../config';
import type { AppStateServiceStart } from '../app_state';
import { defaultAlertText, defaultAlertTitle } from './components';
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/security_oss/public/plugin.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
*/

import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import { InsecureClusterServiceStart } from './insecure_cluster_service';

import type { InsecureClusterServiceStart } from './insecure_cluster_service';
import { mockInsecureClusterService } from './insecure_cluster_service/insecure_cluster_service.mock';
import { SecurityOssPluginSetup, SecurityOssPluginStart } from './plugin';
import type { SecurityOssPluginSetup, SecurityOssPluginStart } from './plugin';

export const mockSecurityOssPlugin = {
createSetup: () => {
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/security_oss/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import type {
Plugin,
PluginInitializerContext,
} from 'src/core/public';

import { AppStateService } from './app_state';
import type { ConfigType } from './config';
import {
InsecureClusterService,
import type {
InsecureClusterServiceSetup,
InsecureClusterServiceStart,
} from './insecure_cluster_service';
import { AppStateService } from './app_state';
import { InsecureClusterService } from './insecure_cluster_service';

export interface SecurityOssPluginSetup {
insecureCluster: InsecureClusterServiceSetup;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/security_oss/server/check_cluster_data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import { elasticsearchServiceMock, loggingSystemMock } from '../../../core/server/mocks';
import { elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks';

import { createClusterDataCheck } from './check_cluster_data';

describe('checkClusterForUserData', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/security_oss/server/check_cluster_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { ElasticsearchClient, Logger } from 'kibana/server';
import type { ElasticsearchClient, Logger } from 'src/core/server';

export const createClusterDataCheck = () => {
let clusterHasUserData = false;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/security_oss/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import { schema, TypeOf } from '@kbn/config-schema';
import type { TypeOf } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';

export type ConfigType = TypeOf<typeof ConfigSchema>;

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/security_oss/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Side Public License, v 1.
*/

import { TypeOf } from '@kbn/config-schema';
import type { TypeOf } from '@kbn/config-schema';
import type { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server';

import { PluginConfigDescriptor, PluginInitializerContext } from 'kibana/server';
import { ConfigSchema } from './config';
import { SecurityOssPlugin } from './plugin';

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/security_oss/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import { coreMock } from '../../../core/server/mocks';
import { coreMock } from 'src/core/server/mocks';

import { SecurityOssPlugin } from './plugin';

describe('SecurityOss Plugin', () => {
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/security_oss/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
* Side Public License, v 1.
*/

import type { Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs';

import type {
Capabilities,
CoreSetup,
KibanaRequest,
Logger,
Plugin,
PluginInitializerContext,
} from 'kibana/server';
import { BehaviorSubject, Observable } from 'rxjs';
} from 'src/core/server';

import { createClusterDataCheck } from './check_cluster_data';
import { ConfigType } from './config';
import { setupAppStateRoute, setupAnonymousAccessCapabilitiesRoute } from './routes';
import type { ConfigType } from './config';
import { setupAnonymousAccessCapabilitiesRoute, setupAppStateRoute } from './routes';

export interface SecurityOssPluginSetup {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import type { IRouter } from 'kibana/server';
import type { IRouter } from 'src/core/server';

import type { AnonymousAccessService } from '../plugin';

interface Deps {
Expand Down
9 changes: 6 additions & 3 deletions src/plugins/security_oss/server/routes/app_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
* Side Public License, v 1.
*/

import type { IRouter, Logger } from 'kibana/server';
import { combineLatest, Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { combineLatest } from 'rxjs';

import type { IRouter, Logger } from 'src/core/server';

import type { AppState } from '../../common';
import { createClusterDataCheck } from '../check_cluster_data';
import type { createClusterDataCheck } from '../check_cluster_data';
import type { ConfigType } from '../config';
import type { AnonymousAccessService } from '../plugin';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
* Side Public License, v 1.
*/

import type { UnwrapPromise } from '@kbn/utility-types';
import supertest from 'supertest';
import { setupServer } from '../../../../../core/server/test_utils';
import { AnonymousAccessService } from '../../plugin';

import type { UnwrapPromise } from '@kbn/utility-types';
import { setupServer } from 'src/core/server/test_utils';

import type { AnonymousAccessService } from '../../plugin';
import { setupAnonymousAccessCapabilitiesRoute } from '../anonymous_access_capabilities';

type SetupServerReturn = UnwrapPromise<ReturnType<typeof setupServer>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
* Side Public License, v 1.
*/

import { loggingSystemMock } from '../../../../../core/server/mocks';
import { setupServer } from '../../../../../core/server/test_utils';
import { AnonymousAccessService } from '../../plugin';
import { setupAppStateRoute } from '../app_state';
import { ConfigType } from '../../config';
import { BehaviorSubject, of } from 'rxjs';
import { UnwrapPromise } from '@kbn/utility-types';
import { createClusterDataCheck } from '../../check_cluster_data';
import supertest from 'supertest';

import type { UnwrapPromise } from '@kbn/utility-types';
import { loggingSystemMock } from 'src/core/server/mocks';
import { setupServer } from 'src/core/server/test_utils';

import type { createClusterDataCheck } from '../../check_cluster_data';
import type { ConfigType } from '../../config';
import type { AnonymousAccessService } from '../../plugin';
import { setupAppStateRoute } from '../app_state';

type SetupServerReturn = UnwrapPromise<ReturnType<typeof setupServer>>;
const pluginId = Symbol('securityOss');

Expand Down
5 changes: 5 additions & 0 deletions src/plugins/spaces_oss/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/consistent-type-imports": 1
}
}
3 changes: 2 additions & 1 deletion src/plugins/spaces_oss/public/api.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { of } from 'rxjs';
import { SpacesApi, SpacesApiUi, SpacesApiUiComponent } from './api';

import type { SpacesApi, SpacesApiUi, SpacesApiUiComponent } from './api';

const createApiMock = (): jest.Mocked<SpacesApi> => ({
activeSpace$: of(),
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/spaces_oss/public/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Side Public License, v 1.
*/

import { Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import type { ReactElement } from 'react';
import { Space } from '../common';

import type { Space } from '../common';

/**
* @public
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/spaces_oss/public/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { spacesApiMock } from '../api.mock';
import { SpacesOssPluginSetup, SpacesOssPluginStart } from '..';

import type { SpacesOssPluginSetup, SpacesOssPluginStart } from '../';

const createSetupContract = (): jest.Mocked<SpacesOssPluginSetup> => ({
registerSpacesApi: jest.fn(),
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/spaces_oss/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Side Public License, v 1.
*/

import { Plugin } from 'src/core/public';
import { SpacesOssPluginSetup, SpacesOssPluginStart } from './types';
import { SpacesApi } from './api';
import type { Plugin } from 'src/core/public';

import type { SpacesOssPluginSetup, SpacesOssPluginStart } from './types';
import type { SpacesApi } from './api';

export class SpacesOssPlugin implements Plugin<SpacesOssPluginSetup, SpacesOssPluginStart, {}, {}> {
private api?: SpacesApi;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spaces_oss/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { SpacesApi } from './api';
import type { SpacesApi } from './api';

export interface SpacesAvailableStartContract extends SpacesApi {
isSpacesAvailable: true;
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/encrypted_saved_objects/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/consistent-type-imports": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { EncryptedSavedObjectsAuditLogger } from './audit_logger';
import { mockAuthenticatedUser } from '../../../security/common/model/authenticated_user.mock';
import { EncryptedSavedObjectsAuditLogger } from './audit_logger';

it('properly logs audit events', () => {
const mockInternalAuditLogger = { log: jest.fn() };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* 2.0.
*/

import { LegacyAuditLogger, AuthenticatedUser } from '../../../security/server';
import { SavedObjectDescriptor, descriptorToArray } from '../crypto';
import type { AuthenticatedUser, LegacyAuditLogger } from '../../../security/server';
import type { SavedObjectDescriptor } from '../crypto';
import { descriptorToArray } from '../crypto';

/**
* Represents all audit events the plugin can log.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { EncryptedSavedObjectsAuditLogger } from './audit_logger';
import type { EncryptedSavedObjectsAuditLogger } from './audit_logger';

export const encryptedSavedObjectsAuditLoggerMock = {
create() {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/encrypted_saved_objects/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { schema, TypeOf } from '@kbn/config-schema';
import type { TypeOf } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';

export type ConfigType = TypeOf<typeof ConfigSchema>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* 2.0.
*/

import { SavedObjectUnsanitizedDoc } from 'kibana/server';
import type { SavedObjectUnsanitizedDoc } from 'src/core/server';
import { migrationMocks } from 'src/core/server/mocks';
import { encryptedSavedObjectsServiceMock } from './crypto/index.mock';

import { getCreateMigration } from './create_migration';
import { encryptedSavedObjectsServiceMock } from './crypto/index.mock';

afterEach(() => {
jest.clearAllMocks();
Expand Down

0 comments on commit 6ecffcc

Please sign in to comment.