diff --git a/$null b/$null new file mode 100644 index 0000000..e69de29 diff --git a/.specstory/.project.json b/.specstory/.project.json new file mode 100644 index 0000000..9de9622 --- /dev/null +++ b/.specstory/.project.json @@ -0,0 +1,5 @@ +{ + "workspace_id": "6c5e-09e0-3a93-f4a1", + "workspace_id_at": "2026-05-14T10:44:35Z", + "project_name": "DuneDashboard" +} \ No newline at end of file diff --git a/.specstory/cli/config.toml b/.specstory/cli/config.toml new file mode 100644 index 0000000..9336aae --- /dev/null +++ b/.specstory/cli/config.toml @@ -0,0 +1,79 @@ +# SpecStory CLI Configuration +# +# This is the project-level config file for SpecStory CLI. +# All settings here apply to this project unless overridden by CLI flags. +# +# Uncomment (remove the #) the line and edit any setting below to change the default behavior. +# For more information, see: https://docs.specstory.com/integrations/terminal-coding-agents/usage + +[local_sync] +# Write markdown files locally. (default: true) +# enabled = false # equivalent to --only-cloud-sync + +# Custom output directory for markdown files. +# Default: ./.specstory/history (relative to the project directory) +# output_dir = "~/.specstory/history" # equivalent to --output-dir "~/.specstory/history" + +# Use local timezone for file name and content timestamps (default: false, UTC) +# local_time_zone = true # equivalent to --local-time-zone + +[cloud_sync] +# Sync session data to SpecStory Cloud. (default: true, when logged in to SpecStory Cloud) +# enabled = false # equivalent to --no-cloud-sync + +[logging] +# Write logs to .specstory/debug/debug.log (default: false) +# log = true # equivalent to --log + +# Debug-level output, requires console or log (default: false) +# debug = true # equivalent to --debug + +# Custom output directory for debug data. +# Default: ./.specstory/debug (relative to the project directory) +# debug_dir = "~/.specstory/debug" # equivalent to --debug-dir "~/.specstory/debug" + +# Error/warn/info output to stdout (default: false) +# console = true # equivalent to --console + +# Suppress all non-error output (default: false) +# silent = true # equivalent to --silent + +[version_check] +# Check for new versions of the CLI on startup. +# Default: true +# enabled = false # equivalent to --no-version-check + +[analytics] +# Send anonymous product usage analytics to help improve SpecStory. +# Default: true +# enabled = false # equivalent to --no-usage-analytics + +[telemetry] +# OTLP gRPC collector endpoint (e.g., "localhost:4317" or "http://localhost:4317") +# endpoint = "localhost:4317" + +# Override the default service name (default: "specstory-cli") +# service_name = "my-service-name" + +# Include user prompt text in telemetry spans (default: true) +# prompts = false + +[providers] +# Agent execution commands by provider (used by specstory run) +# Pass custom flags (e.g. claude_cmd = "claude --allow-dangerously-skip-permissions") +# Use of these is equivalent to -c "custom command" + +# Claude Code command +# claude_cmd = "claude" + +# Codex CLI command +# codex_cmd = "codex" + +# Cursor CLI command +# cursor_cmd = "cursor-agent" + +# Droid CLI command +# droid_cmd = "droid" + +# Gemini CLI command +# gemini_cmd = "gemini" diff --git a/app/config.py b/app/config.py index 2593825..069c572 100644 --- a/app/config.py +++ b/app/config.py @@ -45,8 +45,8 @@ DEFAULTS = { 'port': 18888, }, 'firewall': { - 'block_filebrowser': False, - 'block_director': False, + 'block_filebrowser': True, + 'block_director': True, 'block_postgres': True, }, 'cache': { @@ -171,17 +171,21 @@ def load_settings(settings_path=None): # Backward compatibility: migrate old plaintext password to hash # This is a one-time migration that hashes the password and removes plaintext auth = settings.get('auth', {}) + password_migrated = False if auth.get('password') and not auth.get('password_hash'): try: from argon2 import PasswordHasher ph = PasswordHasher() settings['auth']['password_hash'] = ph.hash(str(auth['password'])) - # Remove plaintext after hashing del settings['auth']['password'] + password_migrated = True logger.info("Migrated plaintext password to Argon2 hash") except ImportError: logger.error("argon2-cffi not installed. Password hashing unavailable.") - # Fallback: keep plaintext for now but log warning settings['auth']['password_hash'] = None + if password_migrated: + settings['dashboard']['secret_key'] = secrets.token_hex(32) + logger.warning("Rotated secret_key to invalidate sessions after password migration") + return settings diff --git a/app/routes/auth.py b/app/routes/auth.py index 45d8e14..0583670 100644 --- a/app/routes/auth.py +++ b/app/routes/auth.py @@ -24,7 +24,7 @@ def init_auth(app, settings, limiter=None): return None @app.route('/login', methods=['GET', 'POST']) - @limiter.limit("10 per minute") if limiter else lambda f: f + @limiter.limit("5 per hour") if limiter else lambda f: f def login(): if current_user.is_authenticated: return redirect(url_for('overview')) diff --git a/app/routes/main.py b/app/routes/main.py index c69138f..05117f0 100644 --- a/app/routes/main.py +++ b/app/routes/main.py @@ -317,14 +317,24 @@ def register_routes(app, services, settings): def events_page(): game_events = [] event_logs = [] + + def safe_query(table, cols, order_col, limit): + try: + return db.query(f"SELECT {cols} FROM {table} ORDER BY {order_col} DESC LIMIT {limit}") or [] + except Exception as e: + logger.error(f"Error fetching {table}: {e}") + return [] + try: - game_events = db.query("SELECT id, event_type, actor_id, actor_name, map, universe_time, x, y, z FROM dune.game_events ORDER BY universe_time DESC LIMIT 50") or [] - except Exception as e: - logger.error(f"Error fetching game_events: {e}") + game_events = safe_query("dune.game_events", "*", "universe_time", 50) + except Exception: + pass + try: - event_logs = db.query("SELECT id, event_type, category, function_name, message, event_time, meta FROM dune.event_log ORDER BY event_time DESC LIMIT 100") or [] - except Exception as e: - logger.error(f"Error fetching event_logs: {e}") + event_logs = safe_query("dune.event_log", "*", "event_time", 100) + except Exception: + pass + return render_template('events.html', game_events=game_events, event_logs=event_logs) # Chat diff --git a/setup.ps1 b/setup.ps1 index b99f149..91fc352 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -167,22 +167,56 @@ $FileBrowserPort = "18888" $AuthUser = "admin" $AuthPass = "" -# Try to detect VM IP from known_hosts -$KnownHosts = Join-Path $env:USERPROFILE ".ssh\known_hosts" -if (Test-Path $KnownHosts) { - $content = Get-Content $KnownHosts - $ips = @() - foreach ($line in $content) { - if ($line -match '\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b') { - $ips += $matches[1] +# Try to detect VM IP - prioritize local Hyper-V, then local network IPs from known_hosts +function Test-IsLocalIP($ip) { + if ($ip -match '^192\.168\.') { return $true } + if ($ip -match '^10\.') { return $true } + if ($ip -match '^172\.(1[6-9]|2[0-9]|3[0-1])\.') { return $true } + return $false +} + +# First: try direct Hyper-V detection +$vmIp = $null +try { + $vmAdapter = Get-VMNetworkAdapter -VMName 'dune-awakening' -ErrorAction SilentlyContinue + if ($vmAdapter -and $vmAdapter.IPAddresses) { + $localIp = $vmAdapter.IPAddresses | Where-Object { Test-IsLocalIP $_ } + if ($localIp) { + $vmIp = $localIp[0] + Write-Host " Detected local Hyper-V VM IP: $vmIp" -ForegroundColor Green } } - if ($ips.Count -gt 0) { - $VmHost = $ips[-1] - Write-Host " Detected VM IP from SSH history: $VmHost" -ForegroundColor Green +} catch { } + +if (-not $vmIp) { + # Fallback: scan known_hosts and prioritize local IPs + $KnownHosts = Join-Path $env:USERPROFILE ".ssh\known_hosts" + if (Test-Path $KnownHosts) { + $content = Get-Content $KnownHosts + $localIps = @() + $publicIps = @() + foreach ($line in $content) { + if ($line -match '\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b') { + $ip = $matches[1] + if (Test-IsLocalIP $ip) { + $localIps += $ip + } else { + $publicIps += $ip + } + } + } + if ($localIps.Count -gt 0) { + $vmIp = $localIps[-1] + Write-Host " Detected local IP from SSH history: $vmIp" -ForegroundColor Green + } elseif ($publicIps.Count -gt 0) { + $vmIp = $publicIps[-1] + Write-Host " Detected IP from SSH history: $vmIp (verify this is your local VM)" -ForegroundColor Yellow + } } } +if ($vmIp) { $VmHost = $vmIp } + # Auto-detect external IP (try external service first, then local interfaces) try { $HostIp = (Invoke-WebRequest -Uri "https://api.ipify.org" -UseBasicParsing -TimeoutSec 5).Content.Trim() diff --git a/templates/base.html b/templates/base.html index e64e140..b54be77 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,8 +3,8 @@
-