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 Optional Argument to Disable Sleeping #76

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gato/attack/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ def __init__(
author_name: str = None,
timeout: int = 30,
github_url: str = None,
no_sleep: bool = False
):

self.api = Api(
pat,
socks_proxy=socks_proxy,
http_proxy=http_proxy,
github_url=github_url,
no_sleep=no_sleep,
)

self.socks_proxy = socks_proxy
Expand Down
6 changes: 6 additions & 0 deletions gato/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def cli(args):
required=False,
)

parser.add_argument(
"--no-sleep",
help="Disable sleeping when api rate limit is hit and exit instead",
action="store_true"
)

attack_parser = subparsers.add_parser(
"attack", help="CI/CD Attack Capabilities", aliases=["a"],
formatter_class=argparse.RawTextHelpFormatter
Expand Down
4 changes: 3 additions & 1 deletion gato/enumerate/enumerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def __init__(
output_yaml: str = None,
skip_log: bool = False,
github_url: str = None,
output_json: str = None
output_json: str = None,
no_sleep: bool = False
):
"""Initialize enumeration class with arguments sent by user.

Expand All @@ -46,6 +47,7 @@ def __init__(
socks_proxy=socks_proxy,
http_proxy=http_proxy,
github_url=github_url,
no_sleep=no_sleep,
)

self.socks_proxy = socks_proxy
Expand Down
8 changes: 7 additions & 1 deletion gato/github/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Api():

def __init__(self, pat: str, version: str = "2022-11-28",
http_proxy: str = None, socks_proxy: str = None,
github_url: str = "https://api.github.com"):
github_url: str = "https://api.github.com", no_sleep: bool = False):
"""Initialize the API abstraction layer to interact with the GitHub
REST API.

Expand All @@ -50,6 +50,8 @@ def __init__(self, pat: str, version: str = "2022-11-28",
'Authorization': f'Bearer {pat}',
'X-GitHub-Api-Version': version
}
self.no_sleep = no_sleep

if not github_url:
self.github_url = "https://api.github.com"
else:
Expand Down Expand Up @@ -103,6 +105,10 @@ def __check_rate_limit(self, headers):
f"Sleeping for {Output.bright( sleep_time_mins + ' minutes')} "
"to prevent rate limit exhaustion!")

if self.no_sleep:
Output.warn("Skipping sleep due to no_sleep being set to True (exiting instead)")
sys.exit(-1)

time.sleep(sleep_time + 1)

def __process_run_log(self, log_content: bytes, run_info: dict):
Expand Down
Loading