gitarsenal-cli 1.6.3 → 1.6.5
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.
package/package.json
CHANGED
@@ -187,4 +187,37 @@ class CredentialsManager:
|
|
187
187
|
|
188
188
|
def clear_all_credentials(self):
|
189
189
|
"""Clear all saved credentials"""
|
190
|
-
return self.save_credentials({})
|
190
|
+
return self.save_credentials({})
|
191
|
+
|
192
|
+
def cleanup_security_files(self):
|
193
|
+
"""Clean up all security-related files including legacy files"""
|
194
|
+
try:
|
195
|
+
# Clear all credentials from the main file
|
196
|
+
self.clear_all_credentials()
|
197
|
+
|
198
|
+
# Remove legacy OpenAI key file
|
199
|
+
openai_key_file = self.config_dir / "openai_key"
|
200
|
+
if openai_key_file.exists():
|
201
|
+
openai_key_file.unlink()
|
202
|
+
print("✅ Removed legacy OpenAI API key file")
|
203
|
+
|
204
|
+
# Remove environment variables
|
205
|
+
import os
|
206
|
+
security_vars = [
|
207
|
+
"OPENAI_API_KEY",
|
208
|
+
"HUGGINGFACE_TOKEN",
|
209
|
+
"WANDB_API_KEY",
|
210
|
+
"MODAL_TOKEN_ID",
|
211
|
+
"MODAL_TOKEN",
|
212
|
+
"MODAL_TOKEN_SECRET"
|
213
|
+
]
|
214
|
+
|
215
|
+
for var in security_vars:
|
216
|
+
if var in os.environ:
|
217
|
+
del os.environ[var]
|
218
|
+
|
219
|
+
print("✅ Security cleanup completed successfully")
|
220
|
+
return True
|
221
|
+
except Exception as e:
|
222
|
+
print(f"❌ Error during security cleanup: {e}")
|
223
|
+
return False
|
@@ -210,23 +210,22 @@ def setup_modal_auth():
|
|
210
210
|
logger.error(f"Error setting up Modal authentication: {e}")
|
211
211
|
return False
|
212
212
|
|
213
|
-
def
|
214
|
-
"""Delete
|
215
|
-
logger.info("🧹 Cleaning up
|
213
|
+
def cleanup_security_tokens():
|
214
|
+
"""Delete all security tokens and API keys after SSH container is started"""
|
215
|
+
logger.info("🧹 Cleaning up security tokens and API keys...")
|
216
216
|
|
217
217
|
try:
|
218
|
-
# Remove
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
logger.info("✅ Removed MODAL_TOKEN_SECRET from environment")
|
218
|
+
# Remove Modal tokens from environment variables
|
219
|
+
modal_env_vars = ["MODAL_TOKEN_ID", "MODAL_TOKEN", "MODAL_TOKEN_SECRET"]
|
220
|
+
for var in modal_env_vars:
|
221
|
+
if var in os.environ:
|
222
|
+
del os.environ[var]
|
223
|
+
logger.info(f"✅ Removed {var} from environment")
|
224
|
+
|
225
|
+
# Remove OpenAI API key from environment
|
226
|
+
if "OPENAI_API_KEY" in os.environ:
|
227
|
+
del os.environ["OPENAI_API_KEY"]
|
228
|
+
logger.info("✅ Removed OpenAI API key from environment")
|
230
229
|
|
231
230
|
# Delete ~/.modal.toml file
|
232
231
|
from pathlib import Path
|
@@ -235,9 +234,20 @@ def cleanup_modal_token():
|
|
235
234
|
modal_toml.unlink()
|
236
235
|
logger.info(f"✅ Deleted Modal token file at {modal_toml}")
|
237
236
|
|
238
|
-
|
237
|
+
# Delete ~/.gitarsenal/openai_key file
|
238
|
+
openai_key_file = Path.home() / ".gitarsenal" / "openai_key"
|
239
|
+
if openai_key_file.exists():
|
240
|
+
openai_key_file.unlink()
|
241
|
+
logger.info(f"✅ Deleted OpenAI API key file at {openai_key_file}")
|
242
|
+
|
243
|
+
logger.info("✅ Security cleanup completed successfully")
|
239
244
|
except Exception as e:
|
240
|
-
logger.error(f"❌ Error during
|
245
|
+
logger.error(f"❌ Error during security cleanup: {e}")
|
246
|
+
|
247
|
+
# Keep the old function for backward compatibility
|
248
|
+
def cleanup_modal_token():
|
249
|
+
"""Legacy function - now calls the comprehensive cleanup"""
|
250
|
+
cleanup_security_tokens()
|
241
251
|
|
242
252
|
@app.route('/api/health', methods=['GET'])
|
243
253
|
def health_check():
|
@@ -1396,7 +1396,7 @@ def create_modal_ssh_container(gpu_type, repo_url=None, repo_name=None, setup_co
|
|
1396
1396
|
try:
|
1397
1397
|
print("📦 Building SSH-enabled image...")
|
1398
1398
|
ssh_image = (
|
1399
|
-
modal.Image.
|
1399
|
+
modal.Image.from_registry("nvidia/cuda:12.4.0-devel-ubuntu22.04", add_python="3.11")
|
1400
1400
|
.apt_install(
|
1401
1401
|
"openssh-server", "sudo", "curl", "wget", "vim", "htop", "git",
|
1402
1402
|
"python3", "python3-pip", "build-essential", "tmux", "screen", "nano",
|
@@ -2278,6 +2278,45 @@ def cleanup_modal_token():
|
|
2278
2278
|
except Exception as e:
|
2279
2279
|
print(f"❌ Error during token cleanup: {e}")
|
2280
2280
|
|
2281
|
+
def cleanup_security_tokens():
|
2282
|
+
"""Delete all security tokens and API keys after SSH container is started"""
|
2283
|
+
print("🧹 Cleaning up security tokens and API keys...")
|
2284
|
+
|
2285
|
+
try:
|
2286
|
+
# Remove Modal tokens from environment variables
|
2287
|
+
modal_env_vars = ["MODAL_TOKEN_ID", "MODAL_TOKEN", "MODAL_TOKEN_SECRET"]
|
2288
|
+
for var in modal_env_vars:
|
2289
|
+
if var in os.environ:
|
2290
|
+
del os.environ[var]
|
2291
|
+
# print(f"✅ Removed {var} from environment")
|
2292
|
+
|
2293
|
+
# Remove OpenAI API key from environment
|
2294
|
+
if "OPENAI_API_KEY" in os.environ:
|
2295
|
+
del os.environ["OPENAI_API_KEY"]
|
2296
|
+
# print("✅ Removed OpenAI API key from environment")
|
2297
|
+
|
2298
|
+
# Delete ~/.modal.toml file
|
2299
|
+
home_dir = os.path.expanduser("~")
|
2300
|
+
modal_toml = os.path.join(home_dir, ".modal.toml")
|
2301
|
+
if os.path.exists(modal_toml):
|
2302
|
+
os.remove(modal_toml)
|
2303
|
+
# print(f"✅ Deleted Modal token file at {modal_toml}")
|
2304
|
+
|
2305
|
+
# Delete ~/.gitarsenal/openai_key file
|
2306
|
+
openai_key_file = os.path.join(home_dir, ".gitarsenal", "openai_key")
|
2307
|
+
if os.path.exists(openai_key_file):
|
2308
|
+
os.remove(openai_key_file)
|
2309
|
+
# print(f"✅ Deleted OpenAI API key file at {openai_key_file}")
|
2310
|
+
|
2311
|
+
# print("✅ Security cleanup completed successfully")
|
2312
|
+
except Exception as e:
|
2313
|
+
print(f"❌ Error during security cleanup: {e}")
|
2314
|
+
|
2315
|
+
# Keep the old function for backward compatibility
|
2316
|
+
def cleanup_modal_token():
|
2317
|
+
"""Legacy function - now calls the comprehensive cleanup"""
|
2318
|
+
cleanup_security_tokens()
|
2319
|
+
|
2281
2320
|
def show_usage_examples():
|
2282
2321
|
"""Display usage examples for the script."""
|
2283
2322
|
print("Usage Examples\n")
|
@@ -1396,7 +1396,7 @@ def create_modal_ssh_container(gpu_type, repo_url=None, repo_name=None, setup_co
|
|
1396
1396
|
try:
|
1397
1397
|
print("📦 Building SSH-enabled image...")
|
1398
1398
|
ssh_image = (
|
1399
|
-
modal.Image.
|
1399
|
+
modal.Image.from_registry("nvidia/cuda:12.4.0-devel-ubuntu22.04", add_python="3.11")
|
1400
1400
|
.apt_install(
|
1401
1401
|
"openssh-server", "sudo", "curl", "wget", "vim", "htop", "git",
|
1402
1402
|
"python3", "python3-pip", "build-essential", "tmux", "screen", "nano",
|
@@ -2278,6 +2278,45 @@ def cleanup_modal_token():
|
|
2278
2278
|
except Exception as e:
|
2279
2279
|
print(f"❌ Error during token cleanup: {e}")
|
2280
2280
|
|
2281
|
+
def cleanup_security_tokens():
|
2282
|
+
"""Delete all security tokens and API keys after SSH container is started"""
|
2283
|
+
print("🧹 Cleaning up security tokens and API keys...")
|
2284
|
+
|
2285
|
+
try:
|
2286
|
+
# Remove Modal tokens from environment variables
|
2287
|
+
modal_env_vars = ["MODAL_TOKEN_ID", "MODAL_TOKEN", "MODAL_TOKEN_SECRET"]
|
2288
|
+
for var in modal_env_vars:
|
2289
|
+
if var in os.environ:
|
2290
|
+
del os.environ[var]
|
2291
|
+
# print(f"✅ Removed {var} from environment")
|
2292
|
+
|
2293
|
+
# Remove OpenAI API key from environment
|
2294
|
+
if "OPENAI_API_KEY" in os.environ:
|
2295
|
+
del os.environ["OPENAI_API_KEY"]
|
2296
|
+
# print("✅ Removed OpenAI API key from environment")
|
2297
|
+
|
2298
|
+
# Delete ~/.modal.toml file
|
2299
|
+
home_dir = os.path.expanduser("~")
|
2300
|
+
modal_toml = os.path.join(home_dir, ".modal.toml")
|
2301
|
+
if os.path.exists(modal_toml):
|
2302
|
+
os.remove(modal_toml)
|
2303
|
+
# print(f"✅ Deleted Modal token file at {modal_toml}")
|
2304
|
+
|
2305
|
+
# Delete ~/.gitarsenal/openai_key file
|
2306
|
+
openai_key_file = os.path.join(home_dir, ".gitarsenal", "openai_key")
|
2307
|
+
if os.path.exists(openai_key_file):
|
2308
|
+
os.remove(openai_key_file)
|
2309
|
+
# print(f"✅ Deleted OpenAI API key file at {openai_key_file}")
|
2310
|
+
|
2311
|
+
# print("✅ Security cleanup completed successfully")
|
2312
|
+
except Exception as e:
|
2313
|
+
print(f"❌ Error during security cleanup: {e}")
|
2314
|
+
|
2315
|
+
# Keep the old function for backward compatibility
|
2316
|
+
def cleanup_modal_token():
|
2317
|
+
"""Legacy function - now calls the comprehensive cleanup"""
|
2318
|
+
cleanup_security_tokens()
|
2319
|
+
|
2281
2320
|
def show_usage_examples():
|
2282
2321
|
"""Display usage examples for the script."""
|
2283
2322
|
print("Usage Examples\n")
|