Skip to content

Commit

Permalink
Remove old version checking and add new get_version function
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveYesland committed Jan 4, 2024
1 parent 7b3125e commit 4bb6a7b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pacu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import botocore.session
import botocore.exceptions
import urllib.parse
import toml

from pacu import settings

Expand Down Expand Up @@ -464,6 +465,20 @@ def fetch_data(self, data: List[str], module: str, args: str, force=False) -> bo
self.exec_module(['exec', module])
return True

def get_pacu_version(self):
try:
# Get the directory where this file is located
current_dir = os.path.dirname(__file__)
# Go up one level to the root of package
package_root = os.path.abspath(os.path.join(current_dir, os.pardir))
# Construct the path to pyproject.toml
toml_path = os.path.join(package_root, 'pyproject.toml')
with open(toml_path, 'r') as file:
pyproject = toml.load(file)
return pyproject['tool']['poetry']['version']
except Exception:
return "unknown"

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 @@ -1798,7 +1813,7 @@ def run_gui(self) -> None:
try:
if not idle_ready:
try:
print("""
print(f"""
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣿⣿⣿⣶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⡿⠛⠉⠁⠀⠀⠈⠙⠻⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand All @@ -1823,6 +1838,7 @@ def run_gui(self) -> None:
⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡏⠉⠉⠉⠉⠀⠀⠀⢸⣿⣿⡏⠉⠉⢹⣿⣿⡇⠀⢸⣿⣿⣇⣀⣀⣸⣿⣿⣿⠀⢸⣿⣿⣿⣀⣀⣀⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡇⠀⠀⢸⣿⣿⡇⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⡟
⠀⠀⠀⠀⠀⠀⠀⠀⠘⠛⠛⠃⠀⠀⠀⠀⠀⠀⠀⠘⠛⠛⠃⠀⠀⠘⠛⠛⠃⠀⠀⠉⠛⠛⠛⠛⠛⠛⠋⠀⠀⠀⠀⠙⠛⠛⠛⠛⠛⠉⠀
Version: {self.get_pacu_version()}
""")
except UnicodeEncodeError:
pass
Expand Down Expand Up @@ -1917,6 +1933,7 @@ def run(self) -> None:
parser.add_argument('--exec', action='store_true', help='exec module')
parser.add_argument('--set-regions', nargs='+', default=None, help='<region1 region2 ...> or <all> for all', metavar='')
parser.add_argument('--whoami', action='store_true', help='Display information on current IAM user')
parser.add_argument('--version', action='version', version=f'Pacu {self.get_pacu_version()}', help='Display Pacu version')
args = parser.parse_args()

if any([args.session, args.data, args.module_args, args.exec, args.set_regions, args.whoami, args.new_session, args.set_keys, args.activate_session]):
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "1.4.2"
description = "The AWS exploitation framework, designed for testing the security of Amazon Web Services environments."
authors = ["Rhino Assessment Team <pacu@rhinosecuritylabs.com>"]
license = "BSD-3"
include = ["pyproject.toml"]

[tool.poetry.scripts]
pacu = "pacu.__main__:main"
Expand All @@ -25,6 +26,7 @@ pycognito = "^2023.5.0"
qrcode = "^7.4.2"
jq = "^1.4.1"
pyyaml = "^6.0.1"
toml = "^0.10.2"

[tool.poetry.dev-dependencies]
flake8 = "^3.9.1"
Expand Down

0 comments on commit 4bb6a7b

Please sign in to comment.