Skip to content
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

[Alerting][Connectors] Export rules and connectors #94151

Closed
ymao1 opened this issue Mar 9, 2021 · 11 comments · Fixed by #98802
Closed

[Alerting][Connectors] Export rules and connectors #94151

ymao1 opened this issue Mar 9, 2021 · 11 comments · Fixed by #98802
Assignees
Labels
Feature:Actions Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@ymao1
Copy link
Contributor

ymao1 commented Mar 9, 2021

This issue covers the export portion of importing/exporting rules and connectors. We want to be able to export rules and connectors from the saved object management page.

1. Export rules

Set rules to exportable when registering the alert saved object type. Add an onExport hook that sets the rule to disabled and sensitive values within the rule to null before exporting.

The following fields should be modified on export:

  • enabled: false
  • apiKey: null
  • apiKeyOwner: null
  • scheduledTaskId: null

What should we do with the alert execution status? Would lastExecutionDate make sense on a new kibana instance? Should we clear it out and reset the execution status altogether?

2. Export connectors

Set connectors to exportable when registering the action saved object type. Add an onExport hook that sets the connector to disabled and secret values to null before exporting.

The following fields should be modified on export:

  • isMissingSecrets: true
  • secrets: null

There are some connectors (server log & es index, example) that have no secrets. It would be nice to not disable these so they can be ready to use right after import. There are also some connectors that have optional secrets (webhook & email, if hasAuth is enabled, for example). If the secret is not required, then the flag should not be set on export.

3. Audit log entry for exports

Based on this comment and the ensuring discussion, we should be generating alerting/action specific audit log entries on export so the exports don't just show up as generic saved object actions.

@ymao1 ymao1 added Feature:Actions Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Mar 9, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@ymao1 ymao1 added the blocked label Mar 9, 2021
@ymao1
Copy link
Contributor Author

ymao1 commented Mar 9, 2021

Blocked by #94106

@ymao1
Copy link
Contributor Author

ymao1 commented Mar 10, 2021

Access to hidden saved object types is controlled by feature privileges for users with limited roles. Giving a user access to the "Actions and Connectors" privilege allows them to see connectors in the saved object management page. Since alerting doesn't have its own privilege, @legrego suggested adding alert to the Saved Objects Management privilege. This means a user with the ability to manage saved objects will be able to export all rules, even if they don't have specific privileges to create them.

The update would be done here by adding 'alert' to the [...savedObjectTypes] array

{
id: 'savedObjectsManagement',
name: i18n.translate('xpack.features.savedObjectsManagementFeatureName', {
defaultMessage: 'Saved Objects Management',
}),
order: 1700,
category: DEFAULT_APP_CATEGORIES.management,
app: ['kibana'],
catalogue: ['saved_objects'],
management: {
kibana: ['objects'],
},
privileges: {
all: {
app: ['kibana'],
catalogue: ['saved_objects'],
management: {
kibana: ['objects'],
},
api: ['copySavedObjectsToSpaces'],
savedObject: {
all: [...savedObjectTypes],
read: [],
},
ui: ['read', 'edit', 'delete', 'copyIntoSpace', 'shareIntoSpace'],
},
read: {
app: ['kibana'],
catalogue: ['saved_objects'],
management: {
kibana: ['objects'],
},
api: ['copySavedObjectsToSpaces'],
savedObject: {
all: [],
read: [...savedObjectTypes],
},
ui: ['read'],
},
},
},
...(includeTimelion ? [timelionFeature] : []),
] as KibanaFeatureConfig[];
};

@mikecote
Copy link
Contributor

mikecote commented Mar 11, 2021

Access to hidden saved object types is controlled by feature privileges for users with limited roles. Giving a user access to the "Actions and Connectors" privilege allows them to see connectors in the saved object management page.

This is interesting. Is this something specific to hidden types in saved objects management?

@ymao1
Copy link
Contributor Author

ymao1 commented Mar 11, 2021

Yes, right now the Saved Objects Management privilege explicitly gives access to "visible types", so if a user only had access to Saved Objects Management, they would not see rules or connectors or any other hidden types. Adding the Actions and Connectors privilege gives access to the action type but there's no privilege currently that gives access to the alert type. I think this is probably unique to the alert hidden type only because Alerting doesn't have an explicit privilege and we depend on the privileges of the alerting rule producers.

@mikecote
Copy link
Contributor

mikecote commented Mar 11, 2021

I see now, thanks!

I wonder if the user will understand this limitation for alerts and connectors (mostly connectors) or if we should auto-grant access to both when a role has the SO management feature. That way if they don't have the connectors privilege, they would see those automatically.

@ymao1
Copy link
Contributor Author

ymao1 commented Mar 11, 2021

That's definitely an option! I think it's not as confusing for actions because if you don't have the connectors privilege you don't see the connectors tab at all and are unable to add any actions, whereas if you had the stack alerts privilege and were able to create rules and see the rule management page, it would be confusing why you can't see them in Saved Objects Management

@legrego
Copy link
Member

legrego commented Mar 11, 2021

Based on an earlier conversation, my understanding is that we would update the saved objects management privilege to grant access to all exportable types, even if they were hidden.

If that's still the path we plan on taking, then I think it addresses the inconsistency/potential confustion.

@ymao1
Copy link
Contributor Author

ymao1 commented Mar 11, 2021

@legrego I see that was added in the POC. It looks like this PR got merged recently to allow import/export of hidden types but it did not include updating the saved objects management privilege. Should I create an issue for this?

@legrego
Copy link
Member

legrego commented Mar 11, 2021

@legrego I see that was added in the POC. It looks like this PR got merged recently to allow import/export of hidden types but it did not include updating the saved objects management privilege. Should I create an issue for this?

Good question -- @Bamieh do you have any insight here?

@ymao1
Copy link
Contributor Author

ymao1 commented Apr 26, 2021

PR for #94106 is open so removing blocked label since you can branch off the PR

@ymao1 ymao1 removed the blocked label Apr 26, 2021
@ymao1 ymao1 self-assigned this Apr 28, 2021
@kobelb kobelb added the needs-team Issues missing a team label label Jan 31, 2022
@botelastic botelastic bot removed the needs-team Issues missing a team label label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Actions Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants