-
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 Posture][Benchmark Improvements] Rules Page Improvements phase 1 + Empty Benchmark #173345
Conversation
/ci |
/ci |
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
default: | ||
return null; |
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.
is this needed? we will already get undefined
as default if the matching strings won't be passed
default: | ||
return null; |
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.
same comment here
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; | ||
}; |
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.
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" |
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 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'} /> |
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.
<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
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.
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 ?
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.
so there's no difference at all between cspm kspm and all? maybe just change it to be either cloud or vulnerabilities?
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.
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}> |
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.
A few fixes needed for this bar:
- there is an empty space left on the right of the screen
- the buttons are not equal in size
- in the figma they appear as grouped buttons:
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
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.
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
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 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; |
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.
lets make sure the sizes are equal
options: FindCspBenchmarkRuleRequest | ||
): Promise<FindCspBenchmarkRuleResponse> => { | ||
if (!options.benchmarkId) { | ||
throw new Error('Please provide BenchmarkId'); |
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.
throw new Error('Please provide BenchmarkId'); | |
throw new Error('Please provide benchmarkId'); |
throw new Error('Please provide BenchmarkId'); | ||
} | ||
|
||
const benchmarkId = options.benchmarkId ? options.benchmarkId : ''; |
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.
this will never happen since we throw an error if its missing
@@ -0,0 +1,237 @@ | |||
/* |
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.
all test files should be have a suffix test.ts
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 thought thats only for Jest test ? this one is FTR no ?
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.
MB, missed the location of the file
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.
ruleNumber?: string; | ||
} | ||
|
||
// export type PageUrlParams = Record<'benchmarkId' | 'benchmarkVersion', BenchmarksCisId | string>; |
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 this be removed?
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, forgot to remove this
benchmarkVersion, | ||
benchmarkId, | ||
}: { | ||
benchmarkName: BenchmarksCisId; |
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.
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.
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.
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
benchmarkName={benchmarkId || ''} | ||
benchmarkId={benchmarkId || ''} |
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.
if those are the same we dont need both
…into rule-page-phase1-clean
render: (benchmarkId: Benchmark['id'], benchmark: Benchmark) => ( | ||
<BenchmarkButtonLink | ||
benchmarkId={benchmarkId || ''} | ||
benchmarkVersion={benchmark.version || ''} | ||
/> | ||
), |
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.
could this render work with benchmark only?
render: (benchmark: Benchmark) => (
<BenchmarkButtonLink
benchmarkId={benchmark.id || ''}
benchmarkVersion={benchmark.version || ''}
/>
)
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.
nope :(
})} | ||
/> | ||
<EuiFlexGroup gutterSize="s"> | ||
<EuiFlexItem grow={false} style={{ marginBottom: `6px` }}> |
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.
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:
<EuiFlexItem grow={false} style={{ marginBottom: `6px` }}> | |
<EuiFlexItem grow={false} style={{ marginBottom: 6 }}> |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @animehart |
|
||
const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25; | ||
|
||
export const findCspBenchmarkRuleRequestSchema = schema.object({ |
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.
@animehart was there any breaking change to the interfaces so we needed to introduce a new version?
Summary
This PR
Summarize your PR. If it involves visual changes include a screenshot or gif.