Skip to content

Commit

Permalink
Removed os list constant in favour of separate lists in places that u…
Browse files Browse the repository at this point in the history
…se it (each place has own needs to the ordering).
  • Loading branch information
efreeti committed Nov 30, 2020
1 parent 68973fe commit 39da5d1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
8 changes: 0 additions & 8 deletions x-pack/plugins/security_solution/common/endpoint/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { OperatingSystem } from './types';

export const eventsIndexPattern = 'logs-endpoint.events.*';
export const alertsIndexPattern = 'logs-endpoint.alerts-*';
export const metadataIndexPattern = 'metrics-endpoint.metadata-*';
Expand All @@ -16,12 +14,6 @@ export const telemetryIndexPattern = 'metrics-endpoint.telemetry-*';
export const LIMITED_CONCURRENCY_ENDPOINT_ROUTE_TAG = 'endpoint:limited-concurrency';
export const LIMITED_CONCURRENCY_ENDPOINT_COUNT = 100;

export const OPERATING_SYSTEMS: readonly OperatingSystem[] = [
OperatingSystem.LINUX,
OperatingSystem.MAC,
OperatingSystem.WINDOWS,
];

export const TRUSTED_APPS_LIST_API = '/api/endpoint/trusted_apps';
export const TRUSTED_APPS_CREATE_API = '/api/endpoint/trusted_apps';
export const TRUSTED_APPS_DELETE_API = '/api/endpoint/trusted_apps/{id}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import { GetTrustedAppsRequestSchema, PostTrustedAppCreateRequestSchema } from './trusted_apps';
import { ConditionEntryField, OperatingSystem } from '../types';
import { OPERATING_SYSTEMS } from '../constants';

describe('When invoking Trusted Apps Schema', () => {
describe('for GET List', () => {
Expand Down Expand Up @@ -114,7 +113,7 @@ describe('When invoking Trusted Apps Schema', () => {

expect(() => body.validate({ ...bodyMsg, os: 'winz' })).toThrow();

OPERATING_SYSTEMS.forEach((os) => {
[OperatingSystem.LINUX, OperatingSystem.MAC, OperatingSystem.WINDOWS].forEach((os) => {
expect(() => body.validate({ ...bodyMsg, os })).not.toThrow();
});
});
Expand Down Expand Up @@ -156,7 +155,7 @@ describe('When invoking Trusted Apps Schema', () => {
});

it('should validate `entry.field` accepts hash field name for all os values', () => {
OPERATING_SYSTEMS.forEach((os) => {
[OperatingSystem.LINUX, OperatingSystem.MAC, OperatingSystem.WINDOWS].forEach((os) => {
const bodyMsg3 = createNewTrustedApp({
os,
entries: [
Expand All @@ -172,7 +171,7 @@ describe('When invoking Trusted Apps Schema', () => {
});

it('should validate `entry.field` accepts path field name for all os values', () => {
OPERATING_SYSTEMS.forEach((os) => {
[OperatingSystem.LINUX, OperatingSystem.MAC, OperatingSystem.WINDOWS].forEach((os) => {
const bodyMsg3 = createNewTrustedApp({
os,
entries: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

import { combineReducers, createStore } from 'redux';
import { TrustedApp } from '../../../../../common/endpoint/types';
import { OPERATING_SYSTEMS } from '../../../../../common/endpoint/constants';
import { TrustedApp, OperatingSystem } from '../../../../../common/endpoint/types';
import { RoutingAction } from '../../../../common/store/routing';

import {
Expand All @@ -32,6 +31,12 @@ import {
import { trustedAppsPageReducer } from '../store/reducer';
import { TrustedAppsListResourceStateChanged } from '../store/action';

const OPERATING_SYSTEMS: OperatingSystem[] = [
OperatingSystem.WINDOWS,
OperatingSystem.MAC,
OperatingSystem.LINUX,
];

const generate = <T>(count: number, generator: (i: number) => T) =>
[...new Array(count).keys()].map(generator);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { EuiFormProps } from '@elastic/eui/src/components/form/form';
import { OPERATING_SYSTEMS } from '../../../../../../common/endpoint/constants';
import { LogicalConditionBuilder } from './logical_condition';
import {
ConditionEntry,
Expand All @@ -31,6 +30,12 @@ import {
isWindowsTrustedAppCondition,
} from '../../state/type_guards';

const OPERATING_SYSTEMS: readonly OperatingSystem[] = [
OperatingSystem.MAC,
OperatingSystem.WINDOWS,
OperatingSystem.LINUX,
];

const generateNewEntry = (): ConditionEntry<ConditionEntryField.HASH> => {
return {
field: ConditionEntryField.HASH,
Expand Down

0 comments on commit 39da5d1

Please sign in to comment.