gitarsenal-cli 1.6.3 → 1.6.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -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 cleanup_modal_token():
214
- """Delete Modal token files and environment variables after SSH container is started"""
215
- logger.info("🧹 Cleaning up Modal token for security...")
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 token from environment variables
219
- if "MODAL_TOKEN_ID" in os.environ:
220
- del os.environ["MODAL_TOKEN_ID"]
221
- logger.info("✅ Removed MODAL_TOKEN_ID from environment")
222
-
223
- if "MODAL_TOKEN" in os.environ:
224
- del os.environ["MODAL_TOKEN"]
225
- logger.info("✅ Removed MODAL_TOKEN from environment")
226
-
227
- if "MODAL_TOKEN_SECRET" in os.environ:
228
- del os.environ["MODAL_TOKEN_SECRET"]
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
- logger.info("✅ Modal token cleanup completed successfully")
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 Modal token cleanup: {e}")
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():
@@ -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")
@@ -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")