flyshell 1.1.1__tar.gz → 1.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {flyshell-1.1.1/src/flyshell.egg-info → flyshell-1.1.3}/PKG-INFO +1 -1
  2. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/builtin/system.py +20 -15
  3. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/constants.py +2 -2
  4. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/core/directory.py +1 -0
  5. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/core/loader.py +9 -10
  6. {flyshell-1.1.1 → flyshell-1.1.3/src/flyshell.egg-info}/PKG-INFO +1 -1
  7. {flyshell-1.1.1 → flyshell-1.1.3}/tests/test_loader.py +12 -0
  8. {flyshell-1.1.1 → flyshell-1.1.3}/tests/test_security.py +8 -0
  9. {flyshell-1.1.1 → flyshell-1.1.3}/LICENSE +0 -0
  10. {flyshell-1.1.1 → flyshell-1.1.3}/README.md +0 -0
  11. {flyshell-1.1.1 → flyshell-1.1.3}/pyproject.toml +0 -0
  12. {flyshell-1.1.1 → flyshell-1.1.3}/setup.cfg +0 -0
  13. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/__init__.py +0 -0
  14. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/abstract/__init__.py +0 -0
  15. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/abstract/base_cmd.py +0 -0
  16. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/abstract/base_plugin.py +0 -0
  17. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/abstract/parent_cmd.py +0 -0
  18. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/builtin/__init__.py +0 -0
  19. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/builtin/diskops.py +0 -0
  20. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/builtin/fs.py +0 -0
  21. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/builtin/utils.py +0 -0
  22. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/core/__init__.py +0 -0
  23. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/core/auth.py +0 -0
  24. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/core/console.py +0 -0
  25. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/core/data.py +0 -0
  26. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell/main.py +0 -0
  27. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell.egg-info/SOURCES.txt +0 -0
  28. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell.egg-info/dependency_links.txt +0 -0
  29. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell.egg-info/entry_points.txt +0 -0
  30. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell.egg-info/requires.txt +0 -0
  31. {flyshell-1.1.1 → flyshell-1.1.3}/src/flyshell.egg-info/top_level.txt +0 -0
  32. {flyshell-1.1.1 → flyshell-1.1.3}/tests/test_auth.py +0 -0
  33. {flyshell-1.1.1 → flyshell-1.1.3}/tests/test_data.py +0 -0
  34. {flyshell-1.1.1 → flyshell-1.1.3}/tests/test_directory.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.1.1
3
+ Version: 1.1.3
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License: MIT
6
6
  Requires-Python: >=3.10
@@ -73,32 +73,36 @@ class SysExe(BaseCmd):
73
73
  aliases = []
74
74
 
75
75
  def execute(self, args):
76
+ if not args:
77
+ return (1, "\nCommand Error: 'sys' requires at least 1 parameter(s).\n")
76
78
  if args[0] in ["-f", "--force"]:
77
79
  override = True
78
- args = args[1:]
79
- if not args:
80
+ cmd_args = args[1:]
81
+ if not cmd_args:
80
82
  return (1, "\nCommand Error: 'sys' requires at least 1 parameter(s).\n")
81
83
  else:
82
84
  override = False
83
- cmd = " ".join(args).strip().strip("\"'")
84
- cmd_normalised = " ".join(cmd.lower().split())
85
- is_blocked = any(
86
- re.search(rf"\b{re.escape(b)}\b", cmd_normalised)
87
- for b in c.BLOCKED_COMMANDS
88
- )
89
- is_dangerous = any(
90
- re.search(rf"\b{re.escape(d)}\b", cmd_normalised) for d in c.DANGER_COMMANDS
91
- )
92
- if is_blocked:
85
+ cmd_args = args
86
+ tokens_lower = [token.lower().strip("\"'") for token in cmd_args]
87
+
88
+ def matches_pattern(target_set):
89
+ for token in tokens_lower:
90
+ base_name = os.path.splitext(os.path.basename(token))[0]
91
+ if token in target_set or base_name in target_set:
92
+ return True
93
+ return False
94
+
95
+ if matches_pattern(c.BLOCKED_COMMANDS):
96
+ cmd_display = " ".join(cmd_args)
93
97
  return (
94
98
  1,
95
99
  (
96
100
  "\nSecurity Error: Flyshell has blocked execution of this command.\n"
97
- f"This command '{cmd}' is permanently restricted by Flyshell safety policy.\n"
101
+ f"This command '{cmd_display}' is permanently restricted by Flyshell safety policy.\n"
98
102
  "Flyshell has blocked your command to prevent damage to your computer.\n"
99
103
  ),
100
104
  )
101
- elif is_dangerous and not override:
105
+ if not override and matches_pattern(c.DANGER_COMMANDS):
102
106
  password = getpass.getpass(
103
107
  "\nThis command is restricted. To execute, enter your password: "
104
108
  )
