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

[ASM] - Expandr 4735 #27624

Conversation

kball-pa
Copy link
Contributor

Contributing to Cortex XSOAR Content

Make sure to register your contribution by filling the contribution registration form

The Pull Request will be reviewed only after the contribution registration form is filled.

Status

  • In Progress
  • Ready
  • In Hold - (Reason for hold)

Related Issues

https://jira-hq.paloaltonetworks.local/browse/EXPANDR-4735

Description

Currently, we score and return all owners in ${alert.asmserviceowner} in sorted order. Some of these may be service accounts or other low-confidence users/owners that we don't want to notify.

This PR implements a ranking algorithm for Service Ownership that tries to find a smaller (targeting roughly ~5), high-confidence set of owners that we would be comfortable notifying via email. After the Service Ownership playbook runs, ${alert.asmserviceowner} will contain this smaller, high-confidence set, while ${alert.asmserviceownerunrankedraw} will contain the full set of (deduplicated) owners pulled during enrichment.

See unit tests for detailed specification for how the ranking algorithm works.

Test plan: pytest + manual testing in tenant (see JIRA ticket)

Minimum version of Cortex XSOAR

  • 6.0.0
  • 6.1.0
  • 6.2.0
  • 6.5.0

Does it break backward compatibility?

  • Yes
    • Further details:
  • [ x] No

Must have

  • [ x] Tests
  • [ x] Documentation

Currently, we score and return all owners in ${alert.asmserviceowner} in sorted owners; instead, we want ${alert.asmserviceowner} to contain a smaller, high-confidence set of owners that we would be comfortable notifying via email.

Test plan: pytest + manual testing in tenant
Copy link
Contributor

@johnnywilkes johnnywilkes left a comment

Choose a reason for hiding this comment

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

@kball-pa , Approved. Nice work!

@michal-dagan , please merge when possible

Comment on lines +148 to +152
scores: Iterable[float],
target_k: int = 5,
k_tol: int = 2,
a_tol: float = 1.0,
min_score_proportion: float = 0.75

Choose a reason for hiding this comment

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

can you defensively verify that these values are within expected bounds? (for instance, that k_tol isn't -3.)

def test_get_k():
"""
These cases are designed to specify the intuition we are trying to implement with the algorithm.
They are specific to a target value of 5; if the target_k changes, these tests should update to reflect that.

Choose a reason for hiding this comment

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

The docstring should be generic, so mentioning 5 is not appropriate here unless you're actually setting that parameter in _get_k -- instead you might mention that this test verifies the default case. (The place to note "5" is in the docstring for _get_k -- there it is worth flagging that all the default values are tuned for k=5.)

@michal-dagan
Copy link
Contributor

Hi @kball-pa,
Thank you for your contribution!
Good work :)

  1. please run demisto-sdk pre-commit -g --unit-test --validate --no-secrets --show-diff-on-failure --verbose in order to pass the checks.
  2. Please add a unit-test as the build fails on test-coverage:
    Message: "[red]Unit-tests for 'Packs/CortexAttackSurfaceManagement/Scripts/RankServiceOwners/RankServiceOwners.py' must reach a coverage of at least 95.05% (currently: 93.0%).[/red]"

Please feel free to reach out to me with any questions - I'm available here or on slack :)
Thanks again

@michal-dagan michal-dagan added the pending-contributor The PR is pending the response of its creator label Jun 27, 2023
@CLAassistant
Copy link

CLAassistant commented Jul 5, 2023

CLA assistant check
All committers have signed the CLA.

@michal-dagan michal-dagan removed the request for review from thefrieddan1 July 5, 2023 15:41
@kball-pa
Copy link
Contributor Author

kball-pa commented Jul 5, 2023

@michal-dagan I increased the test coverage and verified that all checks were passing on a previous commit 5d6c938, but now the Run Validations step is failing with an error that seems to be local to the build.

@michal-dagan michal-dagan added the ready-for-instance-test In contribution PRs, this label will cause a trigger of a build with a modified pack from the PR. label Jul 6, 2023
Copy link
Contributor

@michal-dagan michal-dagan left a comment

Choose a reason for hiding this comment

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

Great!

@michal-dagan michal-dagan merged commit 205d786 into demisto:contrib/kball-pa_find-top-k-owners Jul 6, 2023
michal-dagan added a commit that referenced this pull request Jul 6, 2023
* Update ranking algorithm for Service Ownership

Currently, we score and return all owners in ${alert.asmserviceowner} in sorted owners; instead, we want ${alert.asmserviceowner} to contain a smaller, high-confidence set of owners that we would be comfortable notifying via email.

Test plan: pytest + manual testing in tenant

* Add release notes

* Verify hyperparameters and update docs

* Add unit test for value-checking in _get_k

* Update release notes

* Manually apply diff in output of pre-commit check: use built-ins for type hints, set generators

---------

Co-authored-by: kball-pa <131012047+kball-pa@users.noreply.github.com>
Co-authored-by: michal-dagan <109464765+michal-dagan@users.noreply.github.com>
xsoar-bot pushed a commit to xsoar-contrib/content that referenced this pull request Jul 26, 2023
* Update ranking algorithm for Service Ownership

Currently, we score and return all owners in ${alert.asmserviceowner} in sorted owners; instead, we want ${alert.asmserviceowner} to contain a smaller, high-confidence set of owners that we would be comfortable notifying via email.

Test plan: pytest + manual testing in tenant

* Add release notes

* Verify hyperparameters and update docs

* Add unit test for value-checking in _get_k

* Update release notes

* Manually apply diff in output of pre-commit check: use built-ins for type hints, set generators

---------

Co-authored-by: kball-pa <131012047+kball-pa@users.noreply.github.com>
Co-authored-by: michal-dagan <109464765+michal-dagan@users.noreply.github.com>
xsoar-bot pushed a commit to xsoar-contrib/content that referenced this pull request Aug 2, 2023
* Update ranking algorithm for Service Ownership

Currently, we score and return all owners in ${alert.asmserviceowner} in sorted owners; instead, we want ${alert.asmserviceowner} to contain a smaller, high-confidence set of owners that we would be comfortable notifying via email.

Test plan: pytest + manual testing in tenant

* Add release notes

* Verify hyperparameters and update docs

* Add unit test for value-checking in _get_k

* Update release notes

* Manually apply diff in output of pre-commit check: use built-ins for type hints, set generators

---------

Co-authored-by: kball-pa <131012047+kball-pa@users.noreply.github.com>
Co-authored-by: michal-dagan <109464765+michal-dagan@users.noreply.github.com>
xsoar-bot pushed a commit to xsoar-contrib/content that referenced this pull request Aug 2, 2023
* Update ranking algorithm for Service Ownership

Currently, we score and return all owners in ${alert.asmserviceowner} in sorted owners; instead, we want ${alert.asmserviceowner} to contain a smaller, high-confidence set of owners that we would be comfortable notifying via email.

Test plan: pytest + manual testing in tenant

* Add release notes

* Verify hyperparameters and update docs

* Add unit test for value-checking in _get_k

* Update release notes

* Manually apply diff in output of pre-commit check: use built-ins for type hints, set generators

---------

Co-authored-by: kball-pa <131012047+kball-pa@users.noreply.github.com>
Co-authored-by: michal-dagan <109464765+michal-dagan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution Form Filled Whether contribution form filled or not. Contribution Thank you! Contributions are always welcome! docs-approved pending-contributor The PR is pending the response of its creator ready-for-instance-test In contribution PRs, this label will cause a trigger of a build with a modified pack from the PR. Xsoar Support Level Indicates that the contribution is for XSOAR supported pack
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants