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

[SOAR-17745] Duo admin Improve handling of 429s in task code #3048

Conversation

lcwiklinski-r7
Copy link
Collaborator

https://rapid7.atlassian.net/browse/SOAR-17745

Unit Tests

Review our documentation on generating and writing plugin unit tests

  • [ ✅ ] Unit tests written for any new or updated code

@lcwiklinski-r7 lcwiklinski-r7 requested a review from a team as a code owner January 14, 2025 12:47
@lcwiklinski-r7 lcwiklinski-r7 changed the title Duo admin Improve handling of 429s in task code [SOAR-17745] Duo admin Improve handling of 429s in task code Jan 14, 2025
@@ -64,7 +64,9 @@ class MonitorLogsOutput(insightconnect_plugin_runtime.Output):
"type": "array",
"title": "Logs",
"description": "List of administrator, authentication and trust monitor event logs within the specified time range",
"items": {},
"items": {
"$ref": {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be reverted :( Sdk refresh does this automatically

plugins/duo_admin/help.md Outdated Show resolved Hide resolved
@rmurray-r7 rmurray-r7 self-requested a review January 14, 2025 13:45
@@ -103,7 +108,46 @@ def get_parameters_for_query(
self.logger.info(f"Retrieve data from {mintime} to {maxtime}. Get next page is set to {get_next_page}")
return mintime, maxtime, get_next_page

def check_rate_limit(self, state: Dict):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def check_rate_limit(self, state: Dict):
def check_rate_limit(self, state: Dict[str, Any]) -> Union[PluginException, None]:

@@ -285,7 +330,7 @@ def add_log_type_field(logs: list, value: str) -> list:

@staticmethod
def sha1(log: dict) -> str:
hash_ = sha1() # nosec B303
hash_ = sha1(usedforsecurity=False) # nosec B303
Copy link
Collaborator

Choose a reason for hiding this comment

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

we've got a hashing method we can call from the SDK we can use now, if you want to swap out to use that

@@ -37,6 +37,12 @@ def setUpClass(cls) -> None:
"lookback": "2023-04-30T08:34:46.000Z",
},
],
[
"with_rate_limit",
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you mind adding a test that has the whole flow of:

  • happy state -> API returns 429 -> task returns 200 with rate limit in state -> second task call returns 429 as task status code

and maybe one showing the rate limit time has passed and we resume task? just i know these can be a bit tricky to test locally!

@@ -1,5 +1,5 @@
{
"spec": "4d67f7597ca0c9b43ff85bc3d161836e",
"spec": "bd19980a894fe29ad2516339a3668832",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is there Whois files in here?

@@ -32,7 +32,8 @@ hub_tags:
key_features: ["Perform a WHOIS lookup for a provided IP address or domain to gain information on who is responsible for a domain or IP"]
references: ["[WHOIS](https://en.wikipedia.org/wiki/WHOIS)"]
links: ["[WHOIS](https://en.wikipedia.org/wiki/WHOIS)"]
troubleshooting: "Multiple records can be returned by the server, this plugin currently only returns the first unique records found."
troubleshooting:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah these Whois files shouldn't be in the PR.

@rmurray-r7 rmurray-r7 self-requested a review January 16, 2025 11:33
@lcwiklinski-r7 lcwiklinski-r7 force-pushed the SOAR-17745_duo_admin_Improve-handling-of-429s-in-task-code branch from 2bb8a2c to 54c0ec4 Compare January 16, 2025 11:36
@rmurray-r7 rmurray-r7 force-pushed the SOAR-17745_duo_admin_Improve-handling-of-429s-in-task-code branch 2 times, most recently from 360f870 to 86f9f03 Compare January 21, 2025 12:21
@lcwiklinski-r7 lcwiklinski-r7 force-pushed the SOAR-17745_duo_admin_Improve-handling-of-429s-in-task-code branch from 083267f to 7791e66 Compare January 23, 2025 14:30
@lcwiklinski-r7 lcwiklinski-r7 merged commit 50a2790 into develop Jan 23, 2025
11 checks passed
@lcwiklinski-r7 lcwiklinski-r7 deleted the SOAR-17745_duo_admin_Improve-handling-of-429s-in-task-code branch January 23, 2025 14:45
igorski-r7 pushed a commit that referenced this pull request Jan 27, 2025
* Updating plugin.spec (#3047)

* Duo admin Improve handling of 429s in task code

* Linting the code

* Version bump

* Adjusting styling

* Resolving static code analysis

* Resolving plugin's validation

* CR fixes

* Additional test case

* Bumping the SDK and linting the code

---------

Co-authored-by: rmurray-r7 <ryanj_murray@rapid7.com>
lcwiklinski-r7 added a commit that referenced this pull request Jan 29, 2025
* Updating plugin.spec (#3047)

* Duo admin Improve handling of 429s in task code

* Linting the code

* Version bump

* Adjusting styling

* Resolving static code analysis

* Resolving plugin's validation

* CR fixes

* Additional test case

* Bumping the SDK and linting the code

---------

Co-authored-by: rmurray-r7 <ryanj_murray@rapid7.com>
lcwiklinski-r7 added a commit that referenced this pull request Jan 29, 2025
…3067)

* Updating plugin.spec (#3047)

* Duo admin Improve handling of 429s in task code

* Linting the code

* Version bump

* Adjusting styling

* Resolving static code analysis

* Resolving plugin's validation

* CR fixes

* Additional test case

* Bumping the SDK and linting the code

---------

Co-authored-by: rmurray-r7 <ryanj_murray@rapid7.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants