Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.4] [Backport 2.x] Backporting several PRs to 2.x that failed the DCO check. #63

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 55 additions & 14 deletions models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@
* SPDX-License-Identifier: Apache-2.0
*/

export interface Rule {
id: string;
category: string;
log_source: string;
title: string;
description: string;
tags: { value: string }[];
false_positives: { value: string }[];
level: string;
status: string;
references: { value: string }[];
author: string;
detection: string;
}

export interface Detector {
id?: string;
type: 'detector';
detector_type: string;
name: string;
Expand All @@ -17,37 +33,62 @@ export interface Detector {
export interface PeriodSchedule {
period: {
interval: number;
unit: 'MINUTES';
unit: string;
};
}

export interface DetectorInput {
input: {
detector_input: {
description: string;
indices: string[];
rules: string[];
pre_packaged_rules: DetectorRuleInfo[];
custom_rules: DetectorRuleInfo[];
};
}

export interface Rule {
export interface DetectorRuleInfo {
id: string;
name: string;
rule: string; // TODO: Rules will be in "sigma yaml format"
type: string;
active: boolean;
description?: string;
}

export interface AlertCondition {
// Trigger fields
name: string;
id?: string;

// Detector types
types: string[];

// Trigger fields based on Rules
sev_levels: string[];
tags: string[];
actions: string[];
types: string[];
ids: string[];

// Alert related fields
actions: TriggerAction[];
severity: string;
}

export interface TriggerAction {
id: string;
// Id of notification channel
destination_id: string;
subject_template: {
source: string;
lang: string;
};
name: string;
id?: string;
throttle_enabled: boolean;
message_template: {
source: string;
lang: string;
};
throttle: {
unit: string;
value: number;
};
}

export interface FieldMapping {
fieldName: string;
aliasName: string;
indexFieldName: string;
ruleFieldName: string;
}
20 changes: 19 additions & 1 deletion public/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
OpenSearchService,
FieldMappingService,
AlertsService,
IndexService,
RuleService,
NotificationsService,
} from '../services';
import IndexService from '../services/IndexService';

export interface BrowserServices {
detectorsService: DetectorsService;
Expand All @@ -19,4 +21,20 @@ export interface BrowserServices {
opensearchService: OpenSearchService;
fieldMappingService: FieldMappingService;
alertService: AlertsService;
ruleService: RuleService;
notificationsService: NotificationsService;
}

export interface RulesSharedState {
page: RulesPage;
rulesOptions: {
name: string;
id: string;
severity: string;
tags: string[];
}[];
}

export interface RulesPage {
index: number;
}
8 changes: 8 additions & 0 deletions public/models/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { RulesSharedState } from './interfaces';

export type CreateDetectorRulesOptions = Pick<RulesSharedState, 'rulesOptions'>['rulesOptions'];
Loading