From faa5591c21fd229619fbfb90ade84cbdff426809 Mon Sep 17 00:00:00 2001 From: kenna-bmcdevitt Date: Tue, 27 Aug 2024 10:35:22 -0500 Subject: [PATCH] added new arg --get_open_pull_requests --- github_searcher.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/github_searcher.py b/github_searcher.py index f267379..4e2d593 100644 --- a/github_searcher.py +++ b/github_searcher.py @@ -43,24 +43,23 @@ class GithubSearcher(): def get_repo_open_issues(self, repo): try: - issues = repo.get_issues(state='open') - for issue in issues: - print(issue) - return issues - + return repo.get_issues(state='open') except GithubException as e: logging.error(f"Error getting open issues: {e}") return None + def get_repo_open_pull_requests(self, repo): + try: + return repo.get_pulls(state='open') + except GithubException as e: + logging.error(f"Error getting open pull requests: {e}") + return None + def get_repo_contents(self, repo): try: contents = repo.get_contents("") - while contents: - file_content = contents.pop(0) - if file_content.type == "dir": - contents.extend(repo.get_contents(file_content.path)) - else: - print(file_content) + for content_file in contents: + print(content_file) return contents except GithubException as e: logging.error(f"Error getting repository contents: {e}") @@ -73,8 +72,10 @@ def main(): parser = argparse.ArgumentParser(description="Search GitHub repositories and users for PoC exploits and CVEs.") parser.add_argument("--query", type=str, required=True, help="The search query.") parser.add_argument("--search_type", type=str, required=True, choices=["repo", "users", "name"], help="The type of search to perform: 'repo', 'users', or 'name'.") - parser.add_argument("--get_file_contents", action="store_true", help="Get the contents of a repository.") - parser.add_argument("--get_open_issues", action="store_true", help="Get the open issues of a repository.") + parser.add_argument("--get_file_contents", action="store_true", help="Get the contents of repo results.") + parser.add_argument("--get_open_issues", action="store_true", help="Get the open issues of repo results.") + parser.add_argument("--get_open_pull_requests", action="store_true", help="Get the open pull requests of repo results.") + args = parser.parse_args() searcher = GithubSearcher(args.query) @@ -103,6 +104,10 @@ def main(): searcher.get_repo_open_issues(item) print("\n") + if args.get_open_pull_requests: + searcher.get_repo_open_pull_requests(item) + print("\n") + if args.get_file_contents: searcher.get_repo_contents(item) print("\n")