@@ -109,7 +113,8 @@ class SysExe(BaseCmd):
109
113
  return (1, "\nAccount Error: Password does not match.\n")
110
114
  try:
111
115
  print()
112
- result = subprocess.run(cmd, shell=True)
116
+ raw_cmd = " ".join(cmd_args)
117
+ result = subprocess.run(raw_cmd, shell=True)
113
118
  print()
114
119
  return (result.returncode, "")
115
120
  except KeyboardInterrupt:
@@ -5,8 +5,8 @@ import os
5
5
  import platform
6
6
  import time
7
7
 
8
- BUILD = 114
9
- VERSION = "1.1.1"
8
+ BUILD = 116
9
+ VERSION = "1.1.3"
10
10
 
11
11
 
12
12
  def _resolve_app_dir() -> Path:
@@ -80,6 +80,7 @@ for cmd_obj in INSTALLED_COMMANDS:
80
80
 
81
81
  RESERVED_NAMES = set(COMMAND_REGISTRY.keys())
82
82
 
83
+
83
84
  def log(cmd):
84
85
  utc_now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
85
86
  data.append_history(cmd, utc_now)
@@ -1,4 +1,4 @@
1
- # src\flyshell\core\loader.py
1
+ # src/flyshell/core/loader.py
2
2
 
3
3
  from flyshell import constants as c
4
4
  from flyshell.abstract.base_plugin import BasePlugin
@@ -33,10 +33,17 @@ def scan_plugins(plugin_folder=None):
33
33
  if entry.exists():
34
34
  file_path = entry
35
35
  plugin_name = item.name
36
- if not file_path:
36
+ if not file_path or not plugin_name:
37
+ continue
38
+ if plugin_name in RESERVED_NAMES:
39
+ print(
40
+ f"\n⚠️ Collision Error - Plugin '{plugin_name}' conflicts with a built-in Flyshell command and will not be loaded."
41
+ )
37
42
  continue
38
43
  try:
39
44
  spec = importlib.util.spec_from_file_location(plugin_name, file_path)
45
+ if spec is None or spec.loader is None:
46
+ continue
40
47
  module = importlib.util.module_from_spec(spec)
41
48
  spec.loader.exec_module(module)
42
49
  for _, obj in inspect.getmembers(module, inspect.isclass):
@@ -51,12 +58,6 @@ def scan_plugins(plugin_folder=None):
51
58
  loaded_count = 0
52
59
  first_print = True
53
60
  for name, entries in candidates.items():
54
- failed = False
55
- if name in RESERVED_NAMES:
56
- print(
57
- f"\n⚠️ Collision Error - Plugin '{name}' conflicts with a built-in Flyshell command and will not be loaded."
58
- )
59
- failed = True
60
61
  if len(entries) > 1:
61
62
  paths = "\n - ".join(str(path) for _, path in entries)
62
63
  print(
@@ -65,8 +66,6 @@ def scan_plugins(plugin_folder=None):
65
66
  print(
66
67
  "The above plugins will not be loaded. Please rename them to unique names."
67
68
  )
68
- failed = True
69
- if failed:
70
69
  continue
71
70
  instance, _ = entries[0]
72
71
  c.PLUGINS[name] = instance
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.1.1
3
+ Version: 1.1.3
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License: MIT
6
6
  Requires-Python: >=3.10
@@ -41,3 +41,15 @@ def test_loader_handles_broken_plugin_gracefully(tmp_path, monkeypatch):
41
41
  monkeypatch.setattr(c, "USER_PLUGIN_DIR", tmp_path)
42
42
  loader.scan_plugins(plugin_folder=tmp_path)
43
43
  assert "broken" not in c.PLUGINS
44
+
45
+
46
+ def test_loader_does_not_execute_code_in_reserved_plugin(tmp_path, monkeypatch):
47
+ sentinel = tmp_path / "sentinel.txt"
48
+ bad_plugin = tmp_path / "cd.py"
49
+ bad_plugin.write_text(
50
+ f"from pathlib import Path\nPath('{sentinel.as_posix()}').write_text('executed')\n"
51
+ )
52
+ monkeypatch.setattr(c, "USER_PLUGIN_DIR", tmp_path)
53
+ loader.scan_plugins(plugin_folder=tmp_path)
54
+ assert "cd" not in c.PLUGINS
55
+ assert not sentinel.exists()
@@ -31,3 +31,11 @@ def test_sysexe_force_flag_without_arguments_returns_error():
31
31
  code, message = system.SysExe().execute(["-f"])
32
32
  assert code == 1
33
33
  assert "requires at least 1 parameter" in message
34
+
35
+
36
+ def test_sysexe_blocks_command_with_path_or_extension():
37
+ for cmd in ["/bin/dd if=/dev/zero", "diskpart.exe", "format.com"]:
38
+ tokens = cmd.split()
39
+ code, message = system.SysExe().execute(tokens)
40
+ assert code == 1
41
+ assert "Security Error" in message
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes