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

APIEndpointAsset model #165

Merged
merged 10 commits into from Aug 21, 2023
Merged

APIEndpointAsset model #165

merged 10 commits into from Aug 21, 2023

Conversation

alex-nork
Copy link
Contributor

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

The purpose of this PR is to add a new asset type: APIEndpointAsset. This provides the user with a means for connecting Chirps to an API endpoint, allowing Chirps to interact with their chatbot or some other LLM application. In order to connect to said API endpoint, the user can specify the API endpoint's URL, authentication method, API key, request headers, and request body. If the asset is selected for a scan, Chirps will use the above information to send requests to the endpoint as part of the scan.

I've opted to handle the adding/removing of key-value pairs via JS in order to keep this project moving. Once this PR is approved, I'll create a ticket that can be used to track refactoring this to use HTMX.

Asset creation:
Screenshot 2023-08-21 at 11 40 36 AM

Asset editing:
Screenshot 2023-08-21 at 11 41 08 AM

@alex-nork alex-nork marked this pull request as ready for review August 21, 2023 15:48
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.

Thanks for updating those assets to SVG's - nice touch! A couple of items for you to consider but great PR overall. 🥳


def search(self, query: str, max_results: int) -> list[SearchResult]:
"""Search the API Endpoint asset with the specified query."""
raise NotImplementedError('The search method is not implemented for this asset.')
Copy link
Contributor

Choose a reason for hiding this comment

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

So then how do we scan this asset? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to break this out into a separate PR to keep them both a reasonable size.

authentication_method = models.CharField(
max_length=10, choices=[('Basic', 'Basic'), ('Bearer', 'Bearer')], default='Bearer'
)
api_key = EncryptedCharField(max_length=256, editable=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this asset will support multiple auth types in the future, it's probably worth making this an opaque "secret" and adding an enum of the supported types (bearer is the only one to start). I'm guessing oauth is probably going to be needed sooner rather than later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

spoke with @zimventures about this and I'm going to leave it as is. We don't expect that changing it later, with clearer direction, will take more effort than changing it now.

@alex-nork alex-nork merged commit 878ec37 into main Aug 21, 2023
5 checks passed
@alex-nork alex-nork deleted the AlexN/api-endpoint-asset branch August 21, 2023 17:25
@alex-nork alex-nork mentioned this pull request Aug 22, 2023
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