flyshell 1.0.8__tar.gz → 1.0.9__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.
- {flyshell-1.0.8/src/flyshell.egg-info → flyshell-1.0.9}/PKG-INFO +1 -1
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/builtin/diskops.py +51 -13
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/constants.py +2 -2
- {flyshell-1.0.8 → flyshell-1.0.9/src/flyshell.egg-info}/PKG-INFO +1 -1
- {flyshell-1.0.8 → flyshell-1.0.9}/LICENSE +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/README.md +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/pyproject.toml +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/setup.cfg +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/__init__.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/core/auth.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/core/console.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/core/data.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/core/directory.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/core/loader.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell/main.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell.egg-info/SOURCES.txt +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/tests/test_auth.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/tests/test_data.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/tests/test_directory.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/tests/test_loader.py +0 -0
- {flyshell-1.0.8 → flyshell-1.0.9}/tests/test_security.py +0 -0
|
@@ -30,6 +30,7 @@ class Dir(BaseCmd):
|
|
|
30
30
|
except Exception as e:
|
|
31
31
|
return (1, f"\nSystem Error: Unable to list directory ({e})\n")
|
|
32
32
|
|
|
33
|
+
|
|
33
34
|
class MkDir(BaseCmd):
|
|
34
35
|
name = "mkdir"
|
|
35
36
|
description = "Create a new directory from the current working directory"
|
|
@@ -50,7 +51,10 @@ class MkDir(BaseCmd):
|
|
|
50
51
|
except FileExistsError:
|
|
51
52
|
return (1, f"\nSystem Error: Directory '{target}' already exists.\n")
|
|
52
53
|
except FileNotFoundError:
|
|
53
|
-
return (
|
|
54
|
+
return (
|
|
55
|
+
1,
|
|
56
|
+
"\nSystem Error: Parent directory does not exist. Use '-p' or '--parents' to create parent directories.\n",
|
|
57
|
+
)
|
|
54
58
|
except PermissionError:
|
|
55
59
|
return (1, f"\nSystem Error: Permission denied. Cannot create '{target}'\n")
|
|
56
60
|
except Exception as e:
|
|
@@ -69,23 +73,35 @@ class RmDir(BaseCmd):
|
|
|
69
73
|
path_tokens = [arg for arg in args if arg not in ("-f", "--force")]
|
|
70
74
|
raw_target = " ".join(path_tokens).strip("\"'")
|
|
71
75
|
target_path = Path(raw_target).expanduser().resolve()
|
|
72
|
-
if
|
|
73
|
-
return (1, f"\nSystem Error: Directory '{raw_target}' not found.\n")
|
|
74
|
-
if not target_path.is_dir():
|
|
75
|
-
return (1, f"\nCommand Error: '{raw_target}' is a file, not a directory.\n")
|
|
76
|
-
if target_path == target_path.anchor or target_path.parent == target_path:
|
|
76
|
+
if target_path == target_path.parent or str(target_path) == target_path.anchor:
|
|
77
77
|
return (
|
|
78
78
|
1,
|
|
79
79
|
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
80
80
|
"You cannot delete the root filesystem directory.\n",
|
|
81
81
|
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
critical_system_dirs = [
|
|
83
|
+
Path.home().parent.resolve(),
|
|
84
|
+
Path.home().resolve(),
|
|
85
|
+
]
|
|
86
|
+
if c.HOST_OS == "Windows":
|
|
87
|
+
system_drive = os.environ.get("SystemDrive", "C:")
|
|
88
|
+
critical_system_dirs.extend([
|
|
89
|
+
Path(f"{system_drive}\\Windows").resolve(),
|
|
90
|
+
Path(f"{system_drive}\\Program Files").resolve(),
|
|
91
|
+
Path(f"{system_drive}\\Program Files (x86)").resolve(),
|
|
92
|
+
])
|
|
93
|
+
else:
|
|
94
|
+
critical_system_dirs.extend([
|
|
95
|
+
Path("/bin").resolve(),
|
|
96
|
+
Path("/etc").resolve(),
|
|
97
|
+
Path("/usr").resolve(),
|
|
98
|
+
Path("/var").resolve(),
|
|
99
|
+
])
|
|
100
|
+
if target_path in critical_system_dirs:
|
|
85
101
|
return (
|
|
86
102
|
1,
|
|
87
103
|
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
88
|
-
f"
|
|
104
|
+
f"Target '{raw_target}' is a protected operating system directory.\n",
|
|
89
105
|
)
|
|
90
106
|
if target_path == Path(os.getcwd()).resolve():
|
|
91
107
|
return (
|
|
@@ -93,6 +109,19 @@ class RmDir(BaseCmd):
|
|
|
93
109
|
"\nSystem Error: Cannot remove current working directory.\n"
|
|
94
110
|
"Switch to a different directory using 'cd' first.\n",
|
|
95
111
|
)
|
|
112
|
+
flyshell_dirs = [
|
|
113
|
+
c.APP_DIR.resolve(),
|
|
114
|
+
c.PACKAGE_ROOT.resolve(),
|
|
115
|
+
c.PROJECT_ROOT.resolve(),
|
|
116
|
+
]
|
|
117
|
+
for protected in flyshell_dirs:
|
|
118
|
+
if target_path == protected or target_path.is_relative_to(protected):
|
|
119
|
+
return (
|
|
120
|
+
1,
|
|
121
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
122
|
+
f"Target '{raw_target}' contains or belongs to Flyshell system files.\n"
|
|
123
|
+
"If you wish to delete Flyshell, use the host.\n",
|
|
124
|
+
)
|
|
96
125
|
try:
|
|
97
126
|
has_contents = any(target_path.iterdir())
|
|
98
127
|
if has_contents and not force:
|
|
@@ -107,8 +136,17 @@ class RmDir(BaseCmd):
|
|
|
107
136
|
os.rmdir(target_path)
|
|
108
137
|
return (0, f"\nSUCCESS! Removed directory '{raw_target}'\n")
|
|
109
138
|
except PermissionError:
|
|
110
|
-
return (
|
|
139
|
+
return (
|
|
140
|
+
1,
|
|
141
|
+
f"\nSystem Error: Permission denied. Cannot delete '{raw_target}'\n",
|
|
142
|
+
)
|
|
111
143
|
except OSError as e:
|
|
112
|
-
return (
|
|
144
|
+
return (
|
|
145
|
+
1,
|
|
146
|
+
f"\nSystem Error: Unable to remove directory '{raw_target}' ({e.strerror})\n",
|
|
147
|
+
)
|
|
113
148
|
except Exception as e:
|
|
114
|
-
return (
|
|
149
|
+
return (
|
|
150
|
+
1,
|
|
151
|
+
f"\nSystem Error: Unexpected error removing '{raw_target}' ({e})\n",
|
|
152
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|