Skip to content

Commit f37e546

Browse files
committed
Add Optional Argument to Disable Sleeping
1 parent fffb8b5 commit f37e546

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

gato/attack/attack.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ def __init__(
3838
author_name: str = None,
3939
timeout: int = 30,
4040
github_url: str = None,
41+
no_sleep: bool = False
4142
):
4243

4344
self.api = Api(
4445
pat,
4546
socks_proxy=socks_proxy,
4647
http_proxy=http_proxy,
4748
github_url=github_url,
49+
no_sleep=no_sleep,
4850
)
4951

5052
self.socks_proxy = socks_proxy

gato/cli/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def cli(args):
4949
required=False,
5050
)
5151

52+
parser.add_argument(
53+
"--no-sleep",
54+
help="Disable sleeping when api rate limit is hit and exit instead",
55+
action="store_true"
56+
)
57+
5258
attack_parser = subparsers.add_parser(
5359
"attack", help="CI/CD Attack Capabilities", aliases=["a"],
5460
formatter_class=argparse.RawTextHelpFormatter

gato/enumerate/enumerate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def __init__(
2424
output_yaml: str = None,
2525
skip_log: bool = False,
2626
github_url: str = None,
27-
output_json: str = None
27+
output_json: str = None,
28+
no_sleep: bool = False
2829
):
2930
"""Initialize enumeration class with arguments sent by user.
3031
@@ -46,6 +47,7 @@ def __init__(
4647
socks_proxy=socks_proxy,
4748
http_proxy=http_proxy,
4849
github_url=github_url,
50+
no_sleep=no_sleep,
4951
)
5052

5153
self.socks_proxy = socks_proxy

gato/github/api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Api():
2828

2929
def __init__(self, pat: str, version: str = "2022-11-28",
3030
http_proxy: str = None, socks_proxy: str = None,
31-
github_url: str = "https://api.github.com"):
31+
github_url: str = "https://api.github.com", no_sleep: bool = False):
3232
"""Initialize the API abstraction layer to interact with the GitHub
3333
REST API.
3434
@@ -50,6 +50,8 @@ def __init__(self, pat: str, version: str = "2022-11-28",
5050
'Authorization': f'Bearer {pat}',
5151
'X-GitHub-Api-Version': version
5252
}
53+
self.no_sleep = no_sleep
54+
5355
if not github_url:
5456
self.github_url = "https://api.github.com"
5557
else:
@@ -103,6 +105,10 @@ def __check_rate_limit(self, headers):
103105
f"Sleeping for {Output.bright( sleep_time_mins + ' minutes')} "
104106
"to prevent rate limit exhaustion!")
105107

108+
if self.no_sleep:
109+
Output.warn("Skipping sleep due to no_sleep being set to True (exiting instead)")
110+
sys.exit(-1)
111+
106112
time.sleep(sleep_time + 1)
107113

108114
def __process_run_log(self, log_content: bytes, run_info: dict):

0 commit comments

Comments
 (0)