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

Expand configuration_links to support internal/external links #844

Merged
merged 14 commits into from
Dec 13, 2024

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Dec 12, 2024

What does this PR do?

Follow up to #834

Why is it important?

With #834 I added support to configuration_links to kibana manifest. This PR expands upon the previous change setting explicit formats for the urls:

External links should have url field of type http://... or https://..

      - title: Configure fleet
        url: "https://www.elastic.co/guide/en/fleet/master/fleet-overview.html"
        type: next_step
        content: "See docs"

Internal links should use the kbn:/ prefix (similar to what it's done in Kiban dev tools) and of course the link should be a valid Kibana link in order to work . Example corresponding to /app/integrations/browse:

      - title: Browse integrations
        url: "kbn:/app/integrations/browse"
        type: action

NOTE Kibana doesn't currently handle configuration_links field at all and just ignores this field, as I'm still working to the related changes. This change should be safe to merge.

Checklist

Related issues

Related to #832

@criamico criamico self-assigned this Dec 12, 2024
type: next_step
content: "Check your agents in Fleet"
appId: "fleet"
# bad format: `internal: false` should match http or https format
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to enforce this rule. I found the pattern field but can I enforce it conditionally (based on internal field)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you would need to use anyOf or oneOf. Something like this:

          internal:
            description: Set to true for internal kibana links, false for external links. Defaults to false.
            type: boolean
            oneOf:
              - const: true
                pattern: "^/"
              - const: false
                pattern: "^https?://"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be used if - then definitions here to set those conditions

I've tried to set these conditions in the manifest definition:

 $ git diff
diff --git spec/integration/manifest.spec.yml spec/integration/manifest.spec.yml
index cf39a4f..bd79026 100644
--- spec/integration/manifest.spec.yml
+++ spec/integration/manifest.spec.yml
@@ -235,6 +235,30 @@ spec:
             description: Set to true for internal kibana links, false for external links. Defaults to false.
             type: boolean
             default: false
+        allOf:
+          - if:
+              properties:
+                internal:
+                  const: true
+            then:
+              required:
+                - appId
+              properties:
+                url:
+                  type: string
+                  pattern: '^/'
+          - if:
+              properties:
+                internal:
+                  const: false
+            then:
+              not:
+                required:
+                  - appId
+              properties:
+                url:
+                  type: string
+                  pattern: '^http(s)?://'
         required:
         - title
         - url

Adding those definitions there are some errors, that probably are legit.

These conditions enforce:

  • a pattern for url depending on the internal value
  • appId is set required or not depending on the internal value.
    Is there any other condition that should be added ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm switching to use format kbn:... for internal links as per below discussion. Example kbn:app/integrations/browse

@criamico criamico marked this pull request as ready for review December 12, 2024 09:44
@criamico criamico requested a review from a team as a code owner December 12, 2024 09:44
Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a suggestion to achieve conditional rules in the JSON schema.

type: next_step
content: "Check your agents in Fleet"
appId: "fleet"
# bad format: `internal: false` should match http or https format
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be used if - then definitions here to set those conditions

I've tried to set these conditions in the manifest definition:

 $ git diff
diff --git spec/integration/manifest.spec.yml spec/integration/manifest.spec.yml
index cf39a4f..bd79026 100644
--- spec/integration/manifest.spec.yml
+++ spec/integration/manifest.spec.yml
@@ -235,6 +235,30 @@ spec:
             description: Set to true for internal kibana links, false for external links. Defaults to false.
             type: boolean
             default: false
+        allOf:
+          - if:
+              properties:
+                internal:
+                  const: true
+            then:
+              required:
+                - appId
+              properties:
+                url:
+                  type: string
+                  pattern: '^/'
+          - if:
+              properties:
+                internal:
+                  const: false
+            then:
+              not:
+                required:
+                  - appId
+              properties:
+                url:
+                  type: string
+                  pattern: '^http(s)?://'
         required:
         - title
         - url

Adding those definitions there are some errors, that probably are legit.

These conditions enforce:

  • a pattern for url depending on the internal value
  • appId is set required or not depending on the internal value.
    Is there any other condition that should be added ?

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered to use urls with the kbn: prefix as we do in other places?

spec/integration/manifest.spec.yml Outdated Show resolved Hide resolved
spec/integration/manifest.spec.yml Outdated Show resolved Hide resolved
Comment on lines 43 to 48
- title: View Agents
url: "/agents"
type: next_step
content: "View security overview"
content: "Check your agents in Fleet"
appId: "fleet"
internal: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding the internal setting, could we use the urls prefixed by kbn that are used in many other places?

      - title: View Agents
        url: "kbn:/app/fleet/agents"
        type: next_step
        content: "Check your agents in Fleet"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any examples in package-spec, but maybe you refer to the Kibana dev tools?

We could use this format, it requires to do some more manipulation in kibana as the url needs to be split (it cannot be used directly by kibana this way) and it's also less explicit. However, reading your other comments I understand your concerns that this could be a bit too specific to Kibana internal way of handling urls.

Copy link
Contributor Author

@criamico criamico Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR and the description based on this discussion.

type: next_step
content: "Check your agents in Fleet"
appId: "fleet"
# bad format: `internal: false` should match http or https format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you would need to use anyOf or oneOf. Something like this:

          internal:
            description: Set to true for internal kibana links, false for external links. Defaults to false.
            type: boolean
            oneOf:
              - const: true
                pattern: "^/"
              - const: false
                pattern: "^https?://"

test/packages/good_v3/manifest.yml Outdated Show resolved Hide resolved
spec/integration/manifest.spec.yml Outdated Show resolved Hide resolved
jsoriano
jsoriano previously approved these changes Dec 12, 2024
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer this approach based on the url prefixes, thanks!

Added a suggestion about how patterns are defined.

spec/integration/manifest.spec.yml Outdated Show resolved Hide resolved
test/packages/good_v3/manifest.yml Outdated Show resolved Hide resolved
jsoriano
jsoriano previously approved these changes Dec 12, 2024
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

spec/integration/manifest.spec.yml Outdated Show resolved Hide resolved
@elasticmachine
Copy link

💚 Build Succeeded

History

cc @criamico

@mrodm mrodm merged commit 6cad88c into elastic:main Dec 13, 2024
3 checks passed
@criamico criamico deleted the expand_configuration_links branch December 13, 2024 14:18
criamico added a commit to elastic/kibana that referenced this pull request Dec 17, 2024
…ut (#203824)

## Summary

Display next steps and actions in agentless integrations flyout. This PR
is based off the following changes:

**Agentless flyout**
Introduced with #199567

**package-spec**
The definitions for package-spec have been updated in these two PRs:
- elastic/package-spec#834
- elastic/package-spec#844
Any agentless package can now define internal links with format
`kbn:/app/...` and external links with format `https://...`. This PR
shows a card or a button linking to these urls in the new agentless
flyout

**Connectors**
Agentless integration now expose connectors name and id in the package
policy (see code
[here](https://github.com/elastic/integrations/blob/69fd5a26c4d0a8e9e999c51fb49a2cf28c078dd2/packages/elastic_connectors/manifest.yml#L45-L62)
for elastic connectors integration).
<img width="1003" alt="Screenshot 2024-12-16 at 16 30 22"
src="https://github.com/user-attachments/assets/70b3471e-51bb-4e79-95a4-843e20128c26"
/>

This PR creates a dynamic link to the connector configured in the policy
and shows it in the agentless flyout.

### Testing
- First of all, enable agentless following the steps under `Testing` in
[ this PR](#199567). Follow up to
step 3
- Instead of installing CSPM, install this test package
[agentless_package_links-0.0.1.zip](https://github.com/user-attachments/files/18152872/agentless_package_links-0.0.1.zip)
with the upload command
```
curl -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true' http://localhost:5601/YOURPATH/api/fleet/epm/packages -u elastic:changeme --data-binary @agentless_package_links-0.0.1.zip
```
- Once appears installed, create a package policy with this new
integration. Make sure to choose `agentless` as deployment mode
<img width="1278" alt="Screenshot 2024-12-16 at 16 22 09"
src="https://github.com/user-attachments/assets/7104bf2a-e419-4efa-b352-278ad2057951"
/>

- Enroll an agent to the newly created "agentless" policy by using the
token (it's available in the token page)
- Go back to integrations, you should see a page like this one:
<img width="1569" alt="Screenshot 2024-12-16 at 16 38 18"
src="https://github.com/user-attachments/assets/de770984-985e-449e-b6e3-5c78eb5d3926"
/>

- Click on the state ("pending"/"healhty"/"unhealthy") and see the
flyout. If the enrollment was successful, you should see some cards and
buttons that link to internal and external links in kibana

<img width="878" alt="Screenshot 2024-12-16 at 16 21 57"
src="https://github.com/user-attachments/assets/c77b224f-882c-4d52-956a-744e94e36f1e"
/>

### Testing the connector cards
- First create a new connector: go to
`app/elasticsearch/content/connectors` and click on "new connector". For
this purpose there's no need to complete the procedure
- Note down the name and id of the connector
<img width="1789" alt="Screenshot 2024-12-16 at 16 42 00"
src="https://github.com/user-attachments/assets/b60e491c-809a-40d5-8d01-12b225896fca"
/>
<img width="1789" alt="Screenshot 2024-12-16 at 16 42 00"
src="https://github.com/user-attachments/assets/1adc65e4-0b3b-4e03-9e65-5cc01385b0db"
/>
- Go back to the integration policy previously installed. Enable the
"Test Connector" input and add the name and id from above.
- The agentless flyout should now have a card that will link the user to
`app/elasticsearch/content/connectors/<id>`


### Checklist

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials

---------

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 17, 2024
…ut (elastic#203824)

## Summary

Display next steps and actions in agentless integrations flyout. This PR
is based off the following changes:

**Agentless flyout**
Introduced with elastic#199567

**package-spec**
The definitions for package-spec have been updated in these two PRs:
- elastic/package-spec#834
- elastic/package-spec#844
Any agentless package can now define internal links with format
`kbn:/app/...` and external links with format `https://...`. This PR
shows a card or a button linking to these urls in the new agentless
flyout

**Connectors**
Agentless integration now expose connectors name and id in the package
policy (see code
[here](https://github.com/elastic/integrations/blob/69fd5a26c4d0a8e9e999c51fb49a2cf28c078dd2/packages/elastic_connectors/manifest.yml#L45-L62)
for elastic connectors integration).
<img width="1003" alt="Screenshot 2024-12-16 at 16 30 22"
src="https://github.com/user-attachments/assets/70b3471e-51bb-4e79-95a4-843e20128c26"
/>

This PR creates a dynamic link to the connector configured in the policy
and shows it in the agentless flyout.

### Testing
- First of all, enable agentless following the steps under `Testing` in
[ this PR](elastic#199567). Follow up to
step 3
- Instead of installing CSPM, install this test package
[agentless_package_links-0.0.1.zip](https://github.com/user-attachments/files/18152872/agentless_package_links-0.0.1.zip)
with the upload command
```
curl -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true' http://localhost:5601/YOURPATH/api/fleet/epm/packages -u elastic:changeme --data-binary @agentless_package_links-0.0.1.zip
```
- Once appears installed, create a package policy with this new
integration. Make sure to choose `agentless` as deployment mode
<img width="1278" alt="Screenshot 2024-12-16 at 16 22 09"
src="https://github.com/user-attachments/assets/7104bf2a-e419-4efa-b352-278ad2057951"
/>

- Enroll an agent to the newly created "agentless" policy by using the
token (it's available in the token page)
- Go back to integrations, you should see a page like this one:
<img width="1569" alt="Screenshot 2024-12-16 at 16 38 18"
src="https://github.com/user-attachments/assets/de770984-985e-449e-b6e3-5c78eb5d3926"
/>

- Click on the state ("pending"/"healhty"/"unhealthy") and see the
flyout. If the enrollment was successful, you should see some cards and
buttons that link to internal and external links in kibana

<img width="878" alt="Screenshot 2024-12-16 at 16 21 57"
src="https://github.com/user-attachments/assets/c77b224f-882c-4d52-956a-744e94e36f1e"
/>

### Testing the connector cards
- First create a new connector: go to
`app/elasticsearch/content/connectors` and click on "new connector". For
this purpose there's no need to complete the procedure
- Note down the name and id of the connector
<img width="1789" alt="Screenshot 2024-12-16 at 16 42 00"
src="https://github.com/user-attachments/assets/b60e491c-809a-40d5-8d01-12b225896fca"
/>
<img width="1789" alt="Screenshot 2024-12-16 at 16 42 00"
src="https://github.com/user-attachments/assets/1adc65e4-0b3b-4e03-9e65-5cc01385b0db"
/>
- Go back to the integration policy previously installed. Enable the
"Test Connector" input and add the name and id from above.
- The agentless flyout should now have a card that will link the user to
`app/elasticsearch/content/connectors/<id>`

### Checklist

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials

---------

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 790c589)
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Dec 19, 2024
…ut (elastic#203824)

## Summary

Display next steps and actions in agentless integrations flyout. This PR
is based off the following changes:

**Agentless flyout**
Introduced with elastic#199567

**package-spec**
The definitions for package-spec have been updated in these two PRs:
- elastic/package-spec#834
- elastic/package-spec#844
Any agentless package can now define internal links with format
`kbn:/app/...` and external links with format `https://...`. This PR
shows a card or a button linking to these urls in the new agentless
flyout

**Connectors**
Agentless integration now expose connectors name and id in the package
policy (see code
[here](https://github.com/elastic/integrations/blob/69fd5a26c4d0a8e9e999c51fb49a2cf28c078dd2/packages/elastic_connectors/manifest.yml#L45-L62)
for elastic connectors integration).
<img width="1003" alt="Screenshot 2024-12-16 at 16 30 22"
src="https://github.com/user-attachments/assets/70b3471e-51bb-4e79-95a4-843e20128c26"
/>

This PR creates a dynamic link to the connector configured in the policy
and shows it in the agentless flyout.

### Testing
- First of all, enable agentless following the steps under `Testing` in
[ this PR](elastic#199567). Follow up to
step 3
- Instead of installing CSPM, install this test package
[agentless_package_links-0.0.1.zip](https://github.com/user-attachments/files/18152872/agentless_package_links-0.0.1.zip)
with the upload command
```
curl -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true' http://localhost:5601/YOURPATH/api/fleet/epm/packages -u elastic:changeme --data-binary @agentless_package_links-0.0.1.zip
```
- Once appears installed, create a package policy with this new
integration. Make sure to choose `agentless` as deployment mode
<img width="1278" alt="Screenshot 2024-12-16 at 16 22 09"
src="https://github.com/user-attachments/assets/7104bf2a-e419-4efa-b352-278ad2057951"
/>

- Enroll an agent to the newly created "agentless" policy by using the
token (it's available in the token page)
- Go back to integrations, you should see a page like this one:
<img width="1569" alt="Screenshot 2024-12-16 at 16 38 18"
src="https://github.com/user-attachments/assets/de770984-985e-449e-b6e3-5c78eb5d3926"
/>

- Click on the state ("pending"/"healhty"/"unhealthy") and see the
flyout. If the enrollment was successful, you should see some cards and
buttons that link to internal and external links in kibana

<img width="878" alt="Screenshot 2024-12-16 at 16 21 57"
src="https://github.com/user-attachments/assets/c77b224f-882c-4d52-956a-744e94e36f1e"
/>

### Testing the connector cards
- First create a new connector: go to
`app/elasticsearch/content/connectors` and click on "new connector". For
this purpose there's no need to complete the procedure
- Note down the name and id of the connector
<img width="1789" alt="Screenshot 2024-12-16 at 16 42 00"
src="https://github.com/user-attachments/assets/b60e491c-809a-40d5-8d01-12b225896fca"
/>
<img width="1789" alt="Screenshot 2024-12-16 at 16 42 00"
src="https://github.com/user-attachments/assets/1adc65e4-0b3b-4e03-9e65-5cc01385b0db"
/>
- Go back to the integration policy previously installed. Enable the
"Test Connector" input and add the name and id from above.
- The agentless flyout should now have a card that will link the user to
`app/elasticsearch/content/connectors/<id>`


### Checklist

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials

---------

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants