-
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
[Cloud Security] Filters for Contextual Flyout Datagrid #201708
[Cloud Security] Filters for Contextual Flyout Datagrid #201708
Conversation
…ies and Misconfigurations
/ci |
/ci |
1 similar comment
/ci |
/ci |
/ci |
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
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.
Looks good, I left many comments and would be glad to discuss them if you want.
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.
:opinion
We should consider renaming this file to something like queries.ts
because all exported functions are related to building queries.
This is a little pet peeve of mine when directories are called utils
and files helpers
. I've seen this in many cases over time files like this become a kitchen sink of common functions and it becomes hard to reorganize the structure later. This will be especially hard to reorganize if other plugins start to use our shared package.
x-pack/packages/kbn-cloud-security-posture/common/queries.ts
Since this is a shared package everything is by definition common
so another suggestion is to remove comment altogether
x-pack/packages/kbn-cloud-security-posture/queries.ts
wdyt?
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.
hmmm you are right that almost all of the helpers functions here are query related and I can see the issue that this might have later in the future
I'm down to do this change but maybe in separate ticket/PR (as this PR is for Filters for the Datagrid, and this suggested change might touch other features thats not related at all with Contextual Flyout)
wdyt ?
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.
Yes please and thank you! Can you open that issue as a tech debt?
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.
Can you add the link to the tech debt issue here?
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.
Lemme know if i missed anything :)
x-pack/packages/kbn-cloud-security-posture/public/src/utils/vulnerability_helpers.ts
Outdated
Show resolved
Hide resolved
x-pack/packages/kbn-cloud-security-posture/public/src/utils/vulnerability_helpers.ts
Outdated
Show resolved
Hide resolved
x-pack/packages/kbn-cloud-security-posture/public/src/utils/vulnerability_helpers.ts
Outdated
Show resolved
Hide resolved
x-pack/packages/security-solution/distribution_bar/src/distribution_bar.tsx
Outdated
Show resolved
Hide resolved
x-pack/packages/security-solution/distribution_bar/src/distribution_bar.tsx
Outdated
Show resolved
Hide resolved
...ic/cloud_security_posture/components/csp_details/misconfiguration_findings_details_table.tsx
Outdated
Show resolved
Hide resolved
...ic/cloud_security_posture/components/csp_details/misconfiguration_findings_details_table.tsx
Outdated
Show resolved
Hide resolved
...lic/cloud_security_posture/components/csp_details/vulnerabilities_findings_details_table.tsx
Outdated
Show resolved
Hide resolved
…hart/kibana into contextual-flyout-datagrid-filters
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.
Almost there, just a few things to resolve. 🙏
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.
looks good, added some suggestions
@@ -43,7 +43,14 @@ export const buildMutedRulesFilter = ( | |||
return mutedRulesFilterQuery; | |||
}; | |||
|
|||
export const buildEntityFlyoutPreviewQuery = (field: string, queryValue?: string) => { | |||
export const buildEntityFlyoutPreviewQuery = ( |
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.
I guess we could create some High Order functions instead:
// Generic function
export const buildGenericEntityFlyoutPreviewQuery = (
field: string,
queryValue?: string,
status?: string,
queryField?: string
) => {
return {
bool: {
filter: [
{
bool: {
should: [
{
term: {
[field]: `${queryValue || ''}`,
},
},
],
minimum_should_match: 1,
},
},
status && queryField
? {
bool: {
should: [
{
term: {
[queryField]: status,
},
},
],
minimum_should_match: 1,
},
}
: undefined,
].filter(Boolean),
},
};
};
// Higher-order function for Misconfiguration
export const buildMisconfigurationEntityFlyoutPreviewQuery = (
field: string,
queryValue?: string,
status?: string
) => {
const queryField = 'result.evaluation';
return buildGenericEntityFlyoutPreviewQuery(field, queryValue, status, queryField);
};
// Higher-order function for Vulnerability
export const buildVulnerabilityEntityFlyoutPreviewQuery = (
field: string,
queryValue?: string,
status?: string
) => {
const queryField = 'vulnerability.severity';
return buildGenericEntityFlyoutPreviewQuery(field, queryValue, status, queryField);
};
@@ -50,6 +55,14 @@ export const getVulnerabilityStats = ( | |||
), | |||
count: counts.none, | |||
color: getSeverityStatusColor(VULNERABILITIES_SEVERITY.UNKNOWN), | |||
filter: () => { | |||
filterFunction?.('UNKNOWN'); |
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.
let's update to use the constant:
filterFunction?.(VULNERABILITIES_SEVERITY.UNKNOWN);
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.
woops
@@ -41,6 +47,14 @@ const getFindingsStats = (passedFindingsStats: number, failedFindingsStats: numb | |||
), | |||
count: passedFindingsStats, | |||
color: euiThemeVars.euiColorSuccess, | |||
filter: () => { | |||
filterFunction('passed'); |
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.
can we add 'passed' and 'failed' values to a constant?
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.
THI changes lgtm
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Unknown metric groupsAPI count
History
|
Starting backport for target branches: 8.x |
## Summary https://github.com/user-attachments/assets/59ace35f-62b8-4c08-bf2c-eed200db791d This PR is for adding Filters for Contextual Flytout Datagrid (cherry picked from commit 2f62cde)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
… (#202556) # Backport This will backport the following commits from `main` to `8.x`: - [[Cloud Security] Filters for Contextual Flyout Datagrid (#201708)](#201708) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Rickyanto Ang","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-02T17:26:03Z","message":"[Cloud Security] Filters for Contextual Flyout Datagrid (#201708)\n\n## Summary\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/59ace35f-62b8-4c08-bf2c-eed200db791d\r\n\r\nThis PR is for adding Filters for Contextual Flytout Datagrid","sha":"2f62cdebfcc585689cd266495a82c2049fcc19ad","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud Security","backport:prev-minor","v8.18.0"],"title":"[Cloud Security] Filters for Contextual Flyout Datagrid","number":201708,"url":"https://github.com/elastic/kibana/pull/201708","mergeCommit":{"message":"[Cloud Security] Filters for Contextual Flyout Datagrid (#201708)\n\n## Summary\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/59ace35f-62b8-4c08-bf2c-eed200db791d\r\n\r\nThis PR is for adding Filters for Contextual Flytout Datagrid","sha":"2f62cdebfcc585689cd266495a82c2049fcc19ad"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201708","number":201708,"mergeCommit":{"message":"[Cloud Security] Filters for Contextual Flyout Datagrid (#201708)\n\n## Summary\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/59ace35f-62b8-4c08-bf2c-eed200db791d\r\n\r\nThis PR is for adding Filters for Contextual Flytout Datagrid","sha":"2f62cdebfcc585689cd266495a82c2049fcc19ad"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Rickyanto Ang <[email protected]>
## Summary https://github.com/user-attachments/assets/59ace35f-62b8-4c08-bf2c-eed200db791d This PR is for adding Filters for Contextual Flytout Datagrid
## Summary https://github.com/user-attachments/assets/59ace35f-62b8-4c08-bf2c-eed200db791d This PR is for adding Filters for Contextual Flytout Datagrid
## Summary https://github.com/user-attachments/assets/59ace35f-62b8-4c08-bf2c-eed200db791d This PR is for adding Filters for Contextual Flytout Datagrid
Summary
Screen.Recording.2024-11-26.at.4.52.58.PM.mov
This PR is for adding Filters for Contextual Flytout Datagrid