Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .superset/lib/setup/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,27 @@ setup_main() {
step_failed "Seed local DB"
fi

# Step 5: Setup Neon branch
# Step 5: Seed auth token into superset-dev-data/
if ! step_seed_auth_token; then
step_failed "Seed auth token"
fi

# Step 6: Setup Neon branch
if ! step_setup_neon_branch; then
step_failed "Setup Neon branch"
fi

# Step 6: Allocate port base (file-backed)
# Step 7: Allocate port base (file-backed)
if ! allocate_port_base; then
step_failed "Allocate port base"
fi

# Step 7: Start Electric SQL
# Step 8: Start Electric SQL
if ! step_start_electric; then
step_failed "Start Electric SQL"
fi

# Step 8: Write .env file
# Step 9: Write .env file
if ! step_write_env; then
step_failed "Write .env file"
fi
Expand Down
32 changes: 32 additions & 0 deletions .superset/lib/setup/steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,38 @@ PORTSJSON
return 0
}

step_seed_auth_token() {
echo "🔑 Seeding auth token into superset-dev-data/..."

local source_token="$HOME/.superset/auth-token.enc"
local dev_data_dir="superset-dev-data"
local dest_token="$dev_data_dir/auth-token.enc"

if [ ! -f "$source_token" ]; then
warn "No auth token found at $source_token — skipping (you'll need to sign in)"
step_skipped "Seed auth token (no source token)"
return 0
fi

mkdir -p "$dev_data_dir"
chmod 700 "$dev_data_dir"

if [ -f "$dest_token" ] && [ "$FORCE_OVERWRITE_DATA" != "1" ]; then
warn "Auth token already exists at $dest_token — skipping (use -f/--force)"
step_skipped "Seed auth token (already exists)"
return 0
fi

if ! cp "$source_token" "$dest_token"; then
error "Failed to copy auth token"
return 1
fi
chmod 600 "$dest_token"
Comment on lines +473 to +477

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

cp + chmod 600 leaves a brief exposure window and has no chmod error handling.

cp creates $dest_token with umask-derived permissions (typically 644) before chmod 600 tightens them. If chmod fails (e.g., filesystem issue), the encrypted token remains group/world-readable. Use install -m 600 to set permissions atomically in a single call.

🔒 Proposed fix using install -m 600
-  if ! cp "$source_token" "$dest_token"; then
-    error "Failed to copy auth token"
-    return 1
-  fi
-  chmod 600 "$dest_token"
+  if ! install -m 600 "$source_token" "$dest_token"; then
+    error "Failed to copy auth token"
+    return 1
+  fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ! cp "$source_token" "$dest_token"; then
error "Failed to copy auth token"
return 1
fi
chmod 600 "$dest_token"
if ! install -m 600 "$source_token" "$dest_token"; then
error "Failed to copy auth token"
return 1
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.superset/lib/setup/steps.sh around lines 473 - 477, The copy+chmod sequence
using "$source_token" and "$dest_token" leaves a brief permission exposure and
lacks chmod error handling; replace the two-step cp + chmod 600 with a single
atomic install call (install -m 600 "$source_token" "$dest_token") and propagate
the existing error handling (log via error "Failed to copy auth token" and
return 1) if install fails, removing the separate chmod invocation.


success "Auth token seeded from $source_token"
return 0
}

step_seed_local_db() {
echo "💾 Seeding local DB into superset-dev-data/..."

Expand Down
Loading