Skip to content

Commit

Permalink
fixed security typing
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Jul 1, 2020
1 parent 90d0df4 commit 036a082
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import Boom from 'boom';
import { pluck, mapValues, remove, omit, isUndefined } from 'lodash';
import { KibanaRequest } from 'src/core/server';
import { RecursiveReadonly } from '@kbn/utility-types';
import { ALERTS_FEATURE_ID } from '../../common';
import { AlertTypeRegistry } from '../types';
import { SecurityPluginSetup } from '../../../security/server';
Expand Down Expand Up @@ -316,7 +317,9 @@ export function ensureFieldIsSafeForQuery(field: string, value: string): boolean
}

function hasAnyAlertingPrivileges(
privileges?: FeatureKibanaPrivileges | SubFeaturePrivilegeConfig
privileges?:
| RecursiveReadonly<FeatureKibanaPrivileges>
| RecursiveReadonly<SubFeaturePrivilegeConfig>
): boolean {
return (
((privileges?.alerting?.all?.length ?? 0) || (privileges?.alerting?.read?.length ?? 0)) > 0
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/features/common/feature_kibana_privileges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface FeatureKibanaPrivileges {
* }
* ```
*/
all?: string[];
all?: readonly string[];

/**
* List of alert types which users should have read-only access to when granted this privilege.
Expand All @@ -101,7 +101,7 @@ export interface FeatureKibanaPrivileges {
* }
* ```
*/
read?: string[];
read?: readonly string[];
};
/**
* If your feature requires access to specific saved objects, then specify your access needs here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FeaturePrivilegeAlertingBuilder extends BaseFeaturePrivilegeBuilder
public getActions(privilegeDefinition: FeatureKibanaPrivileges, feature: Feature): string[] {
const getAlertingPrivilege = (
operations: string[],
privilegedTypes: string[],
privilegedTypes: readonly string[],
consumer: string
) =>
privilegedTypes.flatMap((type) =>
Expand Down

0 comments on commit 036a082

Please sign in to comment.