add a custom type for trusted_apps operator

undo changes from list plugin and server/lib/detection_engine

refs 2ac56ee839
refs elastic/security-team/issues/543
This commit is contained in:
Ashokaditya 2021-04-23 16:19:12 +02:00
parent 0a60598cba
commit c3643f0c94
3 changed files with 10 additions and 4 deletions

View file

@ -276,12 +276,11 @@ export type CursorOrUndefined = t.TypeOf<typeof cursorOrUndefined>;
export const namespace_type = DefaultNamespace;
export const operatorIncluded = t.keyof({ included: null });
export const operator = t.keyof({ excluded: null, included: null, wildcard_caseless: null });
export const operator = t.keyof({ excluded: null, included: null });
export type Operator = t.TypeOf<typeof operator>;
export enum OperatorEnum {
INCLUDED = 'included',
EXCLUDED = 'excluded',
WILDCARD_CASELESS = 'wildcard_caseless',
}
export enum OperatorTypeEnum {

View file

@ -14,6 +14,7 @@ import {
EntryNested,
ExceptionListItemSchema,
NestedEntriesArray,
Operator,
} from '../../../../../lists/common';
import { ENDPOINT_TRUSTED_APPS_LIST_ID } from '../../../../../lists/common/constants';
import {
@ -75,7 +76,13 @@ export const tagsToEffectScope = (tags: string[]): EffectScope => {
}
};
export const entriesToConditionEntriesMap = (entries: EntriesArray): ConditionEntriesMap => {
type TrustedAppsEntriesArray = Omit<EntriesArray, 'operator'> & {
operator: Operator | 'wildcard_caseless';
};
export const entriesToConditionEntriesMap = (
entries: TrustedAppsEntriesArray
): ConditionEntriesMap => {
return entries.reduce((result, entry) => {
if (entry.field.startsWith('process.hash') && entry.type === 'match') {
return {

View file

@ -44,6 +44,6 @@ export interface CreateFieldAndSetTuplesOptions<T> {
export interface FieldSet {
field: string;
operator: 'excluded' | 'included' | 'wildcard_caseless';
operator: 'excluded' | 'included';
matchedSet: Set<unknown>;
}