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




- 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>
## 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>
## 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"
]
}
```
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>
* 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>
* [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>