Skip to content

Commit

Permalink
Remove old update checks, Pacu uses pip
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveYesland committed Jan 4, 2024
1 parent 7acc82a commit 4db1759
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 157 deletions.
1 change: 0 additions & 1 deletion pacu/last_update.txt

This file was deleted.

51 changes: 0 additions & 51 deletions pacu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,54 +465,6 @@ def fetch_data(self, data: List[str], module: str, args: str, force=False) -> bo
self.exec_module(['exec', module])
return True

def check_for_updates(self):
TIME_FORMAT = '%Y-%m-%d'
UPDATE_CYCLE = 7 # Days
UPDATE_INFO_PATH = lib.home_dir()/'update_info.json'
LAST_UPDATE_PATH = lib.pacu_dir()/'last_update.txt'
UPDATE_MSG = '''Pacu has a new version available! Clone it from GitHub to receive the updates.
git clone https://github.com/RhinoSecurityLabs/pacu.git'''

with open(LAST_UPDATE_PATH, 'r') as f:
local_last_update = f.read().rstrip()

datetime_now = datetime.now()
datetime_local = datetime.strptime(local_last_update, TIME_FORMAT)

datetime_last_check = datetime.min
latest_cached = datetime.min

# update_info.json structure:
# { 'last_check':'YYYY-MM-DD', 'latest_cached':'YYYY-MM-DD'}
# Create a update_info.json if not exist
update_info = {}
if os.path.isfile(UPDATE_INFO_PATH):
with open(UPDATE_INFO_PATH, 'r') as f:
update_info = json.load(f)
datetime_last_check = datetime.strptime(update_info['last_check'], TIME_FORMAT)
latest_cached = datetime.strptime(update_info['latest_cached'], TIME_FORMAT)

# Check upstream
if (datetime_now - datetime_last_check).days >= UPDATE_CYCLE:
latest_update = requests.get(
'https://raw.githubusercontent.com/RhinoSecurityLabs/pacu/master/pacu/last_update.txt').text.rstrip()
latest = datetime.strptime(latest_update, TIME_FORMAT)

update_info['latest_cached'] = latest.strftime(TIME_FORMAT)
update_info['last_check'] = datetime_now.strftime(TIME_FORMAT)
with open(UPDATE_INFO_PATH, 'w') as f:
json.dump(update_info, f)

if datetime_local < latest:
print(UPDATE_MSG)
return True
# Local check
elif datetime_local < latest_cached:
print(datetime_local, latest_cached)
print(UPDATE_MSG)
return True
return False

def key_info(self, alias='') -> Union[Dict[str, Any], bool]:
""" Return the set of information stored in the session's active key
or the session's key with a specified alias, as a dictionary. """
Expand Down Expand Up @@ -1889,8 +1841,6 @@ def run_gui(self) -> None:
self.initialize_tab_completion()
display_pacu_help()

self.check_for_updates()

idle_ready = True

self.check_user_agent()
Expand Down Expand Up @@ -1976,7 +1926,6 @@ def run(self) -> None:
exit()
self.run_cli(args)
elif any([args.list_modules, args.pacu_help, args.module_info]):
self.check_for_updates()
self.run_cli(args)
else:
self.run_gui()
Expand Down
105 changes: 0 additions & 105 deletions tests/test_pacu_update.py

This file was deleted.

0 comments on commit 4db1759

Please sign in to comment.