Commit graph

958 commits

Author SHA1 Message Date
Kevin Logan ac71d2e941
[SECURITY_SOLUTION] delete advanced Policy fields when they are empty (#84368) 2020-12-03 10:57:27 -05:00
MadameSheema 37e907078c
[Security Solution][Detections] Implements indicator match rule cypress test (#84323)
* implemnts indicator match rule cypress test

* fixes merge issue

* fixes type check issues

* fixes mapping

* simplifies data

* fixes excpetions flakiness

* fixes alerts test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-12-03 11:48:40 +01:00
Thomas Watson fb48e903d5
Upgrade Node.js to version 14 (#83425) 2020-12-02 23:40:06 +01:00
Dan Panzarella e1944342af
[Security Solution] Keep Endpoint policies up to date with license changes (#83992) 2020-12-02 17:30:44 -05:00
Marshall Main d47c70cd53
[Security Solution][Exceptions] Implement exceptions for ML rules (#84006)
* Implement exceptions for ML rules

* Remove unused import

* Better implicit types

* Retrieve ML rule index pattern for exception field suggestions and autocomplete

* Add ML job logic to edit exception modal

* Remove unnecessary logic change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-12-02 17:14:19 -05:00
Tyler Smalley b593781009
Jest multi-project configuration (#77894)
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
2020-12-02 11:42:23 -08:00
Paul Tavares 2ffdf75b6e
[SECURITY_SOLUTION] Enable usage of the Endpoint Policy form from Fleet (#84684)
* Endpoint: add `withSecurityContext` HOC + refactor endpoint policy edit lazy component to use it
* Endpoint: refactor Policy Details to separate form from view
* Endpoint: Enable the Redux store for the Policy form when displayed via Fleet
* Fleet: Allow partial package policy updates to be sent via `onChange()`
2020-12-02 14:37:36 -05:00
Bohdan Tsymbala 7f969136a3
Added migration of policy for AV registration config. (#84779)
* Added migration of policy for AV registration config.

* Updated migration a bit to be more safe.
2020-12-02 18:55:08 +01:00
Bohdan Tsymbala 32200af4e9
Changed the translation text for the description text in the antivirus registration form (#84626)
* Changed the text for the description text in the antivirus registration form. Moved the form component to components folder and extracted translations into constants to make code more readable.

* Extracted EventsForm to reduce duplication among events forms.
2020-12-02 14:47:56 +01:00
Bohdan Tsymbala 126c99a175
Added word break styles to the texts in the item details card. (#84654)
* Added word break styles to the texts in the item details card.

* Updated snapshots.
2020-12-02 12:48:11 +01:00
Christos Nasikas b9a64ba7d5
[Security Solutino][Case] Case connector alert UI (#82405)
Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-12-01 23:39:27 +02:00
Devin W. Hurley 6e80d9fe09
[Security Solution] [Detections] Create a 'partial failure' status for rules (#84293)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-12-01 10:15:51 -05:00
Steph Milovic 99ea48f401
[Security Solution] [Cases] Cypress for case connector selector options (#80745) 2020-12-01 07:26:01 -07:00
Georgii Gorbachev 80e88cec4d
[Security Solution][Detections] Support arrays in event fields for Severity/Risk overrides (#83723)
This PR changes the behavior of severity and risk score overrides in two ways:

- adds support for arrays in the mapped event fields (so a rule can be triggered by an event where e.g. `event.custom_severity` has a value like `[45, 70, 90]`)
- makes the logic of overrides more flexible, resilient to the incoming values (filters out junk, extracts meaningful values, does its best to find a value that would fit the mapping)
2020-12-01 14:57:53 +01:00
Georgii Gorbachev c0d7ce7de1
[Security Solution][Detections] Fix grammatical error in validation message for threshold field in "Create new rule" -> "Define rule" (#84490)
Just a simple tweak of the default translation.
2020-12-01 14:50:13 +01:00
Anton Dosov 4cb44d9e33
[Search] Integrate "Send to background" UI with session service (#83073) 2020-12-01 14:01:46 +01:00
Paul Tavares 7ba6c73a71
[Fleet] Default Integration Policy Configuration section is only shown if no UI extension is registered (#84534)
* Do not render out-of-box integration policy configuration step if a custom UI extension is registered
* Remove endpoint specific logic from fleet and move it to UI extension
2020-11-30 14:17:19 -05:00
Paul Tavares 707dbcd2b1
[Fleet] Support for showing an Integration Detail Custom (UI Extension) tab (#83805)
* Support for rendering a custom component in Integration Details
* Refactor Fleet app initialization contexts in order to support testing setup
* New test rendering helper tool
* refactor Endpoint to use mock builder from Fleet
2020-11-30 11:12:39 -05:00
Bohdan Tsymbala de5edaa278
Trusted Apps signer API. (#83661)
* Separated out service layer for trusted apps.

* Improved the type structure a bit to avoid using explicit string literals and to add possibility to return OS specific parts of trusted app object in type safe manner.

* Added support for mapping of trusted app to exception item and back.

* Changed schema to support signer in the API.

* Renamed utils to mapping.

* Exported some types in lists plugin and used them in trusted apps.

* Added tests for mapping.

* Added tests for service.

* Switched deletion to use exceptions for not found case.

* Added resetting of the mocks in service layer tests.

* Added handlers tests.

* Refactored mapping tests to be more granular based on the case.

* Restored lowercasing of hash.

* Added schema tests for signer field.

* Removed the grouped tests (they were split into tests for separate concerns).

* Corrected the tests.

* Lowercased the hashes in the service test.

* Moved the lowercasing to the right location.

* Fixed the tests.

* Added test for lowercasing hash value.

* Introduced OperatingSystem enum instead of current types.

* Removed os list constant in favour of separate lists in places that use it (each place has own needs to the ordering).

* Fixed the missed OperatingSystem enum usage.
2020-11-30 15:42:31 +01:00
MadameSheema 454635228e
[Security Solution] Exceptions Cypress tests (#81759)
* improves 'Creates and activates a new custom rule' test

* fixes constant problem

* improves 'Creates and activates a new custom rule with override option' test

* improves 'Creates and activates a new threshold rule' test

* refactor

* fixes type check issue

* improves assertions

* removes unused code

* changes variables for constants

* improves 'waitForTheRuleToBeExecuted' test

* improves readability

* fixes jenkins error

* refactor

* blah

* more things

* finishes 'Creates an exception from rule details and deletes the excpetion' implementation

* implements 'Creates an exception from an alert and deletes the exception'

* updates VALUES_INPUT locator

* updates archiver

* refactor

* improves the code

* fixes CI error

* renames exceptions archive

* refactor

* fixes merge issue

* fixes CI issue

* debug

* refactor

* improves test data

* removes signals index after the execution

* removes unused line

* removes unused variable

* refactors 'numberOfauditbeatExceptionsAlerts' constant to camel case

* simplifies the archive

* waits for the rule to be executed after navigating to opened alerts tab

* cleaning data

* fixes tests flakiness

* cleans test data

* refactors code

* removes unsused archives

* cleans data

* simplifies data

* fixes CI issue

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-30 10:37:42 +01:00
Madison Caldwell bdf7b88b45
[Security Solution][Detections] Handle dupes when processing threshold rules (#83062)
* Fix threshold rule synthetic signal generation

* Use top_hits aggregation

* Find signals and aggregate over search terms

* Exclude dupes

* Fixes to algorithm

* Sync timestamps with events/signals

* Add timestampOverride

* Revert changes in signal creation

* Simplify query, return 10k buckets

* Account for when threshold.field is not supplied

* Ensure we're getting the last event when threshold.field is not provided

* Add missing import

* Handle case where threshold field not supplied

* Fix type errors

* Handle non-ECS fields

* Regorganize

* Address comments

* Fix type error

* Add unit test for buildBulkBody on threshold results

* Add threshold_count back to mapping (and deprecate)

* Timestamp fixes

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-29 22:10:23 -05:00
Dan Panzarella 71f77862e7
[Security Solution] Add Endpoint policy feature checks (#83972) 2020-11-25 15:29:23 -05:00
Jonathan Buttner 5fda30001f
[Security Solution][Resolver] Add support for predefined schemas for endpoint and winlogbeat (#84103)
* Refactoring entity route to return schema

* Refactoring frontend middleware to pick off id field from entity route

* Refactoring schema and adding name and comments

* Adding name to schema mocks

* Fixing type issue
2020-11-25 14:47:11 -05:00
Liza Katz b3430e3f09
[Search] Search batching using bfetch (again) (#84043)
Re-merging after cypress fixes
2020-11-25 16:32:05 +02:00
Patryk Kopyciński 4aa1683b3b
[Security Solution] Cleanup graphiql (#82595) 2020-11-25 10:45:32 +01:00
Ryland Herrick 2ce1e09aad
[Security Solution][Detections] Rule Form Fixes (#84169)
* Prevent error from being displayed when choosing action throttle

Addresses #83230.

This field was previously refactored to not require a callback prop;
simply updating the value via `field.setValue` is sufficient for our use
case.

This fix removes the errant code that assumed a callback prop, since
such a prop does not exist on the underlying component.

* Fix UI bug on ML Jobs popover

EUI links now add an SVG if they're an external link; our use of a div
was causing that to wrap. Since the div was only needed to change the
text size, a refactor makes this all work.

* Exercise editing of tags in E2E tests

These tests were recently skipped due to their improper teardown. Since
that's a broader issue across most of these tests, I'm reopening these
so we can get the coverage provided here for the time being.

* useFetchIndex defaults to isLoading: false

In the case where no index pattern is provided, the hook exits without
doing any work but does not update the loading state; this had the
downstream effect of disabling a form field that was waiting for this
hook to stop loading.

* Move situational action into ... the situation

We only need to clear existing tags in the case where we're editing the
rule (and it has tags); in all other cases, this method fails. This
fixes things by moving that conditional logic (clear the tags field)
into the test that needs it (editing custom rules).
2020-11-24 17:03:56 -06:00
Lukas Olson f80da6cc39
[data.search] Simplify poll logic and improve types (#82545)
* [Search] Add request context and asScoped pattern

* Update docs

* Unify interface for getting search client

* Update examples/search_examples/server/my_strategy.ts

Co-authored-by: Anton Dosov <dosantappdev@gmail.com>

* Review feedback

* Fix checks

* Fix CI

* Fix security search

* Fix test

* Fix test for reals

* Fix types

* [data.search] Refactor search polling and improve types

* Fix & update tests & types

* eql totals

* doc

* Revert "eql totals"

This reverts commit 01e8a06847.

* lint

* response type

* shim inside strategies

* shim for security

* fix eql params

Co-authored-by: Anton Dosov <dosantappdev@gmail.com>
Co-authored-by: Liza K <liza.katz@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-25 00:38:12 +02:00
Jonathan Buttner 5e183dd46d
[Security Solution][Resolver] Allow a configurable entity_id field (#81679)
* Trying to flesh out new tree route

* Working on the descendants query

* Almost working descendants

* Possible solution for aggs

* Working aggregations extraction

* Working on the ancestry array for descendants

* Making changes to the unique id for  ancestr

* Implementing ancestry funcitonality

* Deleting the multiple edges

* Fleshing out the descendants loop for levels

* Writing tests for ancestors and descendants

* Fixing type errors and writing more tests

* Renaming validation variable and deprecating old tree routes

* Renaming tree integration test file

* Adding some integration tests

* Fixing ancestry to handle multiple nodes in the request and writing more tests

* Adding more tests

* Renaming new tree to handler file

* Renaming new tree directory

* Adding more unit tests

* Using doc value fields and working on types

* Adding comments and more tests

* Fixing timestamp test issue

* Adding more comments

* Fixing timestamp test issue take 2

* Adding id, parent, and name fields to the top level response

* Fixing generator start and end time generation

* Adding more comments

* Revert "Fixing generator start and end time generation"

This reverts commit 9e9abf68a6.

* Adding test for time

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-24 11:57:23 -05:00
Angela Chuang d80e8ca2ee
[Security Solution] Fix incorrect time for dns histogram (#83532)
* getSuitableUnit

* update dns histogram query

* update dns query

* update dns histogram query

* fix type error

* fix lint error

* remove unused comments

* fix histogram query size

* revert change

* fix unit test

* fix dns request options

* clean up

* cleanup types

* fix dependency

* review

* review

* revert

* restore docValueFields

* fix unit test

* cleanup

* restore docValueFields for dns histogram

* review

* review

* lint

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-24 15:06:21 +00:00
Mikhail Shustov 5ec6fe315f
[DX] Bump TS version to v4.1 (#83397)
* bump version to 4.1.1-rc

* fix code to run kbn bootstrap

* fix errors

* DO NOT MERGE. mute errors and ping teams to fix them

* Address EuiSelectableProps configuration in discover sidebar

* use explicit type for EuiSelectable

* update to ts v4.1.2

* fix ts error in EuiSelectable

* update docs

* update prettier with ts version support

* Revert "update prettier with ts version support"

This reverts commit 3de48db3ec.

* address another new problem

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
2020-11-24 16:04:33 +01:00
Dan Panzarella 72f36b41f9
[Security Solution] Add endpoint policy revision number (#83982) 2020-11-24 09:59:41 -05:00
Dima Arnautov bfbb43e59b
[ML] Improve browser history navigation (#83792)
* [ML] replace history support

* [ML] explorer url state

* [ML] timeseriesexplorer url state

* [ML] fix state keys for mlSelectSeverity and mlSelectInterval

* [ML] fix useSelectedCells

* [ML] update urls and tests in security app

* [ML] fix TS

* [ML] fix apm unit tests

* [ML] fix typo

* [ML] remove state sync

* [ML] fix initial zoom set

* [ML] fix initial zoom set

* [ML]: update with useMlHref

* [ML] fix TS issue
2020-11-24 15:29:32 +01:00
Mikhail Shustov b3d97764a0
Move streams to kbn/utils (#84033)
* move streams to kbn/std

* import streams from kbn/std

* fix styles

* remove unused shareWeakReplay

* move from kbn/std to kbn/utils

* import from subfolder since test mocks FS module and not compatible with kbn/utils

* remove new line at the end of json file
2020-11-24 15:19:18 +01:00
Yuliia Naumenko b11f7830cb
[Alerting UI] Replaced AppContextProvider introduced by the plugin with KibanaContextProvider (#83248)
* Replaced AppContextProvider introduced by the plugin with KibanaContextProvider

* Removed unused files

* Fixed jest test

* Removed ActionsConnectorContext

* exposed addConnectorFlyout and editConnectorFlyouts as a plugin start result

* removed rest of unused connectors context

* fixed capabilities

* fixed jest tests

* fixed jest tests

* fixed jest tests

* fixed uptime

* fixed typecheck errors

* fixed typechecks

* fixed jest tests

* fixed type

* fixed uptime settings by pathing the correct plugin dependancy

* fixed security detection rules

* fixed due to commetns

* fixed jest tests

* fixed type check

* removed orig files

* fixed cases UI issues

* fixed due to comments

* fixed due to comments

* fixed kibana crash

* fixed es-lint
2020-11-24 00:07:47 -08:00
Tiago Costa f4de3839d0
skip flaky suite (#84145) 2020-11-23 19:12:31 +00:00
Kevin Logan 483749168d
[SECURITY_SOLUTION] truncate Hostname and add tooltip in flyout (#84086)
* truncate Hostname and add tooltip in flyout

* remove leading and trainling spaces
2020-11-23 14:07:18 -05:00
Yara Tercero ad8ea02fb2
[Security Solution][Detections] - Fix EQL preview accepting all date formats (#83939)
## Summary

This PR addresses a bug found where EQL preview was breaking. The preview was showing no hits, though the API response clearly had hits. Because EQL does not support aggregations, aggregations for preview were done manually, client side and missed this case where `@timestamp` is returned as unix epoch. We used `Date.parse` which expects a string, so when inserting a unix timestamp it returned `NaN`.
2020-11-23 13:45:46 -05:00
Frank Hassanabad 24c7b2d2f8
Adds safe guards against in-determinism by checking list items after uploads (#84015)
## Summary

Fixes flakey tests by adding explicit list value upload items through either the fixture that was uploaded or by a specific test value in case the uploaded list is a range value. Also filters out any empty values for more safeguards from prettier formatters that add them to fixture files.

https://github.com/elastic/kibana/issues/84014

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
2020-11-23 08:13:55 -07:00
Kevin Logan d51437e891
change ingest manager text to Fleet (#83991)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-23 09:51:39 -05:00
Mikhail Shustov 95861a0fb0
[DX] Prettier v2.2 (#83899)
* update prettier with ts version support

* mute type-error

* run prettier on codebase

* fix examples

* fix errors after master merged
2020-11-23 13:17:05 +01:00
Tiago Costa 9fcf1f0664
skip flaky suite (#83772) 2020-11-22 22:58:39 +00:00
Tiago Costa 152819f9ed
skip flaky suite (#69849) 2020-11-22 22:51:31 +00:00
Patryk Kopyciński 59053d569d
[Security Solution] Refactor Timeline flyout to take a full page (#82033) 2020-11-22 13:35:06 +01:00
Dan Panzarella 2cd2528ac8
[Security Solution] Give notice when endpoint policy is out of date (#83469) 2020-11-20 15:21:23 -05:00
Kevin Qualters a11f70f9bb
[Security Solution] Sync url state on any changes to query string (#83314) 2020-11-20 14:56:20 -05:00
Frank Hassanabad 5f4c211ea3
[Security Solutions][Detection Engine] Adds e2e FTR runtime support and 213 tests for exception lists (#83764)
## Summary

Adds support to the end to end (e2e) functional test runner (FTR) support for rule runtime tests as well as 213 tests for the exception lists which include value based lists. Previously we had limited runtime support, but as I scaled up runtime tests from 5 to 200+ I noticed in a lot of areas we had to use improved techniques for determinism.

The runtime support being added is our next step of tests. Up to now most of our e2e FTR tests have been structural testing of REST and API integration tests. Basically up to now 95% tests are API structural as:

* Call REST input related to a rule such as GET/PUT/POST/PATCH/DELETE.
* Check REST output of the rule, did it match expected output body and status code?
* In some rare cases we check if the the rule can be executed and we get a status of 'succeeded'

With only a small part of our tests ~5%, `generating_signals.ts` was checking the signals being produced. However, we cannot have confidence in runtime based tests until the structural tests have been built up and run through the weeks against PR's to ensure that those are stable and deterministic.

Now that we have confidence and 90%+ coverage of the structural REST based tests, we are building up newer sets of tests which allow us to do runtime based validation tests to increase confidence that:

* Detection engine produces signals as expected
* Structure of the signals are as expected, including signal on signals
* Exceptions to signals are working as expected
* Most runtime bugs can be TDD'ed with e2e FTR's and regressions
* Whack-a-mole will not happen
* Consistency and predictability of signals is validated
* Refactoring can occur with stronger confidence
* Runtime tests are reference points for answering questions about existing bugs or adding new ones to test if users are experiencing unexpected behaviors  
* Scaling tests can happen without failures
* Velocity for creating tests increases as the utilities and examples increase

Lastly, this puts us within striking distance of creating FTR's for different common class of runtime situations such as:
* Creating tests that exercise each rule against a set of data criteria and get signal hits
* Creating tests that validate the rule overrides operate as expected against data sets
* Creating tests that validate malfunctions, corner cases, or misuse cases such as data sets that are _all_ arrays or data sets that put numbers as strings or throws in an expected `null` instead of a value. 

These tests follow the pattern of:
* Add the smallest data set to a folder in data.json (not gzip format)
* Add the smallest mapping to that folder (mapping.json) 
* Call REST input related to exception lists, value lists, adding prepackaged rules, etc...
* Call REST input related endpoint with utilities to create and activate the rule
* Wait for the rule to go into the `succeeded` phase
* Wait for the N exact signals specific to that rule to be available
* Check against the set of signals to ensure that the matches are exactly as expected 

Example of one runtime test:

A keyword data set is added to a folder called "keyword" but you can add one anywhere you want under `es_archives`, I just grouped mine depending on the situation of the runtime. Small non-gzipped tests `data.json` and `mappings.json` are the best approach for small focused tests. For _larger_ tests and cases I would and sometimes do use things such as auditbeat but try to avoid using larger data sets in favor of smaller focused test cases to validate the runtime is operating as expected.

```ts
{
  "type": "doc",
  "value": {
    "id": "1",
    "index": "long",
    "source": {
      "@timestamp": "2020-10-28T05:00:53.000Z",
      "long": 1
    },
    "type": "_doc"
  }
}

{
  "type": "doc",
  "value": {
    "id": "2",
    "index": "long",
    "source": {
      "@timestamp": "2020-10-28T05:01:53.000Z",
      "long": 2
    },
    "type": "_doc"
  }
}

{
  "type": "doc",
  "value": {
    "id": "3",
    "index": "long",
    "source": {
      "@timestamp": "2020-10-28T05:02:53.000Z",
      "long": 3
    },
    "type": "_doc"
  }
}

{
  "type": "doc",
  "value": {
    "id": "4",
    "index": "long",
    "source": {
      "@timestamp": "2020-10-28T05:03:53.000Z",
      "long": 4
    },
    "type": "_doc"
  }
}
```

Mapping is added. Note that this is "ECS tolerant" but not necessarily all ECS meaning I can and will try to keep things simple where I can, but I have ensured that  `"@timestamp"` is at least there.

```ts
{
  "type": "index",
  "value": {
    "index": "long",
    "mappings": {
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "long": { "type": "long" }
      }
    },
    "settings": {
      "index": {
        "number_of_replicas": "1",
        "number_of_shards": "1"
      }
    }
  }
}
```

Test is written with test utilities where the `beforeEach` and `afterEach` try and clean up the indexes and load/unload the archives to keep one test from effecting another. Note this is never going to be 100% possible so see below on how we add more determinism in case something escapes the sandbox. 
```ts
    beforeEach(async () => {
      await createSignalsIndex(supertest);
      await createListsIndex(supertest);
      await esArchiver.load('rule_exceptions/keyword');
    });

    afterEach(async () => {
      await deleteSignalsIndex(supertest);
      await deleteAllAlerts(supertest);
      await deleteAllExceptions(es);
      await deleteListsIndex(supertest);
      await esArchiver.unload('rule_exceptions/keyword');
    });

    describe('"is" operator', () => {
      it('should filter 1 single keyword if it is set as an exception', async () => {
        const rule = getRuleForSignalTesting(['keyword']);
        const { id } = await createRuleWithExceptionEntries(supertest, rule, [
          [
            {
              field: 'keyword',
              operator: 'included',
              type: 'match',
              value: 'word one',
            },
          ],
        ]);
        await waitForRuleSuccess(supertest, id);
        await waitForSignalsToBePresent(supertest, 3, [id]);
        const signalsOpen = await getSignalsById(supertest, id);
        const hits = signalsOpen.hits.hits.map((hit) => hit._source.keyword).sort();
        expect(hits).to.eql(['word four', 'word three', 'word two']);
      });
   });
```

### Changes for better determinism
To support more determinism there are changes and utilities added which can be tuned during any sporadic failures we might encounter as well as better support unexpected changes to other Elastic Stack pieces such as alerting, task manager, etc...

Get simple rule and others are now defaulting to false, meaning that the structural tests will no longer activate a rule and run it on task manger. This should cut down on error outputs as well as reduce stress and potentials for left over rules interfering with the runtime rules. 
```ts
export const getSimpleRule = (ruleId = 'rule-1', enabled = false): QueryCreateSchema => ({
```

Not mandatory to use, but for most tests that should be runtime based tests, I use this function below which will enable it by default and run it using settings such as `type: 'query'`, `query: '*:*',` `from: '1900-01-01T00:00:00.000Z'`, to cut down on boiler plate noise. However, people can use whatever they want out of the grab bag or if their test is more readable to hand craft a REST request to create signals, or if they just want to call this and override where they want to, then 👍 .
 ```ts
export const getRuleForSignalTesting = (index: string[], ruleId = 'rule-1', enabled = true)
```

This waits for a rule to succeed before continuing
```ts
await waitForRuleSuccess(supertest, id);
```

I added a required array of id that _waits_ only for that particular id here. This is useful in case another test did not cleanup and you are getting signals being produced or left behind but need to wait specifically for yours.
```ts
await waitForSignalsToBePresent(supertest, 4, [id]);
```

I only get the signals for a particular rule id using either the auto-generated id or the rule_id. It's safer to use the ones from the auto-generated id but either of these are fine if you're careful enough. 
```ts
const signalsOpen = await getSignalsById(supertest, id);
const signalsOpen = await getSignalsByIds(supertest, [createdId]);
const signalsOpen = await getSignalsByRuleIds(supertest, ['signal-on-signal']);
```

I delete all alerts now through a series of steps where it properly removes all rules using the rules bulk_delete and does it in such a way that all the API keys and alerting will be the best it can destroyed as well as double check that the alerts are showing up as being cleaned up before continuing.
```ts
deleteAllAlerts()
```

When not explicitly testing something structural, prefer to use the utilities which can and will do retries in case there are over the wire failures or es failures. Examples are:
```ts
installPrePackagedRules()
waitForRuleSuccess()
importFile() // This does a _lot_ of checks to ensure that the file is fully imported before continuing
```

Some of these utilities might still do a `expect(200);` but as we are and should use regular structural tests to cover those problems, these will probably be more and more removed when/if we hit test failures in favor of doing retries, waitFor, and countDowns.

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
2020-11-20 12:09:38 -07:00
Christos Nasikas 52c6b7b81b
[Security Solution][Case] Create comment types (#82715) 2020-11-20 21:03:05 +02:00
Marshall Main f4e7362b45
[Security Solution][Detections] Prevents recursive EQL rules (#82857)
* Prevents recursive EQL rules

* Remove unused import

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-20 11:22:11 -05:00
Jane Miller 7c80a6be68
[SECURITY_SOLUTION] 145: Advanced Policy Tests (#82898)
* Create Policies for each generated host

* Refactor Ingest setup to also setup Fleet

* Rename prop name

* Add generic response type to KbnClient.request + support for headers

* first attempt at adding fleet agent registration

* a little closer with fleet integration

* SUCCESS. Able to enroll agent and set it to online

* update names to be policy

* policy generator has advanced types in endpoint confit

* linting

* flesh out callback

* add submit button for verify_peer

* add verify hostname field

* 145 generalize cb

* 145 fix setAgain and getValue

* 145 merge conflict

* 145 add verify_hostname back, start loop for form

* 145 remove OS trick

* 145 make AdvancedPolicyForms its own component

* 145 grid partially working

* 145 back to basics

* 145 back to basics

* 145 rolled back grid

* 145 flex table working

* 145 undo accidental change

* 145 remove extra schema file

* 145 remove unused variable

* 145 kevin's PR feedback

* 145 fix type check and jest

* 145 EuiFlexGroups

* 145 use simple EuiFormRow and add show/hide buttons

* 145 move all advanced policy code to advanced file; remove unnec test code

* 145 fix IDs

* 145 take out unnecessary stuff

* 145 removed a couple more lines

* 145 add some fields back in

* 145 add spacer

* 145 start tests

* 145 add findAdvancedPolicyButton

* 145 test passing

* 145 remove comment

Co-authored-by: Paul Tavares <paul.tavares@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kevinlog <kevin.logan@elastic.co>
Co-authored-by: Candace Park <candace.park@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-20 10:27:58 -05:00
Devin W. Hurley b3c334a1d9
[Security Solution] [Detections] Adds scripts to create users + roles based on specific privileges (#81866)
* shell scripts for creating roles + users for testing

* update readme's and updated privilege requirements based on testing with the users and inferring what the roles are supposed to do

* update role privileges based on feedback meeting yesterday

* updated scripts to accept filepath to role / user, added a test to ensure upload value list button is disabled

* updated role scripts to be parameterized

* adds login with role function and adds a sample test with a role to test that a t1 analyst user cannot upload a value list

* add object with corresponding roles

* fix spacing

* parameterize urls for basic auth with roles + users

* forgot to change the cy.visit string

* add KIBANA_URL env var for cli runner

* add env vars for curl script execution

* second script

* update readme's for each role and remove create_index from lists privilege for the soc manager role

* remove 'manage' cluster privilege for rule author

* remove 'create_index' privilege from soc_manager role since that is not parity with the security workflows spreadsheet

* update the login function logic with glo's feedback

* replace SIEM with Security Solution in markdown files

* make role param optional not just undefined

* remove unused file

* add copyright to scripts files

* update top-level README for roles scripts

* remove reference to internal spreadsheet and reference readme for this pr

* remove unnecessary -XPOST and remove verbose mode from post_detections_user script

* adds utils for running integration tests with other users and adds two sample tests showing example usage

* minor type updates and small refactor

* fix x-pack/test types

* use enum types instead of custom type

* fix path to json

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
2020-11-19 16:02:03 -05:00