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

Add GitHub search option/feature for #733 #737

Merged
merged 1 commit into from
Sep 9, 2023

Conversation

quine
Copy link
Contributor

@quine quine commented Sep 5, 2023

Summary:
This is somewhat of a rough PoC for enabling the use of GitHub repo search, rather than relying on a list of all repos accessible to the user. In the future, there might be a more user-friendly way to do this.

This adds:

  • Two new GitHub-related env vars:

    • GITHUB_USE_SEARCH: if true, uses octonode's search.reposAsync instead of reposAsync passing in a search query
    • GITHUB_SEARCH_QUERY: specifies the search query to use when searching for repos for Threat Dragon to use
  • A conditional check in threatmodelcontroller determines whether to use reposAsync or search.reposAsync based on the above.

  • A wrapper function in threatmodelrepository to use octonode's search.reposAsync, passing in the aforementioned search query.

Description for the changelog:
Add two env var config options for using GitHub repo search (GITHUB_USE_SEARCH) and providing a query (GITHUB_SEARCH_QUERY).

Other info:
closes #733

Thanks for submitting a pull request!
Please make sure you follow our code_of_conduct.md and our contributing guidelines contributing.md

This is somewhat of a rough PoC for enabling the use of GitHub repo search, rather than relying on a list of all repos accessible to the user. In the future, there might be a more user-friendly way to do this.

Anyways, this adds two new GitHub-related env vars:
- `GITHUB_USE_SEARCH`: if `true`, uses octonode's `search.reposAsync` instead of `reposAsync` passing in a search query
- `GITHUB_SEARCH_QUERY`: specifies the search query to use when searching for repos for Threat Dragon to use

A conditional check in `threatmodelcontroller` determines whether to use `reposAsync` _or_ `search.reposAsync` based on the above.

Finally, this adds a wrapper function in `threatmodelrepository` to use octonode's `search.reposAsync`, passing in the aforementioned search query.
@jgadsden jgadsden self-requested a review September 5, 2023 14:07
@jgadsden jgadsden added enhancement New feature or request version-2.1 labels Sep 5, 2023
@jgadsden
Copy link
Collaborator

jgadsden commented Sep 5, 2023

@quine do not worry about the failing test 'PR pipeline / Build docker image', it is because this test needs greater permissions (something I keep meaning to fix)

@jgadsden
Copy link
Collaborator

jgadsden commented Sep 8, 2023

Hello @quine , I am being a bit slow to review but should do it this weekend

@quine
Copy link
Contributor Author

quine commented Sep 8, 2023

@jgadsden No worries! Just LMK what else I can help with (if anything). Cheers!

Copy link
Collaborator

@jgadsden jgadsden left a comment

Choose a reason for hiding this comment

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

Good to see this new feature, thanks @quine , I will go ahead and merge
Within a few minutes they will be available on https://www.threatdragon.com/#/ - although without either GITHUB_USE_SEARCH or GITHUB_SEARCH_QUERY environment variables we should see no change

@jgadsden
Copy link
Collaborator

jgadsden commented Sep 9, 2023

I have created an issue in the project pages repo to document these variables Document new environment variables #58

@jgadsden jgadsden merged commit 32329e9 into OWASP:main Sep 9, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request version-2.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add broader search for repos; or allow configurable/filterable patterns for repo selection list
2 participants