Pull Linode token from Infisical as default; remove pointless webrunner sub-menu
This commit is contained in:
@@ -36,79 +36,10 @@ PROVIDER_LABELS = {'linode': 'Linode', 'aws': 'AWS', 'flokinet': 'FlokiNET'}
|
||||
|
||||
# ── menu ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
def _available_providers() -> list[str]:
|
||||
"""Return providers that have credentials available."""
|
||||
import subprocess
|
||||
available = []
|
||||
creds_bin = os.path.expanduser('~/.local/bin/creds')
|
||||
|
||||
# Linode — check env first, then Infisical
|
||||
if os.environ.get('LINODE_TOKEN'):
|
||||
available.append('linode')
|
||||
else:
|
||||
try:
|
||||
token = subprocess.check_output(
|
||||
[creds_bin, 'get', 'LINODE_TOKEN', 'homelab'],
|
||||
text=True, stderr=subprocess.DEVNULL,
|
||||
).strip()
|
||||
if token:
|
||||
available.append('linode')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# AWS
|
||||
if os.environ.get('AWS_ACCESS_KEY_ID') and os.environ.get('AWS_SECRET_ACCESS_KEY'):
|
||||
available.append('aws')
|
||||
|
||||
# FlokiNET
|
||||
if os.environ.get('FLOKINET_API_KEY'):
|
||||
available.append('flokinet')
|
||||
else:
|
||||
try:
|
||||
key = subprocess.check_output(
|
||||
[creds_bin, 'get', 'FLOKINET_API_KEY', 'homelab'],
|
||||
text=True, stderr=subprocess.DEVNULL,
|
||||
).strip()
|
||||
if key:
|
||||
available.append('flokinet')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return available
|
||||
|
||||
|
||||
def webrunner_menu():
|
||||
while True:
|
||||
clear_screen()
|
||||
print_banner()
|
||||
print(f"{COLORS['CYAN']}WEBRUNNER — Distributed Geo-Targeted Recon{COLORS['RESET']}")
|
||||
print(f"{COLORS['CYAN']}==========================================={COLORS['RESET']}")
|
||||
|
||||
available = _available_providers()
|
||||
if available:
|
||||
providers_str = ', '.join(PROVIDER_LABELS[p] for p in available)
|
||||
print(f"1) New Scan Deployment [{providers_str}]")
|
||||
else:
|
||||
print(f"{COLORS['YELLOW']} No provider credentials found.{COLORS['RESET']}")
|
||||
print(f" Set a token in Infisical to enable deployments:")
|
||||
print(f" creds set LINODE_TOKEN <token> homelab")
|
||||
|
||||
print(f"\n99) Return to Main Menu")
|
||||
|
||||
choice = input(f"\nSelect: ").strip()
|
||||
if choice == "1":
|
||||
if not available:
|
||||
print(f"{COLORS['RED']}No credentials configured. Add a provider token first.{COLORS['RESET']}")
|
||||
wait_for_input()
|
||||
continue
|
||||
config = gather_webrunner_parameters()
|
||||
if config:
|
||||
execute_webrunner_deployment(config)
|
||||
elif choice == "99":
|
||||
break
|
||||
else:
|
||||
print(f"{COLORS['RED']}Invalid option.{COLORS['RESET']}")
|
||||
wait_for_input()
|
||||
config = gather_webrunner_parameters()
|
||||
if config:
|
||||
execute_webrunner_deployment(config)
|
||||
|
||||
|
||||
# ── helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
+22
-8
@@ -3,24 +3,38 @@
|
||||
Linode provider utilities for C2ingRed deployment system
|
||||
"""
|
||||
|
||||
import os
|
||||
import random
|
||||
import logging
|
||||
import subprocess
|
||||
from .common import COLORS, load_vars_file
|
||||
|
||||
def get_linode_credentials(provider_vars=None):
|
||||
"""Get Linode API token from user or vars file"""
|
||||
if not provider_vars:
|
||||
provider_vars = load_vars_file('linode')
|
||||
|
||||
default_token = provider_vars.get('linode_token', '')
|
||||
|
||||
"""Get Linode API token — Infisical first, vars.yaml fallback, then prompt."""
|
||||
default_token = ''
|
||||
|
||||
# Try Infisical first
|
||||
try:
|
||||
default_token = subprocess.check_output(
|
||||
[os.path.expanduser('~/.local/bin/creds'), 'get', 'LINODE_TOKEN', 'homelab'],
|
||||
text=True, stderr=subprocess.DEVNULL,
|
||||
).strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Fall back to vars.yaml
|
||||
if not default_token:
|
||||
if not provider_vars:
|
||||
provider_vars = load_vars_file('linode')
|
||||
default_token = provider_vars.get('linode_token', '')
|
||||
|
||||
print(f"\n{COLORS['BLUE']}Linode Configuration{COLORS['RESET']}")
|
||||
token = input(f"Linode API Token [{'*****' if default_token else 'required'}]: ") or default_token
|
||||
|
||||
|
||||
if not token:
|
||||
print(f"{COLORS['RED']}Linode API token is required{COLORS['RESET']}")
|
||||
return None
|
||||
|
||||
|
||||
return {'linode_token': token}
|
||||
|
||||
def select_linode_region(provider_vars=None, component=None):
|
||||
|
||||
Reference in New Issue
Block a user