Skip to content

Commit

Permalink
[Security Solution] Fix Lists route permissions (#73368)
Browse files Browse the repository at this point in the history
* Do not display threshold field for an ML Rule

* Give 'read' privileges to 'all' users

We have several lists routes that require lists-read access. If the user
was given the 'all' privilege for securitySolution, they would
previously be locked out of those routes.
  • Loading branch information
rylnd committed Jul 28, 2020
1 parent 79c475a commit 01b70dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { NOTIFICATION_THROTTLE_NO_ACTIONS } from '../../../../../../common/const
import { transformAlertToRuleAction } from '../../../../../../common/detection_engine/transform_actions';
import { RuleType } from '../../../../../../common/detection_engine/types';
import { isMlRule } from '../../../../../../common/machine_learning/helpers';
import { isThresholdRule } from '../../../../../../common/detection_engine/utils';
import { List } from '../../../../../../common/detection_engine/schemas/types';
import { ENDPOINT_LIST_ID } from '../../../../../shared_imports';
import { NewRule, Rule } from '../../../../containers/detection_engine/rules';
Expand Down Expand Up @@ -57,7 +58,7 @@ export interface RuleFields {
}
type QueryRuleFields<T> = Omit<T, 'anomalyThreshold' | 'machineLearningJobId' | 'threshold'>;
type ThresholdRuleFields<T> = Omit<T, 'anomalyThreshold' | 'machineLearningJobId'>;
type MlRuleFields<T> = Omit<T, 'queryBar' | 'index'>;
type MlRuleFields<T> = Omit<T, 'queryBar' | 'index' | 'threshold'>;

const isMlFields = <T>(
fields: QueryRuleFields<T> | MlRuleFields<T> | ThresholdRuleFields<T>
Expand All @@ -69,9 +70,9 @@ const isThresholdFields = <T>(

export const filterRuleFieldsForType = <T extends RuleFields>(fields: T, type: RuleType) => {
if (isMlRule(type)) {
const { index, queryBar, ...mlRuleFields } = fields;
const { index, queryBar, threshold, ...mlRuleFields } = fields;
return mlRuleFields;
} else if (type === 'threshold') {
} else if (isThresholdRule(type)) {
const { anomalyThreshold, machineLearningJobId, ...thresholdRuleFields } = fields;
return thresholdRuleFields;
} else {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
all: {
app: [...securitySubPlugins, 'kibana'],
catalogue: ['securitySolution'],
api: ['securitySolution', 'lists-all'],
api: ['securitySolution', 'lists-all', 'lists-read'],
savedObject: {
all: [
'alert',
Expand Down

0 comments on commit 01b70dd

Please sign in to comment.