added new arg --get_open_pull_requests
This commit is contained in:
parent
fc664d5ad3
commit
faa5591c21
1 changed files with 18 additions and 13 deletions
|
@ -43,24 +43,23 @@ class GithubSearcher():
|
||||||
|
|
||||||
def get_repo_open_issues(self, repo):
|
def get_repo_open_issues(self, repo):
|
||||||
try:
|
try:
|
||||||
issues = repo.get_issues(state='open')
|
return repo.get_issues(state='open')
|
||||||
for issue in issues:
|
|
||||||
print(issue)
|
|
||||||
return issues
|
|
||||||
|
|
||||||
except GithubException as e:
|
except GithubException as e:
|
||||||
logging.error(f"Error getting open issues: {e}")
|
logging.error(f"Error getting open issues: {e}")
|
||||||
return None
|
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):
|
def get_repo_contents(self, repo):
|
||||||
try:
|
try:
|
||||||
contents = repo.get_contents("")
|
contents = repo.get_contents("")
|
||||||
while contents:
|
for content_file in contents:
|
||||||
file_content = contents.pop(0)
|
print(content_file)
|
||||||
if file_content.type == "dir":
|
|
||||||
contents.extend(repo.get_contents(file_content.path))
|
|
||||||
else:
|
|
||||||
print(file_content)
|
|
||||||
return contents
|
return contents
|
||||||
except GithubException as e:
|
except GithubException as e:
|
||||||
logging.error(f"Error getting repository contents: {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 = 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("--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("--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_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 a repository.")
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
searcher = GithubSearcher(args.query)
|
searcher = GithubSearcher(args.query)
|
||||||
|
@ -103,6 +104,10 @@ def main():
|
||||||
searcher.get_repo_open_issues(item)
|
searcher.get_repo_open_issues(item)
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
|
if args.get_open_pull_requests:
|
||||||
|
searcher.get_repo_open_pull_requests(item)
|
||||||
|
print("\n")
|
||||||
|
|
||||||
if args.get_file_contents:
|
if args.get_file_contents:
|
||||||
searcher.get_repo_contents(item)
|
searcher.get_repo_contents(item)
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
Loading…
Add table
Reference in a new issue