-
Notifications
You must be signed in to change notification settings - Fork 566
add new field related_integrations
to the post build
#2060
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
add new field related_integrations
to the post build
#2060
Conversation
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.
LGTM.
…ocess' of github.com:elastic/detection-rules into 2057-add-related_integrationsto-post-transform-build-process
Attempting to identify what potential routes are available for us here, this is what I discussed with Mika. @brokensound77 thoughts? For package/integrationAs discussed we focus on VersioningThe only clear linkage I am aware of is comparing stack versions from the manifest of each package to that our our own packages.yml and finding the least common compatible version through iteration. Instead of making network calls for this we can build a local JSON reference file that is built via separate command. A simple process would be...
|
We should definitely create a new py file called Parsing should come from the query AST Version compatibility should be:
|
Before continuing too far, I would merge #2059 to verify a true diff and avoid divergent errors from code duplication |
…of dictionaries, started work on integrations py
Adding some current progress for this before I turn my attention to a separate and potentially more urgent issue. At this time,
Next steps are to build out the A separate method is being built, |
Co-authored-by: Justin Ibarra <[email protected]>
Co-authored-by: Justin Ibarra <[email protected]>
Co-authored-by: Justin Ibarra <[email protected]>
Co-authored-by: Justin Ibarra <[email protected]>
Co-authored-by: Justin Ibarra <[email protected]>
Co-authored-by: Justin Ibarra <[email protected]>
detection_rules/integrations.py
Outdated
for kibana_compat_vers in re.sub(r"\>|\<|\=|\^", "", manifest["conditions"]["kibana.version"]).split(" || "): | ||
if compare_versions(kibana_compat_vers, current_stack_version): | ||
return version | ||
raise Exception(f"no compatible version for integration {package}:{integration}") |
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.
going forward, we may just want to return None
and not set the integration rather than raising an exception, but we can punt this for now
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.
adjusted in recent commit. Method expects Union[str, None]
. If no compatible version, it will print instead of raise the error and then return None
. Had to adjust rule.add_related_integrations
code so when policy templates are checked, it only does it if version exists or it would error.
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.
Left a few comments on some previous suggestions that got missed, otherwise LGTM. Thanks for the patience with reviews!!
…nstead of raise error only
Co-authored-by: Mika Ayenson <[email protected]>
* add new field `related_integrations` to the post build * add exception for endpoint `integration` * Skip rules without related integrations * lint * refactor related_integrations to TOMLRuleContents class * update to reflect required_fields updates * add todo * add new line for linting * related_integrations updates, get_packaged_integrations returns list of dictionaries, started work on integrations py * build_integrations_manifest command completed * initial test completed for post-building related_integrations * removed get_integration_manifest method from rule, removed global integrations path * moved integration related methods to integrations.py and fixed flake issues * adjustments for PipedQuery from eql sequence rules and packages with no integration * adjusted github client import for integrations.py * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * added integration manifest schema, made adjustments * Update detection_rules/integrations.py * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * removed get_integrations_package to consolidate code * removed type list return * adjusted import flake errors * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted indentation error * adjusted rule.get_packaged_integrations to account for kql.ast.OrExpr if event.dataset is not set * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted find_least_compatible_version in integrations.py * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * fixed flake issues * adjusted get_packaged_integrations * iterate the ast for literal event.dataset values * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * made small adjustments to address errors during build manifests command * addressing integrations.find_least_compatible method to return None instead of raise error only * Update detection_rules/integrations.py Co-authored-by: Mika Ayenson <[email protected]> Co-authored-by: Justin Ibarra <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> (cherry picked from commit 7d973a3)
* add new field `related_integrations` to the post build * add exception for endpoint `integration` * Skip rules without related integrations * lint * refactor related_integrations to TOMLRuleContents class * update to reflect required_fields updates * add todo * add new line for linting * related_integrations updates, get_packaged_integrations returns list of dictionaries, started work on integrations py * build_integrations_manifest command completed * initial test completed for post-building related_integrations * removed get_integration_manifest method from rule, removed global integrations path * moved integration related methods to integrations.py and fixed flake issues * adjustments for PipedQuery from eql sequence rules and packages with no integration * adjusted github client import for integrations.py * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * added integration manifest schema, made adjustments * Update detection_rules/integrations.py * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * removed get_integrations_package to consolidate code * removed type list return * adjusted import flake errors * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted indentation error * adjusted rule.get_packaged_integrations to account for kql.ast.OrExpr if event.dataset is not set * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted find_least_compatible_version in integrations.py * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * fixed flake issues * adjusted get_packaged_integrations * iterate the ast for literal event.dataset values * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * made small adjustments to address errors during build manifests command * addressing integrations.find_least_compatible method to return None instead of raise error only * Update detection_rules/integrations.py Co-authored-by: Mika Ayenson <[email protected]> Co-authored-by: Justin Ibarra <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> (cherry picked from commit 7d973a3)
* add new field `related_integrations` to the post build * add exception for endpoint `integration` * Skip rules without related integrations * lint * refactor related_integrations to TOMLRuleContents class * update to reflect required_fields updates * add todo * add new line for linting * related_integrations updates, get_packaged_integrations returns list of dictionaries, started work on integrations py * build_integrations_manifest command completed * initial test completed for post-building related_integrations * removed get_integration_manifest method from rule, removed global integrations path * moved integration related methods to integrations.py and fixed flake issues * adjustments for PipedQuery from eql sequence rules and packages with no integration * adjusted github client import for integrations.py * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * added integration manifest schema, made adjustments * Update detection_rules/integrations.py * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * removed get_integrations_package to consolidate code * removed type list return * adjusted import flake errors * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted indentation error * adjusted rule.get_packaged_integrations to account for kql.ast.OrExpr if event.dataset is not set * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted find_least_compatible_version in integrations.py * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * fixed flake issues * adjusted get_packaged_integrations * iterate the ast for literal event.dataset values * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * made small adjustments to address errors during build manifests command * addressing integrations.find_least_compatible method to return None instead of raise error only * Update detection_rules/integrations.py Co-authored-by: Mika Ayenson <[email protected]> Co-authored-by: Justin Ibarra <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> (cherry picked from commit 7d973a3)
* add new field `related_integrations` to the post build * add exception for endpoint `integration` * Skip rules without related integrations * lint * refactor related_integrations to TOMLRuleContents class * update to reflect required_fields updates * add todo * add new line for linting * related_integrations updates, get_packaged_integrations returns list of dictionaries, started work on integrations py * build_integrations_manifest command completed * initial test completed for post-building related_integrations * removed get_integration_manifest method from rule, removed global integrations path * moved integration related methods to integrations.py and fixed flake issues * adjustments for PipedQuery from eql sequence rules and packages with no integration * adjusted github client import for integrations.py * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * added integration manifest schema, made adjustments * Update detection_rules/integrations.py * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * removed get_integrations_package to consolidate code * removed type list return * adjusted import flake errors * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted indentation error * adjusted rule.get_packaged_integrations to account for kql.ast.OrExpr if event.dataset is not set * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted find_least_compatible_version in integrations.py * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * fixed flake issues * adjusted get_packaged_integrations * iterate the ast for literal event.dataset values * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * made small adjustments to address errors during build manifests command * addressing integrations.find_least_compatible method to return None instead of raise error only * Update detection_rules/integrations.py Co-authored-by: Mika Ayenson <[email protected]> Co-authored-by: Justin Ibarra <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> (cherry picked from commit 7d973a3)
* add new field `related_integrations` to the post build * add exception for endpoint `integration` * Skip rules without related integrations * lint * refactor related_integrations to TOMLRuleContents class * update to reflect required_fields updates * add todo * add new line for linting * related_integrations updates, get_packaged_integrations returns list of dictionaries, started work on integrations py * build_integrations_manifest command completed * initial test completed for post-building related_integrations * removed get_integration_manifest method from rule, removed global integrations path * moved integration related methods to integrations.py and fixed flake issues * adjustments for PipedQuery from eql sequence rules and packages with no integration * adjusted github client import for integrations.py * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * added integration manifest schema, made adjustments * Update detection_rules/integrations.py * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/rule.py Co-authored-by: Justin Ibarra <[email protected]> * removed get_integrations_package to consolidate code * removed type list return * adjusted import flake errors * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted indentation error * adjusted rule.get_packaged_integrations to account for kql.ast.OrExpr if event.dataset is not set * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/devtools.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * adjusted find_least_compatible_version in integrations.py * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * fixed flake issues * adjusted get_packaged_integrations * iterate the ast for literal event.dataset values * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * Update detection_rules/integrations.py Co-authored-by: Justin Ibarra <[email protected]> * made small adjustments to address errors during build manifests command * addressing integrations.find_least_compatible method to return None instead of raise error only * Update detection_rules/integrations.py Co-authored-by: Mika Ayenson <[email protected]> Co-authored-by: Justin Ibarra <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> (cherry picked from commit 7d973a3)
Issues
Resolves #2057
Summary
related_integrations
to the rule post build.