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

[Security Solution][Fix] Empty Alert Table when upgrading from 8.8.x -> 8.9 #162063

Merged
merged 4 commits into from
Jul 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: variable name
  • Loading branch information
logeekal committed Jul 17, 2023

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
commit 63b674a7e656bd49d90ef2e960a92711666a00f1
Original file line number Diff line number Diff line change
@@ -142,8 +142,8 @@ export const migrateTriggerActionsVisibleColumnsAlertTable88xTo89 = (storage: St
if ('visibleColumns' in alertTableData) {
Copy link
Contributor

@michaelolo24 michaelolo24 Jul 17, 2023

Choose a reason for hiding this comment

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

Can we have one more early exit here?

const nonCompliant = alertTableData.visibleColumns.some(val => typeof val !== 'string')

if (!nonCompliant) return

... or this if you prefer

if (nonCompliant) {
  alertTableData.visibleColumns.map(...)
}

Right now the map will most likely run every time someone loads the table for every version after this

Copy link
Contributor Author

@logeekal logeekal Jul 17, 2023

Choose a reason for hiding this comment

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

You are right.. made these changes with a little tweak.

const visibleColumns =
alertTableData.visibleColumns as DataTableState['dataTable']['tableById'][string]['columns'];
const compliant = visibleColumns.every((val: unknown) => typeof val === 'string');
if (compliant) {
const v89CompliantFormat = visibleColumns.every((val: unknown) => typeof val === 'string');
if (v89CompliantFormat) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sweet, this works! 👍🏾

return;
}
const newVisibleColumns = visibleColumns