-
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
[Security Solution]Fix incorrect number of invalid connectors is shown on the toast message #152313
Changes from all commits
c75409b
a9e7772
4434471
7ade2cc
9f710a2
4d2e9a1
a2b46ef
21308a4
bc5547c
fa9a39e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,6 +174,7 @@ describe('importRuleActionConnectors', () => { | |
'1 connector is missing. Connector id missing is: cabc78e0-9031-11ed-b076-53cc4d57aaf1', | ||
status_code: 404, | ||
}, | ||
id: 'cabc78e0-9031-11ed-b076-53cc4d57aaf1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, you provide both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are different And we need it, in case the user has multiple rules in one file and not all of them are failing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. For some reason |
||
rule_id: 'rule-1', | ||
}, | ||
], | ||
|
@@ -220,6 +221,7 @@ describe('importRuleActionConnectors', () => { | |
status_code: 404, | ||
}, | ||
rule_id: 'rule-1', | ||
id: 'cabc78e0-9031-11ed-b076-53cc4d57aaf1,cabc78e0-9031-11ed-b076-53cc4d57aaf2', | ||
}, | ||
], | ||
warnings: [], | ||
|
@@ -270,6 +272,7 @@ describe('importRuleActionConnectors', () => { | |
status_code: 404, | ||
}, | ||
rule_id: 'rule-1,rule-2', | ||
id: 'cabc78e0-9031-11ed-b076-53cc4d57aaf1,cabc78e0-9031-11ed-b076-53cc4d57aaf2', | ||
}, | ||
], | ||
warnings: [], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ export const handleActionsHaveNoConnectors = ( | |
: 'connector is missing. Connector id missing is:'; | ||
errors.push( | ||
createBulkErrorObject({ | ||
id: actionsIds.join(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll go ahead and add a comment there. Looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review bc5547c |
||
statusCode: 404, | ||
message: `${actionsIds.length} ${errorMessage} ${actionsIds.join(', ')}`, | ||
ruleId: ruleIds, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll go ahead and add a comment there. Looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review here bc5547c |
||
|
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.
Why isn't it possible to just calculate the number of errors? Can we get more than one error per connector?
Generally speaking
ImportRulesResponseError | ImportResponseError
only differs byid
andrule_id
which come from BulkError (just the factBulkError
allows to omit bothid
andrule_id
which is not supposed to happen I expect but it's another story). If we still supportrule_id
(most probably for backwards compatibility) can we have a situation when it's in use and this code is gonna fail? If it's not a case so then we should removerule_id
soas ImportResponseError
type casting won't be necessary.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.
Why isn't it possible to just calculate the number of errors? Can we get more than one error per connector?
-Yes true.
Forex. if the user has rule to import in one file, and this rule has 3 connectors.
For instance, if 2 of them have missing connectors, what will happen as per the Old workflow=> One error message will be generated with the count of the failing connectors, and one error object will be pushed in the array.
2 connectors are missing. Connector ids missing are: X, Y
And just to clarify the
id
here is the action-connectorsid
not therule_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.
Hey @maximpn !
rule_id
was initially created to act as a signature id so that a rule could be recognized, say, across platforms. This allows sigma, snort, suricata etc to identify a rule with a singular "signature id" that is never regenerated over time. So the concept ofrule_id
should hopefully stick around the solution unless platform has come up with a way for it to be supported more globally within a saved object. This comes in very handy on import when a user could be importing a rule they've ported over from elsewhere and want to maintain it's reference to the signature id. I don't think it would be in our interest to remove it's use. Like @WafaaNasr pointed out, theid
she references is to the connector, therule_id
points back to the rule that had an action pointing to said connector so the user knows which rule was the source of the error.If there's a worry that
id
would not exist inconnectorError
because it ends up beingImportRulesResponseError
vsImportResponseError
maybe we can add a check forid != null
.If there's larger refactoring you think is necessary (this route is now a bit dated and could benefit from refactoring as it's complexity has grown a lot), feel free to create a ticket and we can keep discussing what the response should look like and how
rule_id
fits into the import use case.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.
Hey @yctercero, thank you for the explanation! My concern is misleading types as
BulkError
at backend andImportRulesResponseError
at frontend don't look related to the connectors.ImportResponseError
looks too generic (by name). According to what I see in the code it's pretty easy to use some tailored for connectors error type whichaction_connectors_errors
will use.Absence of such a type leads to reusing
id
andrule_id
fields to store serialized arrays in a case of missing connectors. I'm afraid it doesn't match with SO importer errors so that importer seems to returning an error per connector. Merging it now and creating a ticket looks like adding a technical debt while we already have it a lot.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.
There's definitely refactoring needed overall on import. It used to just be rules and now is exceptions, actions and connectors. With the added comments, we can certainly look to simplify and refactor this flow.
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 understand the concern with creating technical debt. As we are far into the BCs, adding scope in this bug fix can also open us up to further bugs. Our team is working on documenting this route, the technical debt and suggested updates. I can be sure to make reference back to your concerns to ensure they're addressed in any upcoming refactors.
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.
Here we go #152648
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.
Thank you @maximpn !