Skip to content

Commit

Permalink
[Security Solution] Remove unused global variables (#136689)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic authored Jul 21, 2022
1 parent 8242bdc commit 4c5f275
Show file tree
Hide file tree
Showing 312 changed files with 56 additions and 11,400 deletions.
6 changes: 0 additions & 6 deletions x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ export const DEFAULT_MAX_SIGNALS = 100 as const;
export const DEFAULT_SEARCH_AFTER_PAGE_SIZE = 100 as const;
export const DEFAULT_ANOMALY_SCORE = 'securitySolution:defaultAnomalyScore' as const;
export const DEFAULT_MAX_TABLE_QUERY_SIZE = 10000 as const;
export const DEFAULT_SCALE_DATE_FORMAT = 'dateFormat:scaled' as const;
export const DEFAULT_FROM = 'now/d' as const;
export const DEFAULT_TO = 'now/d' as const;
export const DEFAULT_INTERVAL_PAUSE = true as const;
export const DEFAULT_INTERVAL_TYPE = 'manual' as const;
export const DEFAULT_INTERVAL_VALUE = 300000 as const; // ms
export const DEFAULT_TIMEPICKER_QUICK_RANGES = 'timepicker:quickRanges' as const;
export const SCROLLING_DISABLED_CLASS_NAME = 'scrolling-disabled' as const;
export const GLOBAL_HEADER_HEIGHT = 96 as const; // px
export const FILTERS_GLOBAL_HEIGHT = 109 as const; // px
export const FULL_SCREEN_TOGGLED_CLASS_NAME = 'fullScreenToggled' as const;
export const NO_ALERT_INDEX = 'no-alert-index-049FC71A-4C2C-446F-9901-37XMC5024C51' as const;
export const ENDPOINT_METADATA_INDEX = 'metrics-endpoint.metadata-*' as const;
Expand Down Expand Up @@ -164,8 +161,6 @@ export const APP_OVERVIEW_PATH = `${APP_PATH}${OVERVIEW_PATH}` as const;
export const APP_LANDING_PATH = `${APP_PATH}${LANDING_PATH}` as const;
export const APP_DETECTION_RESPONSE_PATH = `${APP_PATH}${DETECTION_RESPONSE_PATH}` as const;
export const APP_MANAGEMENT_PATH = `${APP_PATH}${MANAGEMENT_PATH}` as const;
export const APP_EXPLORE_PATH = `${APP_PATH}${EXPLORE_PATH}` as const;
export const APP_DASHBOARDS_PATH = `${APP_PATH}${DASHBOARDS_PATH}` as const;

export const APP_ALERTS_PATH = `${APP_PATH}${ALERTS_PATH}` as const;
export const APP_RULES_PATH = `${APP_PATH}${RULES_PATH}` as const;
Expand Down Expand Up @@ -298,7 +293,6 @@ export const TIMELINE_PREPACKAGED_URL = `${TIMELINE_URL}/_prepackaged` as const;
export const NOTE_URL = '/api/note' as const;
export const PINNED_EVENT_URL = '/api/pinned_event' as const;
export const SOURCERER_API_URL = '/internal/security_solution/sourcerer' as const;
export const DETECTION_RESPONSE_METRICS_API_URL = '/api/detection_response_metrics' as const;

/**
* Default signals index key for kibana.dev.yml
Expand Down
14 changes: 0 additions & 14 deletions x-pack/plugins/security_solution/common/cti/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,20 @@ export const MATCHED_ID = 'matched.id';
export const MATCHED_TYPE = 'matched.type';
export const INDICATOR_MATCH_SUBFIELDS = [MATCHED_ATOMIC, MATCHED_FIELD, MATCHED_TYPE];

export const INDICATOR_MATCHED_ATOMIC = `${ENRICHMENT_DESTINATION_PATH}.${MATCHED_ATOMIC}`;
export const INDICATOR_MATCHED_FIELD = `${ENRICHMENT_DESTINATION_PATH}.${MATCHED_FIELD}`;
export const INDICATOR_MATCHED_TYPE = `${ENRICHMENT_DESTINATION_PATH}.${MATCHED_TYPE}`;

export const EVENT_DATASET = 'event.dataset';

export const FIRST_SEEN = 'indicator.first_seen';
export const LAST_SEEN = 'indicator.last_seen';
export const PROVIDER = 'indicator.provider';
export const REFERENCE = 'indicator.reference';
export const FEED_NAME = 'feed.name';

export const FEED_NAME_PATH = `threat.${FEED_NAME}`;

export const INDICATOR_FIRSTSEEN = `${ENRICHMENT_DESTINATION_PATH}.${FIRST_SEEN}`;
export const INDICATOR_LASTSEEN = `${ENRICHMENT_DESTINATION_PATH}.${LAST_SEEN}`;
export const INDICATOR_PROVIDER = `${ENRICHMENT_DESTINATION_PATH}.${PROVIDER}`;
export const INDICATOR_REFERENCE = `${ENRICHMENT_DESTINATION_PATH}.${REFERENCE}`;

export const CTI_ROW_RENDERER_FIELDS = [
INDICATOR_MATCHED_ATOMIC,
INDICATOR_MATCHED_FIELD,
INDICATOR_MATCHED_TYPE,
INDICATOR_REFERENCE,
INDICATOR_PROVIDER,
];

export enum ENRICHMENT_TYPES {
InvestigationTime = 'investigation_time',
IndicatorMatchRule = 'indicator_match_rule',
Expand All @@ -61,7 +48,6 @@ export const EVENT_ENRICHMENT_INDICATOR_FIELD_MAP = {
export const DEFAULT_EVENT_ENRICHMENT_FROM = 'now-30d';
export const DEFAULT_EVENT_ENRICHMENT_TO = 'now';

export const TI_INTEGRATION_PREFIX = 'ti';
export const OTHER_TI_DATASET_KEY = '_others_ti_';

export const THREAT_PIT_KEEP_ALIVE = '5m';
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ export interface BaseFields800 {
[key: string]: SearchTypes;
}

// This type is used after the alert UUID is generated and stored in the _id and ALERT_UUID fields
export interface WrappedFields800<T extends BaseFields800> {
_id: string;
_index: string;
_source: T & { [ALERT_UUID]: string };
}

export interface EqlBuildingBlockFields800 extends BaseFields800 {
[ALERT_GROUP_ID]: string;
[ALERT_GROUP_INDEX]: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const RelatedIntegrationArray = t.array(RelatedIntegration);
* ecs: false,
* };
*/
export type RequiredField = t.TypeOf<typeof RequiredField>;
export const RequiredField = t.exact(
t.type({
name: NonEmptyString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,14 @@ import * as t from 'io-ts';
export const author = t.array(t.string);
export type Author = t.TypeOf<typeof author>;

export const authorOrUndefined = t.union([author, t.undefined]);
export type AuthorOrUndefined = t.TypeOf<typeof authorOrUndefined>;

export const building_block_type = t.string;
export type BuildingBlockType = t.TypeOf<typeof building_block_type>;

export const buildingBlockTypeOrUndefined = t.union([building_block_type, t.undefined]);
export type BuildingBlockTypeOrUndefined = t.TypeOf<typeof buildingBlockTypeOrUndefined>;

export const description = NonEmptyString;
export type Description = t.TypeOf<typeof description>;

export const descriptionOrUndefined = t.union([description, t.undefined]);
export type DescriptionOrUndefined = t.TypeOf<typeof descriptionOrUndefined>;

// outcome is a property of the saved object resolve api
// will tell us info about the rule after 8.0 migrations
export const outcome = t.union([
Expand All @@ -45,43 +38,24 @@ export const outcome = t.union([
export type Outcome = t.TypeOf<typeof outcome>;

export const alias_target_id = t.string;
export type AliasTargetId = t.TypeOf<typeof alias_target_id>;

export const alias_purpose = t.union([
t.literal('savedObjectConversion'),
t.literal('savedObjectImport'),
]);
export type AliasPurpose = t.TypeOf<typeof alias_purpose>;

export const enabled = t.boolean;
export type Enabled = t.TypeOf<typeof enabled>;

export const enabledOrUndefined = t.union([enabled, t.undefined]);
export type EnabledOrUndefined = t.TypeOf<typeof enabledOrUndefined>;

export const event_category_override = t.string;
export type EventCategoryOverride = t.TypeOf<typeof event_category_override>;

export const eventCategoryOverrideOrUndefined = t.union([event_category_override, t.undefined]);
export type EventCategoryOverrideOrUndefined = t.TypeOf<typeof eventCategoryOverrideOrUndefined>;

export const tiebreaker_field = t.string;
export type TiebreakerField = t.TypeOf<typeof tiebreaker_field>;

export const tiebreakerFieldOrUndefined = t.union([tiebreaker_field, t.undefined]);
export type TiebreakerFieldOrUndefined = t.TypeOf<typeof tiebreakerFieldOrUndefined>;

export const timestamp_field = t.string;
export type TimestampField = t.TypeOf<typeof timestamp_field>;

export const timestampFieldOrUndefined = t.union([timestamp_field, t.undefined]);
export type TimestampFieldOrUndefined = t.TypeOf<typeof timestampFieldOrUndefined>;

export const false_positives = t.array(t.string);
export type FalsePositives = t.TypeOf<typeof false_positives>;

export const falsePositivesOrUndefined = t.union([false_positives, t.undefined]);
export type FalsePositivesOrUndefined = t.TypeOf<typeof falsePositivesOrUndefined>;

export const file_name = t.string;
export type FileName = t.TypeOf<typeof file_name>;
Expand Down Expand Up @@ -124,20 +98,15 @@ export const index = t.array(t.string);
export type Index = t.TypeOf<typeof index>;

export const data_view_id = t.string;
export type DataViewId = t.TypeOf<typeof data_view_id>;

export const dataViewIdOrUndefined = t.union([data_view_id, t.undefined]);
export type DataViewIdOrUndefined = t.TypeOf<typeof dataViewIdOrUndefined>;

export const indexOrUndefined = t.union([index, t.undefined]);
export type IndexOrUndefined = t.TypeOf<typeof indexOrUndefined>;

export const interval = t.string;
export type Interval = t.TypeOf<typeof interval>;

export const intervalOrUndefined = t.union([interval, t.undefined]);
export type IntervalOrUndefined = t.TypeOf<typeof intervalOrUndefined>;

export const query = t.string;
export type Query = t.TypeOf<typeof query>;

Expand All @@ -148,18 +117,12 @@ export const license = t.string;
export type License = t.TypeOf<typeof license>;

export const licenseOrUndefined = t.union([license, t.undefined]);
export type LicenseOrUndefined = t.TypeOf<typeof licenseOrUndefined>;

export const objects = t.array(t.type({ rule_id }));

export const output_index = t.string;
export type OutputIndex = t.TypeOf<typeof output_index>;

export const outputIndexOrUndefined = t.union([output_index, t.undefined]);
export type OutputIndexOrUndefined = t.TypeOf<typeof outputIndexOrUndefined>;

export const saved_id = t.string;
export type SavedId = t.TypeOf<typeof saved_id>;

export const savedIdOrUndefined = t.union([saved_id, t.undefined]);
export type SavedIdOrUndefined = t.TypeOf<typeof savedIdOrUndefined>;
Expand All @@ -168,13 +131,10 @@ export const timeline_id = t.string;
export type TimelineId = t.TypeOf<typeof timeline_id>;

export const timelineIdOrUndefined = t.union([timeline_id, t.undefined]);
export type TimelineIdOrUndefined = t.TypeOf<typeof timelineIdOrUndefined>;

export const timeline_title = t.string;
export type TimelineTitle = t.TypeOf<typeof t.string>;

export const timelineTitleOrUndefined = t.union([timeline_title, t.undefined]);
export type TimelineTitleOrUndefined = t.TypeOf<typeof timelineTitleOrUndefined>;

export const timestamp_override = t.string;
export type TimestampOverride = t.TypeOf<typeof timestamp_override>;
Expand All @@ -183,23 +143,13 @@ export const timestampOverrideOrUndefined = t.union([timestamp_override, t.undef
export type TimestampOverrideOrUndefined = t.TypeOf<typeof timestampOverrideOrUndefined>;

export const anomaly_threshold = PositiveInteger;
export type AnomalyThreshold = t.TypeOf<typeof PositiveInteger>;

export const anomalyThresholdOrUndefined = t.union([anomaly_threshold, t.undefined]);
export type AnomalyThresholdOrUndefined = t.TypeOf<typeof anomalyThresholdOrUndefined>;

export const timestamp_override_fallback_disabled = t.boolean;
export type TimestampOverrideFallbackDisabled = t.TypeOf<
typeof timestamp_override_fallback_disabled
>;

export const timestampOverrideFallbackDisabledOrUndefined = t.union([
timestamp_override_fallback_disabled,
t.undefined,
]);
export type TimestampOverrideFallbackDisabledOrUndefined = t.TypeOf<
typeof timestampOverrideFallbackDisabledOrUndefined
>;

/**
* Note that this is a non-exact io-ts type as we allow extra meta information
Expand All @@ -213,9 +163,6 @@ export type MetaOrUndefined = t.TypeOf<typeof metaOrUndefined>;
export const name = NonEmptyString;
export type Name = t.TypeOf<typeof name>;

export const nameOrUndefined = t.union([name, t.undefined]);
export type NameOrUndefined = t.TypeOf<typeof nameOrUndefined>;

export const rule_name_override = t.string;
export type RuleNameOverride = t.TypeOf<typeof rule_name_override>;

Expand All @@ -231,15 +178,11 @@ export const status = t.keyof({
export type Status = t.TypeOf<typeof status>;

export const conflicts = t.keyof({ abort: null, proceed: null });
export type Conflicts = t.TypeOf<typeof conflicts>;

// TODO: Create a regular expression type or custom date math part type here
export const to = t.string;
export type To = t.TypeOf<typeof to>;

export const toOrUndefined = t.union([to, t.undefined]);
export type ToOrUndefined = t.TypeOf<typeof toOrUndefined>;

export const queryFilter = t.string;
export type QueryFilter = t.TypeOf<typeof queryFilter>;

Expand All @@ -249,9 +192,6 @@ export type QueryFilterOrUndefined = t.TypeOf<typeof queryFilterOrUndefined>;
export const references = t.array(t.string);
export type References = t.TypeOf<typeof references>;

export const referencesOrUndefined = t.union([references, t.undefined]);
export type ReferencesOrUndefined = t.TypeOf<typeof referencesOrUndefined>;

export const per_page = PositiveInteger;
export type PerPage = t.TypeOf<typeof per_page>;

Expand Down Expand Up @@ -285,9 +225,6 @@ export type SortOrderOrUndefined = t.TypeOf<typeof sortOrderOrUndefined>;
export const tags = t.array(t.string);
export type Tags = t.TypeOf<typeof tags>;

export const tagsOrUndefined = t.union([tags, t.undefined]);
export type TagsOrUndefined = t.TypeOf<typeof tagsOrUndefined>;

export const fields = t.array(t.string);
export type Fields = t.TypeOf<typeof fields>;
export const fieldsOrUndefined = t.union([fields, t.undefined]);
Expand All @@ -299,23 +236,20 @@ export const thresholdField = t.exact(
value: PositiveIntegerGreaterThanZero,
})
);
export type ThresholdField = t.TypeOf<typeof thresholdField>;

export const thresholdFieldNormalized = t.exact(
t.type({
field: t.array(t.string),
value: PositiveIntegerGreaterThanZero,
})
);
export type ThresholdFieldNormalized = t.TypeOf<typeof thresholdFieldNormalized>;

export const thresholdCardinalityField = t.exact(
t.type({
field: t.string,
value: PositiveInteger,
})
);
export type ThresholdCardinalityField = t.TypeOf<typeof thresholdCardinalityField>;

export const threshold = t.intersection([
thresholdField,
Expand All @@ -327,9 +261,6 @@ export const threshold = t.intersection([
]);
export type Threshold = t.TypeOf<typeof threshold>;

export const thresholdOrUndefined = t.union([threshold, t.undefined]);
export type ThresholdOrUndefined = t.TypeOf<typeof thresholdOrUndefined>;

export const thresholdNormalized = t.intersection([
thresholdFieldNormalized,
t.exact(
Expand All @@ -340,9 +271,6 @@ export const thresholdNormalized = t.intersection([
]);
export type ThresholdNormalized = t.TypeOf<typeof thresholdNormalized>;

export const thresholdNormalizedOrUndefined = t.union([thresholdNormalized, t.undefined]);
export type ThresholdNormalizedOrUndefined = t.TypeOf<typeof thresholdNormalizedOrUndefined>;

export const thresholdWithCardinality = t.intersection([
thresholdFieldNormalized,
t.exact(
Expand All @@ -361,11 +289,6 @@ export const updated_by = t.string;

export const created_by = t.string;

export const updatedByOrNull = t.union([updated_by, t.null]);
export type UpdatedByOrNull = t.TypeOf<typeof updatedByOrNull>;
export const createdByOrNull = t.union([created_by, t.null]);
export type CreatedByOrNull = t.TypeOf<typeof createdByOrNull>;

export const rules_installed = PositiveInteger;
export const rules_updated = PositiveInteger;
export const status_code = PositiveInteger;
Expand All @@ -387,10 +310,8 @@ export const note = t.string;
export type Note = t.TypeOf<typeof note>;

export const namespaceOrUndefined = t.union([namespace, t.undefined]);
export type NamespaceOrUndefined = t.TypeOf<typeof namespaceOrUndefined>;

export const noteOrUndefined = t.union([note, t.undefined]);
export type NoteOrUndefined = t.TypeOf<typeof noteOrUndefined>;

export const indexRecord = t.record(
t.string,
Expand All @@ -414,12 +335,10 @@ export const indexRecord = t.record(
write: t.boolean,
})
);
export type IndexRecord = t.TypeOf<typeof indexRecord>;

export const indexType = t.type({
index: indexRecord,
});
export type IndexType = t.TypeOf<typeof indexType>;

export const privilege = t.type({
username: t.string,
Expand Down Expand Up @@ -478,8 +397,6 @@ export enum BulkActionEditType {
'set_timeline' = 'set_timeline',
}

export const bulkActionEditType = enumeration('BulkActionEditType', BulkActionEditType);

const bulkActionEditPayloadTags = t.type({
type: t.union([
t.literal(BulkActionEditType.add_tags),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,3 @@ export const getAddPrepackagedThreatMatchRulesSchemaMock = (): AddPrepackagedRul
},
],
});

export const getAddPrepackagedThresholdRulesSchemaMock = (): AddPrepackagedRulesSchema => ({
description: 'some description',
name: 'Query with a rule id',
query: 'user.name: root or user.name: admin',
severity: 'high',
risk_score: 55,
language: 'kuery',
rule_id: 'rule-1',
version: 1,
type: 'threshold',
threshold: {
field: ['field-1', 'field-2', 'field-3', 'field-4'],
value: 1,
},
});
Loading

0 comments on commit 4c5f275

Please sign in to comment.