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

[Cloud Security Posture][Benchmark Improvements] Rules Page Improvements phase 1 + Empty Benchmark #173345

Merged
merged 18 commits into from
Dec 26, 2023

Conversation

animehart
Copy link
Contributor

@animehart animehart commented Dec 14, 2023

Summary

This PR

  • updates the Rules Page looks to accomodate the changes we made to Benchmark page
  • adds Empty page (when user doesn't have any CSP integration) for Benchmark page
  • updates the NoFindings components message when users don't have any CSP integration installed

Summarize your PR. If it involves visual changes include a screenshot or gif.
Screenshot 2023-12-01 at 1 07 39 AM
Screenshot 2023-12-18 at 2 29 24 PM

@animehart
Copy link
Contributor Author

/ci

@animehart
Copy link
Contributor Author

/ci

@animehart animehart marked this pull request as ready for review December 17, 2023 04:41
@animehart animehart requested a review from a team as a code owner December 17, 2023 04:41
@JordanSh JordanSh added release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related labels Dec 19, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

Comment on lines 189 to 190
default:
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed? we will already get undefined as default if the matching strings won't be passed

Comment on lines 206 to 207
default:
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment here

Comment on lines 211 to 224
export const getBenchmarkFilterQuery = (
id: BenchmarkId,
version?: string,
selectParams?: BenchmarkRuleSelectParams
): string => {
const baseQuery = `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${id} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${version}"`;
const sectionQuery = ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${selectParams?.section}"`;
const ruleNumberQuery = ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.rule_number: "${selectParams?.ruleNumber}"`;
if (!selectParams?.section && !selectParams?.ruleNumber) return baseQuery;
else if (selectParams.section && selectParams.ruleNumber)
return baseQuery + sectionQuery + ruleNumberQuery;
else if (selectParams.section) return baseQuery + sectionQuery;
else return baseQuery + ruleNumberQuery;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const getBenchmarkFilterQuery = (
id: BenchmarkId,
version?: string,
selectParams?: BenchmarkRuleSelectParams
): string => {
const baseQuery = `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${id} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${version}"`;
const sectionQuery = ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${selectParams?.section}"`;
const ruleNumberQuery = ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.rule_number: "${selectParams?.ruleNumber}"`;
if (!selectParams?.section && !selectParams?.ruleNumber) return baseQuery;
else if (selectParams.section && selectParams.ruleNumber)
return baseQuery + sectionQuery + ruleNumberQuery;
else if (selectParams.section) return baseQuery + sectionQuery;
else return baseQuery + ruleNumberQuery;
};
export const getBenchmarkFilterQuery = (
id: BenchmarkId,
version?: string,
selectParams?: BenchmarkRuleSelectParams
): string => {
const baseQuery = `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${id} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${version}"`;
const sectionQuery = selectParams?.section ? ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${selectParams.section}"` : '';
const ruleNumberQuery = selectParams?.ruleNumber ? ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.rule_number: "${selectParams.ruleNumber}"` : '';
return baseQuery + sectionQuery + ruleNumberQuery;
};

This should do the same thing but keep it easier to read

</EuiLink>
),
}}
defaultMessage="Maintain the confidentiality, integrity, and availability of your data in the cloud by continuously identifying and remediating potential configuration risks, like publicly accessible s3 buckets, using Elastic Security posture management for Cloud & Kubernetes"
Copy link
Contributor

Choose a reason for hiding this comment

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

let's do this in a different PR. as we talked about it in the last sync, product & design still need to provide a final version for this text

}
/>
{showConfigurationInstallPrompt ? (
<NoFindingsStates posturetype={'all'} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<NoFindingsStates posturetype={'all'} />
<NoFindingsStates postureType={'all'} />

let's change the prop to use camel casing.
also, what does 'all' does? i did a quick look for it and couldn't find a use of it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

originally back then, 'all' means either cspm or kspm (it doesnt matter). In this case it doesn't really matter if we use 'all', 'cspm' or 'kspm' as we wanted to render the case where both cspm and kspm are both not-installed.
Should I just use 'cspm' or 'kspm' in this case then ?

Copy link
Contributor

Choose a reason for hiding this comment

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

so there's no difference at all between cspm kspm and all? maybe just change it to be either cloud or vulnerabilities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no i mean, just for this case (where we want to use NoFindingsState component for benchmark empty page), it doesn't matter whether we use cspm/kspm/all.

return (
<EuiFlexGroup>
<EuiFlexItem>
<EuiFlexItem grow={4}>
Copy link
Contributor

Choose a reason for hiding this comment

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

image

A few fixes needed for this bar:

  1. there is an empty space left on the right of the screen
  2. the buttons are not equal in size
  3. in the figma they appear as grouped buttons:

Figma:
image

Actual:
image

meaning they share borders. try to see if we can achieve that without too many hacks. if not, let add some space between them, like around 4px. it looks weird without any space and without combined borders

It also seems like they behave a bit differently to what is described in the designs, missing multi selects options and showing the number of selected values. if we dont have a specific ticket for that please open a new one and add it to the epic

Copy link
Contributor Author

@animehart animehart Dec 19, 2023

Choose a reason for hiding this comment

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

Showing number of selected values might require custom component as such in my opinion is better to be done on separate PR
Also regarding the multi select options it is listed on a different ticket #171220 (I'll work on this on a different PR later)
We can probably just add the requirement for the custom component on the ticket above as well

Copy link
Contributor

Choose a reason for hiding this comment

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

yes a different pr for sure. just as long as we know we still missing those. for this pr just update the css

<EuiFlexGroup gutterSize="none">
<EuiFlexItem
css={css`
max-width: 200px;
Copy link
Contributor

Choose a reason for hiding this comment

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

lets make sure the sizes are equal

options: FindCspBenchmarkRuleRequest
): Promise<FindCspBenchmarkRuleResponse> => {
if (!options.benchmarkId) {
throw new Error('Please provide BenchmarkId');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new Error('Please provide BenchmarkId');
throw new Error('Please provide benchmarkId');

throw new Error('Please provide BenchmarkId');
}

const benchmarkId = options.benchmarkId ? options.benchmarkId : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

this will never happen since we throw an error if its missing

@@ -0,0 +1,237 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

all test files should be have a suffix test.ts

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 thought thats only for Jest test ? this one is FTR no ?

Copy link
Contributor

@JordanSh JordanSh Dec 20, 2023

Choose a reason for hiding this comment

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

MB, missed the location of the file

@animehart animehart requested a review from JordanSh December 20, 2023 17:43
Copy link
Contributor

@JordanSh JordanSh left a comment

Choose a reason for hiding this comment

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

I approve the changes but i checked out the PR, installed an integration and didn't see any rules. can you double check this and let me know if its something that happens to you as well? try starting from a clean env

image

ruleNumber?: string;
}

// export type PageUrlParams = Record<'benchmarkId' | 'benchmarkVersion', BenchmarksCisId | string>;
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops, forgot to remove this

benchmarkVersion,
benchmarkId,
}: {
benchmarkName: BenchmarksCisId;
Copy link
Contributor

@JordanSh JordanSh Dec 21, 2023

Choose a reason for hiding this comment

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

IDK if this is considered nit picky but we named the prop benchmarkName and type it as BenchmarkCisId, and later call getBenchmarkCisName passing benchmarkName as an argument.

its nothing crucial for the functionality of the code but i think it will be more readable if we change benchmarkName to benchmarkCisId.

the type would make more sense and calling getBenchmarkCisName(benchmarkCisId) is clearer that it generates a name out of the cis id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually I think its better to just call it benchmarkId instead of benchmarkName or benchmarkCisId, considering the field itself is called id on the object

Comment on lines 157 to 158
benchmarkName={benchmarkId || ''}
benchmarkId={benchmarkId || ''}
Copy link
Contributor

Choose a reason for hiding this comment

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

if those are the same we dont need both

@animehart animehart requested a review from JordanSh December 21, 2023 17:06
Comment on lines +152 to +157
render: (benchmarkId: Benchmark['id'], benchmark: Benchmark) => (
<BenchmarkButtonLink
benchmarkId={benchmarkId || ''}
benchmarkVersion={benchmark.version || ''}
/>
),
Copy link
Contributor

Choose a reason for hiding this comment

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

could this render work with benchmark only?

render: (benchmark: Benchmark) => (
      <BenchmarkButtonLink
        benchmarkId={benchmark.id || ''}
        benchmarkVersion={benchmark.version || ''}
      />
    )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope :(

})}
/>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={false} style={{ marginBottom: `6px` }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

really minor but in JSS you dont have to use pixels as they are the default value if you just pass numbers.

meaning this will work the same:

Suggested change
<EuiFlexItem grow={false} style={{ marginBottom: `6px` }}>
<EuiFlexItem grow={false} style={{ marginBottom: 6 }}>

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cloudSecurityPosture 434 432 -2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cloudSecurityPosture 452.0KB 452.0KB -48.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cloudSecurityPosture 15.6KB 15.6KB -39.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @animehart

@animehart animehart merged commit aa2a0f3 into elastic:main Dec 26, 2023
19 checks passed
@kibanamachine kibanamachine added v8.13.0 backport:skip This commit does not require backporting labels Dec 26, 2023

const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25;

export const findCspBenchmarkRuleRequestSchema = schema.object({
Copy link
Contributor

Choose a reason for hiding this comment

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

@animehart was there any breaking change to the interfaces so we needed to introduce a new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cloud Security] Rules table changes - Phase I [Cloud Security] Benchmarks page empty state - Phase I
7 participants