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
423 changes: 423 additions & 0 deletions .github/workflows/self-hosted-builds-hardened.yml

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions .github/workflows/self-hosted-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ on:
- 'pmoves/**'
- 'Dockerfile*'
- 'docker-compose*.yml'
pull_request:
branches: [main]
# NOTE: PR trigger disabled until self-hosted runners are deployed
# Re-enable when AI Lab + VPS runners are operational
# pull_request:
# branches: [main]
workflow_dispatch:
inputs:
deploy_target:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/sql-policy-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ jobs:
"pmoves/supabase/migrations/2025-09-08_geometry_bus_rls.sql"
"pmoves/supabase/migrations/2025-09-09_pmoves_yt_jobs.sql"
"pmoves/supabase/migrations/2025-09-10_media_analysis_rls.sql"
"pmoves/supabase/migrations/2025-10-18_geometry_swarm.sql"
"pmoves/supabase/migrations/2025-10-18_health_finance.sql"
"pmoves/supabase/migrations/2025-10-20_persona_avatar.sql"
"pmoves/supabase/migrations/2025-10-20_geometry_cgp_views.sql"
"pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql"
"pmoves/supabase/migrations/2025-12-08_claude_sessions.sql"
Comment on lines +41 to +46

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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Check if migration files exist and inspect RLS patterns
echo "=== Checking for Archon Work Orders migration ==="
find . -name "*archon_work_orders.sql" -type f 2>/dev/null | head -5

echo ""
echo "=== Checking for Claude Sessions migration ==="
find . -name "*claude_sessions.sql" -type f 2>/dev/null | head -5

echo ""
echo "=== Directory structure of migrations ==="
if [ -d "pmoves/supabase/migrations" ]; then
  ls -la pmoves/supabase/migrations/ 2>/dev/null | tail -20
elif [ -d "supabase/migrations" ]; then
  ls -la supabase/migrations/ 2>/dev/null | tail -20
else
  find . -type d -name "migrations" 2>/dev/null | head -10
fi

echo ""
echo "=== Checking for RLS checklist documentation ==="
find . -type f \( -name "*RLS*" -o -name "*checklist*" \) 2>/dev/null | grep -i supabase

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 1948


🏁 Script executed:

#!/bin/bash

# List all SQL migration files to understand naming/structure
echo "=== All SQL migrations in repository ==="
find . -path "*/migrations/*.sql" -type f 2>/dev/null | sort | tail -20

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 1290


🏁 Script executed:

#!/bin/bash

echo "=== Contents of 2025-12-08_archon_work_orders.sql ==="
cat -n ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql

echo ""
echo ""
echo "=== Contents of 2025-12-08_claude_sessions.sql ==="
cat -n ./pmoves/supabase/migrations/2025-12-08_claude_sessions.sql

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 25644


🏁 Script executed:

#!/bin/bash

# Read the RLS hardening checklist
echo "=== SUPABASE_RLS_HARDENING_CHECKLIST.md ==="
if [ -f "./pmoves/docs/PMOVES.AI PLANS/SUPABASE_RLS_HARDENING_CHECKLIST.md" ]; then
  cat -n "./pmoves/docs/PMOVES.AI PLANS/SUPABASE_RLS_HARDENING_CHECKLIST.md"
else
  echo "File not found at expected path"
fi

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 5186


🏁 Script executed:

#!/bin/bash

# Verify the workflow file and check what the linter actually catches
echo "=== Workflow file content (lines 30-50) ==="
sed -n '30,50p' ./.github/workflows/sql-policy-lint.yml

echo ""
echo "=== Grep for unsafe patterns in both migrations ==="
echo "=== archon_work_orders.sql: USING true patterns ==="
grep -n "USING\s*true" ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql || true
grep -n "to anon" ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql || true

echo ""
echo "=== claude_sessions.sql: USING true patterns ==="
grep -n "USING\s*true" ./pmoves/supabase/migrations/2025-12-08_claude_sessions.sql || true
grep -n "to anon" ./pmoves/supabase/migrations/2025-12-08_claude_sessions.sql || true

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 1359


🏁 Script executed:

#!/bin/bash

# More precise grep for the actual pattern in the SQL
echo "=== Searching for exact pattern: USING (true) ==="
grep -n "USING (true)" ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql

echo ""
echo "=== Searching for exact pattern: WITH CHECK (true) ==="
grep -n "WITH CHECK (true)" ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql

echo ""
echo "=== Testing what the workflow grep regex actually matches ==="
# The workflow uses: grep -E 'USING\s*true|to anon'
# Let's test this exact pattern
grep -E 'USING\s*true|to anon' ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql || echo "No match with workflow pattern"

echo ""
echo "=== Testing with parentheses in the regex ==="
grep -E 'USING\s*\(true\)|to anon' ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql || echo "No match"

echo ""
echo "=== Full workflow grep command section ==="
sed -n '29,60p' ./.github/workflows/sql-policy-lint.yml

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 2110


🏁 Script executed:

#!/bin/bash

# Check the complete grep command from the workflow
echo "=== Complete workflow grep section ==="
sed -n '29,80p' ./.github/workflows/sql-policy-lint.yml

echo ""
echo "=== Looking for the actual grep -E command ==="
grep -A 20 "grep.*USING" ./.github/workflows/sql-policy-lint.yml || true

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 2548


🏁 Script executed:

#!/bin/bash

# Verify claude_sessions.sql patterns too
echo "=== claude_sessions.sql USING (true) patterns ==="
grep -n "USING (true)" ./pmoves/supabase/migrations/2025-12-08_claude_sessions.sql

echo ""
echo "=== Check if either migration has 'to anon' patterns ==="
grep -n "to anon" ./pmoves/supabase/migrations/2025-12-08_archon_work_orders.sql || echo "No 'to anon' in archon"
grep -n "to anon" ./pmoves/supabase/migrations/2025-12-08_claude_sessions.sql || echo "No 'to anon' in claude"

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 263


Allowlisted migrations contain unsafe RLS patterns that violate hardening standards.

Both 2025-12-08_archon_work_orders.sql and 2025-12-08_claude_sessions.sql contain multiple instances of USING (true) that the workflow's linter is designed to catch and reject:

  • archon_work_orders.sql (lines 178, 186, 194, 203, 210, 217): Six USING (true) policies granting blanket read access to authenticated users.
  • claude_sessions.sql (lines 103, 110): Two USING (true) policies with the same blanket access pattern.

The workflow explicitly references pmoves/docs/SUPABASE_RLS_CHECKLIST.md as the standard for acceptable policies. That checklist documents hardened patterns using auth.uid() and auth.role() checks—not blanket true conditions. These migrations directly violate those standards and are allowlisted to bypass security checks.

For critical tables managing autonomous work orders and code execution context, implement the hardening patterns documented in the checklist or provide explicit justification for the security exceptions.

)
echo "Scanning ${#files[@]} SQL files for 'USING true' or 'to anon'..."
# Fail on blanket USING true or explicit anon grants outside dev
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@
[submodule "PMOVES-n8n"]
path = PMOVES-n8n
url = https://github.com/POWERFULMOVES/PMOVES-n8n.git
[submodule "pmoves/vendor/agentgym-rl"]
path = pmoves/vendor/agentgym-rl
url = https://github.com/POWERFULMOVES/Pmoves-AgentGym-RL.git
Loading