Skip to content

Commit fc446f4

Browse files
committed
add code search api
1 parent bc0e29c commit fc446f4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

gh-cli/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ gh auth refresh -h github.com -s admin:org
316316

317317
Gets the SBOM for a repository.
318318

319+
## get-search-results.sh
320+
321+
Uses the search API for code search.
322+
319323
## get-sso-enabled-pats.sh
320324

321325
Retrieves all SSO enabled PATs users have created for an organization.

gh-cli/get-search-results.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# searches for results that have fakecompany.com AND (token or password) in the file
4+
5+
# note this api is likely to trip secondary rate limits for frequent queries
6+
7+
# the new code search via the UI is better https://github.com/search?q=fakecompany.com+AND+%28token+OR+password%29&type=code
8+
9+
results=$(gh api --paginate "/search/code?q=fakecompany.com+token+in:file&per_page=100")
10+
results+=$(gh api --paginate "/search/code?q=fakecompany.com+password+in:file&per_page=100")
11+
12+
# remove duplicates
13+
echo $results | jq '.items[].html_url' | sort | uniq

0 commit comments

Comments
 (0)