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

Implement APIEndpointAsset's fetch_api_data functionality #181

Merged
merged 6 commits into from Aug 28, 2023

Conversation

alex-nork
Copy link
Contributor

@alex-nork alex-nork commented Aug 28, 2023

The purpose of this PR is to implement functionality that allows Chirps to make an API request to an APIEndpointAsset. The query included in the request POST body will be generated during a scan, and the entire response from the request will be parsed to determine if the response includes the pre-defined success outcome. If not, another query will be generated and the process repeated.

@alex-nork alex-nork marked this pull request as ready for review August 28, 2023 16:00
Copy link
Contributor

@zimventures zimventures left a comment

Choose a reason for hiding this comment

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

Looks good, just one concern about request timeouts.

body = json.loads(json.dumps(self.body).replace('%query%', query))

# Send the request
response = requests.post(self.url, headers=headers, json=body, timeout=15)
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if this times out? If run in the context of a job, it will likely blow things up pretty badly :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it'll raise a Timeout exception. I'll wrap it in a try/except and, if caught, raise the same RequestException as below. That should make it easy to handle them in the executor.

@alex-nork alex-nork merged commit 656daba into main Aug 28, 2023
5 checks passed
@alex-nork alex-nork deleted the AlexN/api-endpoint-asset-search branch August 28, 2023 18:55
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.

None yet

2 participants