Commit graph

16 commits

Author SHA1 Message Date
Nicolas Chaulet
708fcd20df
[Fleet] Use multiple saved object type for agent and package policies with opt-in migration (#189387) 2024-08-14 17:22:01 -04:00
Nicolas Chaulet
ed74543cfd
[Fleet] Support secretRef as value for simplified package policies (#189070) 2024-07-25 08:01:40 -04:00
Nicolas Chaulet
33cf6ab5c4
[Fleet] Allow to run docker registry for tests externally (#184455) 2024-05-30 11:06:46 -04:00
Pierre Gayvallet
148eeec0fe
Update supertest and superagent to latest version (#183587)
## Summary

Related to https://github.com/elastic/kibana/issues/7104

Update supertest, superagent, and the corresponding type package, to
their latest version.

(of course, types had some signature changes and we're massively using
supertest in all our FTR suites so the whole Kibana multiverse has to
review it)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-05-17 04:23:21 -07:00
Gergő Ábrahám
599f01598e
[Fleet][EDR Workflows] Fix uninstall token search for special characters (#181829)
## Summary

This PR makes possible to search for uninstall tokens containing special
characters in their associated agent policy's `name` or `id`.

<img width="1277" alt="image"
src="1d235036-6cbe-4f0b-a49a-dfbb1b6740c0">

The existing search algorithm searches by both `policy_name` and
`policy_id`. This happens in two steps, see the following flowchart. One
search is performed via `soClient.find()`'s `filter` attribute therefore
it is a `query string query`, while the other one is performed via
aggregation `include` filter which is `regexp query`. These two kind of
queries need a different set of characters to be escaped.

This PR modifies the algorithm to escape special characters instead of
simply omitting them (see red nodes in chart), in order to work with
`query string query` and `regexp query`.

```mermaid
graph TD;
    search[`search` query param]--"ab+c(d>"-->queryString[prepare `query string query`:\n- escape*\n- add wildcards];
    queryString--"*ab+c\\(d\\>*"-->name[search POLICIES by `policy_name`\nusing `filter` attribute];

    search[`search` query param]--"ab+c(d>"-->regexp[prepare `regexp query`:\n- escape*\n- add wildcards];


    regexp--".*ab\\+c\\(d>.*"-->combine[combine policyID regexp with found policy IDs]
    name--['policy-id-1', 'policy-id-2', ...]-->combine;

    combine--".*ab\\+c\\(d>.*|policy-id-1|policy-id-2|..."-->tokenSearch[search UNINSTALL TOKENS by\ncombined search string against `policy_id`\nusing aggregation's `include` attribute];

    classDef red stroke:red;
    class queryString,regexp red;
```


### 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

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2024-05-14 13:24:28 +02:00
Gergő Ábrahám
a2d61ed0b1
[EDR Workflows][Fleet] Search and display policy name for uninstall tokens (#176626)
## Summary

In Fleet / Uninstall Tokens tab:
- user can see the name of the related Agent Policy in a new column, if
the policy still exists,
<img width="1325" alt="image"
src="1b06e39b-103f-4439-9560-51227d75fb25">


- otherwise an info tooltip indicating why the name is missing.
test: `This token's related Agent policy has already been deleted, so
the policy name is unavailable.`
<img width="1328" alt="image"
src="d98a72d7-9563-4d4e-9390-9d9826702026">



- Policy name (and the tooltip if missing) is indicated in Uninstall
Command flyout, as well.
<img width="300" alt="image"
src="38d33f3e-5f51-4c88-9efc-db9aed10ad42"><img
width="300" alt="image"
src="d1da0177-5e21-44cb-9ef7-e768d02a00aa">

- User can search for Uninstall Tokens by policy ID and policy name as
well: the search is a **case sensitive partial match**, excluding any
special character
(note: the text on the top of each screenshot has been updated, see
first screenshot)


![image](a5461186-a063-4dc3-8f50-3a6fd0af626d)


![image](2ccaffd7-1358-4113-8e4b-a930d5e20d0f)


![image](d6840f08-ac4f-4d72-b827-abbff25c146a)


![image](c18f4437-1fc9-4c4e-b846-21b68651ebb9)


- a hint is added to indicate that a deleted agent policy's name is
unknown
test: `If an Agent policy is deleted, its policy name is also deleted.
Use the policy ID to search for uninstall tokens related to deleted
Agent policies.`
<img width="1308" alt="image"
src="816dae7e-e3d3-445f-8ee1-48f93bd4f69a">




### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2024-02-13 04:25:33 -07:00
Gergő Ábrahám
c9b6054cbe
[Fleet][Agent tamper protection ] Split GET /uninstall_tokens API (#159944)
## Summary

> **Note**
> For testing: enable the `agentTamperProtectionEnabled` feature flag.

This PR modifies the quite new `GET /api/fleet/uninstall_tokens` API:
- `GET /api/fleet/uninstall_tokens`, returns token 'metadata' (i.e.
**uninstall token id**, policy ID and creation date) for the latest
token for every policy, without the token itself.
  - it is paginated (query params `page`, `perPage`),
  - and can be searched by partial policy ID (query param `policyId`).
  - this route is not used at the moment, will be used very soon
- `GET /api/fleet/uninstall_tokens/{id}` returns one decrypted token
identified by its ID
- ~`GET /api/fleet/agent_policies/{policyId}/uninstall_tokens`, returns
the decrypted token history for one policy~
  - ~this route is used by the `UninstallCommandFlyout`~
- this was added and then removed, because not a necessity at the
moment, and let's keep open all doors for agent tampering v2

### Todo - done  
`created_at` field was removed from the uninstall token saved object
mapping (21855ce37b320e1864c5b9db647ac2355158f91d), because it was
unused and messed up ordering by the saved object's own `created_at`
field.

This removal is not allowed, though, so this issue needs to be fixed.

**Update:** after a discussion with Kibana Core team, the `created_at`
field was removed in a separate PR which is merged in v8.9.0. Reason:
it's okay to use the SO's internal `created_at` field for sorting. Also,
the mapping will be released in v8.9.0 first, so it's okay to modify it
this time. The PR: https://github.com/elastic/kibana/pull/159985

### 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

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-06-30 10:56:26 +02:00
Mark Hopkin
a0ac890f23
[Fleet] Add default inactivity_timeout value of 2 weeks to all new agent policies (#149031)
## Summary

Closes #148527

All new agent policies should default inactivity timeout to 2 weeks
(1209600 seconds).

### Test cases

- When installing a package for the first time in cloud, the 'My first
agent policy' agent policy should have inactivity timeout set to
`1209600`. This can be tested locally by adding `?useMultiPageLayout` to
the add integration URL e.g:
`/app/fleet/integrations/system-1.20.4/add-integration?useMultiPageLayout`

- When adding an integration (non multi page layout e.g
`/app/fleet/integrations/system-1.20.4/add-integration`) and electing to
create a new agent policy, under 'advanced' inactivity timeout should be
pre-populated with 1209600:

<img width="883" alt="Screenshot 2023-01-17 at 12 22 59"
src="https://user-images.githubusercontent.com/3315046/212898300-e1a97d2e-b660-45f9-a5d3-8b0d7b6abe4d.png">


- When creating a new agent policy from the agent policy screen, under
"advanced options", inactivity timeout should be pre-populated with
1209600:
<img width="1540" alt="Screenshot 2023-01-17 at 12 25 20"
src="https://user-images.githubusercontent.com/3315046/212899294-027a3cfe-cc43-48b0-96fe-515956bb2da7.png">

- (covered by integration test also) When creating a new agent policy
via the API, if no inactivity timeout is specified it should default to
1209600:

```
POST kbn:/api/fleet/agent_policies
{
  "name": "Default inactivity timeout",
  "description": "",
  "namespace": "default",
  "monitoring_enabled": [
    "logs",
    "metrics"
  ]
}
```
2023-01-17 17:19:56 -07:00
Spencer
2763af3a4e
[ftr] remove @types/mocha, define custom ambient-ftr-types (#147284)
After moving away from composite projects in the IDE we now have an
issue where projects like security solutions are getting `@types/jest`
and `@types/mocha` loaded up, even though the "types" compiler option in
security solutions focuses on jest. To fix this I've removed the
`@types/mocha` package, implemented/copied a portion of the mocha types
into a new `@kbn/ambient-ftr-types` package which can be used in ftr
packages to define the describe/it/etc. globals.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-12-19 10:42:12 -07:00
Julia Bardi
5431d1fb78
Prerelease toggle (#143853)
* WIP: prerelease toggle

* changed styling

* fixed switch

* auto upgrade and hiding button on callout if no ga available

* tweak prereleaseIntegrationsEnabled state to add undefined state in beginning

* fixing types and tests

* fixing types

* removed dummy endpoint package

* extracted hooks to avoid double loading of packages and categories

* prevent double loading of package details

* updated openapi

* fixing tests

* added try catch around loading settings in preconfig

* error handling on integrations, fixing cypress test with that

* reading prerelease from settings during package install

* fix tests

* fixing tests

* added back experimental as deprecated, fix more tests

* fixed issue in package details overview where nlatest version didnt show prerelease

* changed getPackageInfo to load prerelease from settings if not provided

* fixing tests, moved getSettings to bulk install fn

* fixing cypress and endpoint tests

* fix tests

* fix tests

* added back experimental flag in other plugins, as it is not exaclty the same as prerelease

* reverted mappings change in api_integration

* fixed prerelease condition, fix limited test, trying to fix field limit

* removed experimental flag from epr api call

* added unit test on version dropdown and prerelease callout, set field limit to 1500

* added UI package version check for prerelease disabled case

* fixed synthetics test

* extracted getSettings to a helper function

* removed using prerease setting in auto upgrades and install

* fixing tests, added back prerelease flag to install apis

* fixing a bug with version and release badge of installed integrations

* reload package in overview after loading prerelease setting, this is to show available upgrade if package is installed

* fixing tests by passing prerelease flag on apis

* fixing cypress test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-11-02 09:48:22 +01:00
Nicolas Chaulet
fd16e6b224
[Fleet] Fix upgrade one agent should check fleet server version too (#141788) 2022-09-26 12:46:55 -04:00
Nicolas Chaulet
729ecbaddd
[Fleet] Show reassigned agents as "updating" (#138911) 2022-08-17 09:14:32 -04:00
Cristina Amico
44fb932d95
[Fleet] Changes to bulk upgrade api for allowing rolling upgrades (#131947)
* [Fleet] Changes to bulk upgrade api for allowing rolling upgrades

* Remove one query and some tests

* Skip version check if fleet server agents are being upgraded

* Fix test

* Fixing tests again

* Fix failing check

* Fix another test

* Fix another test

* Fix api integration tests

* Remove parameter

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
2022-05-16 15:01:24 +02:00
Spencer
2a78f350e1
break out parts of @kbn/dev-utils (#130509)
* break out parts of @kbn/dev-utils

* autofix imports and kbn/pm dist

* update readme for @kbn/stdio-dev-helpers

* finish renames
2022-04-19 12:24:58 -05:00
Brandon Kobel
4584a8b570
Elastic License 2.0 (#90099)
* Updating everything except the license headers themselves

* Applying ESLint rules

* Manually replacing the stragglers
2021-02-03 18:12:39 -08:00
Nicolas Chaulet
fed9a4fddc
[Fleet] Rename ingest_manager_api_integration tests fleet_api_integration (#83011) 2020-11-12 13:50:59 -05:00
Renamed from x-pack/test/ingest_manager_api_integration/helpers.ts (Browse further)