-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[master] Security CCS automation POC #99042
Conversation
d54a93e
to
a07179c
Compare
a07179c
to
5d40cbe
Compare
Pinging @elastic/security-solution (Team: SecuritySolution) |
@@ -203,5 +224,51 @@ export default ({ getService, getPageObjects }) => { | |||
expect(hitCount).to.be.lessThan(originalHitCount); | |||
}); | |||
}); | |||
|
|||
it('should add detection rule', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to add a test to create a rule, the execution of the rule should be part of it since we need it to perform the assertion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this reasoning be applied also to the index pattern creation then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great! Take a look to my comment above.
await retry.tryForTime(40000, async () => { | ||
const hitCount = await PageObjects.discover.getHitCount(); | ||
log.debug('### hit count = ' + hitCount); | ||
expect(hitCount).to.be.greaterThan('0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better if we assert the number of alerts we are expecting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires tuning, depends on the observation period and on the time elapsed when the reading is done. I also suspect that the observed index (.monitoring-es-*) get updated. Essentially, I'm not sure we can have a deterministic value here. Maybe I should investigate some other index for applying the rule onto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is complex to use our own index of data in the CCS configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As anticipated, none of the indices on the remote (except makelogs*, which is non ECS-compatible) has a deterministic number of entries that can be checked here.
Should we consider ingesting some other data then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a good place to use esArchiver, but it's going to take a little bit of work.
The integration-test repo no longer uses node.js which would be required to call esArchiver.
After the CCS config is provisioned we basically do pushd ../kibana
, and then start the FTR tests.
FTR tests do load data with esArchiver, but currently only to the local cluster. While it's possible to add other configuration for FTR so that esArchiver could also load data in a remote cluster, I think it would be easier to use the CLI to call it from the jenkins_test.sh script in the integration-test just before starting the FTR.
If you want to go this route, let me know and I'll help with it.
const patternName = await PageObjects.settings.getIndexPageHeading(); | ||
expect(patternName).to.be('*:makelogs工程-*'); | ||
}); | ||
|
||
it('create local siem signals index pattern', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in this file it is already tested that an index pattern can be added, in order to improve execution time, as part of the data preparation we need for our test, we can probably add the index we need through the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5d40cbe
to
b250aee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the PR in order to have something already merged and working, but I think we should refactor it to differentiate between the preparation of the test and the test itself. We need also to work to make the test deterministic to make sure that the CCS configuration is fully working.
await retry.tryForTime(40000, async () => { | ||
const hitCount = await PageObjects.discover.getHitCount(); | ||
log.debug('### hit count = ' + hitCount); | ||
expect(hitCount).to.be.greaterThan('0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is complex to use our own index of data in the CCS configuration?
.expect(200); | ||
}); | ||
|
||
it('create remote monitoring ES index pattern', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code inside this test and the above is a preparation of the test we want to perform. So I would refactor it in order to reflect that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually have 2 other ways to automate creating the index pattern without using the API.
-
The old way we're trying to move away from is using
es_archiver
, which let's us save and load a whole .kibana index, which includes the index-pattern saved object. There's still lots of this in use in functional tests. And we do still need it for loading data other than the .kibana index. -
kbnarchiver is pretty new. It basically just wraps the saved object API. There's a CLI for it. So the basic steps would be;
- manually create your index pattern, and any other saved objects you need for your test
- run the CLI to export the saved objects to a .json file
- add the .json file to your PR and code to load that file in your test (often in the before method)
Here's an example PR switching from using esArchiver to kbnArchiver #98063
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
1 similar comment
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
5 similar comments
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
This is just a first step and it's not worth backporting. |
💔 Build Failed
Failed CI Steps
Test FailuresKibana Pipeline / general / task-queue-process-23 / X-Pack Endpoint API Integration Tests.x-pack/test/security_solution_endpoint_api_int/apis/resolver/entity·ts.Endpoint plugin Resolver tests Resolver tests for the entity route winlogbeat tests "before all" hook for "returns a winlogbeat sysmon event when the event matches the schema correctly"Standard Out
Stack Trace
Kibana Pipeline / general / task-queue-process-23 / X-Pack Endpoint API Integration Tests.x-pack/test/security_solution_endpoint_api_int/apis/resolver/entity·ts.Endpoint plugin Resolver tests Resolver tests for the entity route winlogbeat tests "before all" hook for "returns a winlogbeat sysmon event when the event matches the schema correctly"Standard Out
Stack Trace
Kibana Pipeline / general / Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/infra/metrics_anomalies·ts.InfraOps App Metrics UI Metrics UI Anomaly Flyout with anomalies present renders more anomalies on threshold changeStandard Out
Stack Trace
and 4 more failures, only showing the first 3. Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @cavokz |
Summary
Automate testing of the security signal generation when detection rules are applied to remote clusters. See https://github.com/elastic/security-team/issues/1030.