Skip to content

[Snyk] Security upgrade express from 4.21.2 to 4.22.0 #106

[Snyk] Security upgrade express from 4.21.2 to 4.22.0

[Snyk] Security upgrade express from 4.21.2 to 4.22.0 #106

Workflow file for this run

name: Linux Testing
on:
push:
branches: [ main, develop, dev ]
pull_request:
branches: [ main, develop, dev ]
workflow_dispatch: # Allow manual trigger
jobs:
linux-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: |
Cypher/front-end/package.json
Cypher/backend/node_internal_api/package.json
- name: Update package lists
run: |
sudo apt-get update
- name: Setup Docker
uses: docker/setup-buildx-action@v3
- name: Make setup script executable
run: |
cd Cypher
chmod +x scripts/setup.sh
- name: Run Cypher Setup
run: |
cd Cypher
./scripts/setup.sh
- name: Verify Setup Success
run: |
cd Cypher
# Check if virtual environment was created
if [ ! -d "venv" ] && [ ! -d "../venv" ] && [ ! -d "../cyvenv" ] && [ ! -d "cyvenv" ]; then
echo "❌ Virtual environment not found"
exit 1
fi
# Check if .env file was created
if [ ! -f ".env" ]; then
echo "❌ .env file not created"
exit 1
fi
# Check if start.sh was created and is executable
if [ ! -f "scripts/start.sh" ] || [ ! -x "scripts/start.sh" ]; then
echo "❌ scripts/start.sh not created or not executable"
exit 1
fi
# Check if dev.sh was created and is executable
if [ ! -f "scripts/dev.sh" ] || [ ! -x "scripts/dev.sh" ]; then
echo "❌ scripts/dev.sh not created or not executable"
exit 1
fi
# Check Docker containers are running
if ! docker compose ps | grep -q "Up"; then
echo "❌ Docker services not running"
exit 1
fi
echo "✅ Setup verification passed"
- name: Test Database Connectivity
run: |
cd Cypher
# Find and activate virtual environment
VENV_PATHS=("./venv" "../venv" "../cyvenv" "./cyvenv")
VENV_PATH=""
for path in "${VENV_PATHS[@]}"; do
if [ -d "$path" ] && [ -f "$path/bin/activate" ]; then
VENV_PATH="$path"
break
fi
done
source "$VENV_PATH/bin/activate"
# Test database connectivity
if ! docker compose ps | grep -q "postgres.*Up"; then
echo "PostgreSQL container not running"
exit 1
fi
if ! docker compose ps | grep -q "redis.*Up"; then
echo "Redis container not running"
exit 1
fi
echo "Database services are running"
- name: Run Application Tests (if any)
run: |
cd Cypher
# Activate virtual environment
VENV_PATHS=("./venv" "../venv" "../cyvenv" "./cyvenv")
VENV_PATH=""
for path in "${VENV_PATHS[@]}"; do
if [ -d "$path" ] && [ -f "$path/bin/activate" ]; then
VENV_PATH="$path"
break
fi
done
source "$VENV_PATH/bin/activate"
# Check if there are any test files and run them
if [ -d "tests" ]; then
echo "Running Python tests..."
python3 -m pytest tests/ -v
elif ls test_*.py 1> /dev/null 2>&1; then
echo "Running Python test files..."
python3 -m pytest test_*.py -v
else
echo "No Python test files found, skipping test execution"
fi
# Check for Node.js tests
cd backend/node_internal_api
if [ -f "package.json" ]; then
if grep -q '"test"' package.json; then
echo "Running Node.js tests..."
npm test
fi
fi
cd ..
- name: Test Application Startup Components
run: |
cd Cypher
# Find and activate virtual environment
VENV_PATHS=("./venv" "../venv" "../cyvenv" "./cyvenv")
VENV_PATH=""
for path in "${VENV_PATHS[@]}"; do
if [ -d "$path" ] && [ -f "$path/bin/activate" ]; then
VENV_PATH="$path"
break
fi
done
source "$VENV_PATH/bin/activate"
echo "Testing Flask application startup..."
./scripts/generate_secrets.sh --yes
# Start Internal Python API in background for testing
timeout 30 python backend/python_internal_api/internal_api.py &
INTERNAL_API_PID=$!
# Start Flask in background for testing
timeout 30 python backend/Flask-server/main.py &
FLASK_PID=$!
# Start Node.js API in background for testing
cd backend/node_internal_api
timeout 30 node app.js &
NODE_PID=$!
cd ../..
# Wait a bit for services to start
sleep 10
# Test if services are responding
if curl -f http://localhost:5000 --max-time 10 --silent > /dev/null; then
echo "Flask backend responding"
else
echo "Flask backend not responding"
fi
if curl -f http://localhost:3000/health --max-time 10 --silent > /dev/null; then
echo "Node.js API responding"
else
echo "Node.js API not responding"
fi
if curl -f http://127.0.0.1:5001/health --max-time 10 --silent > /dev/null; then
echo "Internal auth API responding"
else
echo "Internal auth API not responding"
fi
# Clean up processes
kill $FLASK_PID $NODE_PID $INTERNAL_API_PID 2>/dev/null || true
sleep 2
echo "Startup components test completed"
- name: Run Registration Automation
continue-on-error: true
run: |
cd Cypher
# Install automation dependencies
cd test
npm install
npx playwright install chromium
cd ..
# Find and activate virtual environment before starting services
VENV_PATHS=("./venv" "../venv" "../cyvenv" "./cyvenv")
VENV_PATH=""
for path in "${VENV_PATHS[@]}"; do
if [ -d "$path" ] && [ -f "$path/bin/activate" ]; then
VENV_PATH="$path"
break
fi
done
if [ -z "$VENV_PATH" ]; then
echo "ERROR: No virtual environment found"
exit 1
fi
source "$VENV_PATH/bin/activate"
# Start services for automation testing
# Start internal Python API first
python backend/python_internal_api/internal_api.py &
INTERNAL_API_PID=$!
# Start Node.js API
cd backend/node_internal_api
node app.js &
NODE_PID=$!
cd ../..
# Start Flask app
python backend/Flask-server/main.py &
FLASK_PID=$!
echo "Started services - Internal API PID: $INTERNAL_API_PID, Node PID: $NODE_PID, Flask PID: $FLASK_PID"
# Wait for services to be ready
sleep 15
# Check if processes are still running
if kill -0 $NODE_PID 2>/dev/null; then
echo "Node API process is running"
else
echo "ERROR: Node API process died"
fi
if kill -0 $FLASK_PID 2>/dev/null; then
echo "Flask process is running"
else
echo "ERROR: Flask process died"
fi
# Health check
echo "Checking service health..."
# Check Node API (try multiple endpoints)
if curl -f http://localhost:3000/health --max-time 5 --silent > /dev/null; then
echo "Node API health endpoint responding"
elif curl -f http://localhost:3000/ --max-time 5 --silent > /dev/null; then
echo "Node API root endpoint responding"
else
echo "WARNING: Node API not responding"
fi
# Check Flask
if curl -f http://localhost:5000/ --max-time 5 --silent > /dev/null; then
echo "Flask service responding"
else
echo "WARNING: Flask service not responding"
fi
# Check Internal Auth API
if curl -f http://127.0.0.1:5001/health --max-time 5 --silent > /dev/null; then
echo "Internal auth API responding"
else
echo "WARNING: Internal auth API not responding"
fi
# Run the user automation
cd test
USERNAME="ci_test_$(date +%s)"
echo "Running user automation test with username: $USERNAME"
AUTOMATION_LOG=automation_output.log
set +e
node demo-user-automation.js http://localhost:5000 "$USERNAME" | tee "$AUTOMATION_LOG"
EXIT_CODE=${PIPESTATUS[0]}
set -e
SUMMARY_LINE=$(grep "AUTOMATION_RESULT" "$AUTOMATION_LOG" | tail -n 1 || true)
if [ -n "$SUMMARY_LINE" ]; then
echo "Automation summary detected."
SUMMARY_JSON=${SUMMARY_LINE#AUTOMATION_RESULT }
echo "$SUMMARY_JSON" > automation_summary.json
echo "::group::Parsed automation summary"
python parse_automation_summary.py
echo "::endgroup::"
else
echo "WARNING: Automation summary not found in output."
fi
echo "$EXIT_CODE" > automation_exit_code.txt
cd ..
# Clean up automation processes
kill $FLASK_PID $NODE_PID $INTERNAL_API_PID 2>/dev/null || true
sleep 2
exit $EXIT_CODE
- name: Validate Login Automation Results
if: always()
run: |
cd Cypher/test
if [ ! -f automation_exit_code.txt ]; then
echo "ERROR: automation_exit_code.txt not found"
exit 1
fi
if [ ! -f automation_summary.json ]; then
echo "ERROR: automation_summary.json not found"
exit 1
fi
python3 validate_automation_summary.py
- name: Verify User Registration in Database
run: |
cd Cypher/test
VENV_PATHS=("../venv" "../../venv" "../cyvenv" "../../cyvenv" "./venv")
VENV_PATH=""
for path in "${VENV_PATHS[@]}"; do
if [ -d "$path" ] && [ -f "$path/bin/activate" ]; then
VENV_PATH="$path"
break
fi
done
if [ -z "$VENV_PATH" ]; then
echo "ERROR: No virtual environment found for verification step"
exit 1
fi
source "$VENV_PATH/bin/activate"
python3 verify_users.py
cd ..
- name: Cleanup
run: |
cd Cypher
# Stop Docker containers
docker compose down
# Kill any remaining processes
pkill -f "python.*main.py" || true
pkill -f "node.*app.js" || true
echo "Cleanup completed"
if: always()