Skip to content

Development Setup ​

This guide walks through setting up a local Vulcan development environment.

Prerequisites ​

Required Software ​

  • mise, which installs the Ruby, Node.js and Yarn versions the project pins
  • PostgreSQL 18 database server
  • Git version control
  • VSCode or RubyMine for IDE
  • Docker Desktop for containerized development
  • Postman or HTTPie for API testing
  • pgAdmin or TablePlus for database management

Quick Start ​

1. Clone Repository ​

bash
git clone https://github.com/mitre/vulcan.git
cd vulcan

2. Install Dependencies ​

Toolchain ​

bash
# Installs Ruby, Node.js and Yarn at the versions in mise.lock
mise trust
mise install

Ruby Dependencies ​

bash
# Install bundler
gem install bundler

# Install gems
bundle install

JavaScript Dependencies ​

bash
yarn install

3. Database Setup ​

bash
# Start PostgreSQL container
docker compose -f docker-compose.dev.yml up db -d

# Wait for healthy status
docker compose ps db   # should show "healthy"

# Create and migrate development database
bin/rails db:prepare

# Seed development data (optional — creates demo users, projects, SRGs, STIGs)
bin/rails db:seed

Option B: Local PostgreSQL ​

bash
# macOS
brew install postgresql@18
brew services start postgresql@18

# Create and migrate
bin/rails db:prepare
bin/rails db:seed

Setting Up Parallel Test Databases ​

parallel_rspec uses one database per CPU core. Set them up once after initial database creation:

bash
# 1. Create parallel test databases (vulcan_test, vulcan_test2, ..., vulcan_testN)
bundle exec rake parallel:create

# 2. Migrate the primary test database (loads schema_migrations)
bin/rails db:migrate RAILS_ENV=test

# 3. Load schema into all parallel test databases
bundle exec rake parallel:load_schema

After schema changes (new migrations), re-sync parallel databases:

bash
bin/rails db:migrate RAILS_ENV=test
bundle exec rake parallel:load_schema

4. Start Development Server ​

bash
# Using Foreman (recommended)
foreman start -f Procfile.dev

# Or manually in separate terminals:
# Terminal 1: Rails server
rails server

# Terminal 2: JavaScript bundler
yarn build:watch

Visit http://localhost:3000

Detailed Setup ​

Toolchain ​

mise reads each version from the file its ecosystem already uses and records the exact release, with checksums, in mise.lock:

ToolVersion sourceRead by
Ruby.ruby-version (the Gemfile's ruby line must match)mise
Node.js.nvmrc (release line, e.g. 24)mise; Heroku reads engines.node in package.json
YarnpackageManager in package.jsonmise, Yarn

mise install and mise exec keep mise.lock up to date (lockfile = true in mise.toml); commit it with the version change. CI installs with mise install --locked, so a version missing from the lock fails the build.

By default mise installs a prebuilt Ruby that carries its own OpenSSL. To compile Ruby against the system OpenSSL instead, for example on a FIPS-enabled host, set MISE_RUBY_COMPILE=true before mise install.

Changing a version ​

  1. Edit the version source above (.ruby-version and the Gemfile's ruby line, .nvmrc, or packageManager). For a newer Node.js release on the same line, run mise lock --bump node.
  2. Run mise install, which updates mise.lock.
  3. Update the matching build arguments in Dockerfile (RUBY_VERSION/RUBY_SHA256, NODE_VERSION/NODE_SHA256_*, YARNPKG_VERSION/YARNPKG_SHA256) and docker-bake.hcl, copying the checksums from mise.lock. The image compiles Ruby itself so that it links the base image's OpenSSL.

spec/config/toolchain_version_consistency_spec.rb fails until every pin matches mise.lock.

Database Configuration ​

PostgreSQL Installation ​

bash
# macOS
brew install postgresql@18
brew services start postgresql@18

# Ubuntu/Debian
sudo apt-get install postgresql postgresql-contrib
sudo systemctl start postgresql

# Create user and database
createuser -d vulcan_dev

Database Configuration ​

Database names follow Rails convention: vulcan_development, vulcan_test, vulcan_production. All connection settings are configurable via environment variables — see config/database.yml and port registry.

Environment Variables ​

Settings live in three files, each copied from its .example (bin/setup copies any that are missing):

FileLoaded inHolds
.envevery environment, and by Docker ComposeDatabase connection and ports
.env.developmentdevelopmentApplication settings: secrets, login options, OIDC, banner, SMTP
.env.testtestOnly what CI's backend job sets (OIDC, optionally LDAP); everything else stays at the application default
bash
cp .env.example .env
cp .env.development.example .env.development
cp .env.test.example .env.test

Rails (dotenv-rails) loads .env.<environment>.local, then .env.local (skipped in test), then .env.<environment>, then .env. The first file to set a variable wins, and a variable already set in the shell wins over every file, so .env.development and .env.test build on .env and override it. Put personal development overrides in .env.local; the test suite never reads it. All .env* files are ignored by git.

To run the OIDC discovery specs against a real identity provider, set the issuer, client ID and secret of a test OIDC application in .env.test; with the placeholder issuer they skip.

Upgrading from a single .env: it keeps working, but it is also loaded by the test suite. To split it, move everything except the database and port settings into .env.development, and copy .env.test.example to .env.test.

Authentication Setup ​

Local Authentication ​

Enabled by default. Create test users:

ruby
# Rails console
rails console

User.create!(
  email: 'admin@example.com',
  password: 'S3cure!#Pass001',
  admin: true,
  confirmed_at: Time.now
)

User.create!(
  email: 'user@example.com',
  password: 'S3cure!#Pass001',
  confirmed_at: Time.now
)

GitHub OAuth (Development) ​

  1. Create GitHub OAuth App:

    • Go to GitHub Settings > Developer settings > OAuth Apps
    • Set callback URL: http://localhost:3000/users/auth/github/callback
  2. Add to config/vulcan.yml under the providers key:

yaml
providers:
  - { name: 'github',
      app_id: 'your_client_id',
      app_secret: 'your_client_secret',
      args: { scope: 'user:email' } }

Development Workflow ​

Branch Strategy ​

bash
# Create feature branch
git checkout -b feature/your-feature-name

# Make changes and commit
git add specific_files
git commit -m "feat: Add new feature"

# Push to GitHub
git push origin feature/your-feature-name

Code Style ​

Ruby Style ​

bash
# Run RuboCop
bundle exec rubocop

# Auto-fix issues
bundle exec rubocop --autocorrect-all

JavaScript Style ​

bash
# Run ESLint
yarn lint

# Auto-fix issues
yarn lint --fix

# CI mode (fails on warnings)
yarn lint:ci

Testing ​

Run All Tests ​

bash
# Ruby tests (use parallel_rspec for full suite — 3-4x faster)
bin/parallel_rspec spec/

# JavaScript tests
yarn test:unit

# Specific test file
bundle exec rspec spec/models/user_spec.rb

# Specific test line
bundle exec rspec spec/models/user_spec.rb:42

Test Coverage ​

bash
# Generate coverage report
COVERAGE=true bundle exec rspec

# View report
open coverage/index.html

Database Tasks ​

bash
# Reset database
rails db:reset

# Run specific migration
rails db:migrate VERSION=20240101000000

# Rollback migration
rails db:rollback

# Database console
rails dbconsole

Asset Management ​

bash
# Compile assets
rails assets:precompile

# Clean assets
rails assets:clean

# Watch for changes
yarn build:watch

IDE Configuration ​

VSCode ​

Recommended extensions:

  • Ruby LSP
  • Rails
  • ESLint
  • Prettier
  • GitLens

.vscode/settings.json:

json
{
  "ruby.useBundler": true,
  "ruby.rubocop.executePath": "bundle exec rubocop",
  "editor.formatOnSave": true,
  "editor.tabSize": 2,
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true
}

RubyMine ​

  1. Set Ruby SDK to 3.4.13
  2. Configure Rails project
  3. Enable RuboCop inspection
  4. Set JavaScript version to ES6+

Common Issues ​

Bundle Install Failures ​

bash
# Missing native extensions
sudo apt-get install libpq-dev # Linux
brew install postgresql # macOS

# Permission issues
bundle config set --local path 'vendor/bundle'
bundle install

Database Connection Issues ​

bash
# Check PostgreSQL is running
pg_isready

# Check connection
psql -U vulcan_dev -d vulcan_development -h localhost

# Reset database
rails db:drop db:create db:migrate

Asset Compilation Issues ​

bash
# Clear cache
rails tmp:clear
yarn cache clean

# Reinstall dependencies
rm -rf node_modules
yarn install --immutable

# Rebuild
yarn build

Port Already in Use ​

bash
# Find process using port 3000
lsof -i :3000

# Kill process
kill -9 <PID>

# Or use different port
rails server -p 3001

Docker Development ​

Use Docker for PostgreSQL while running Rails natively for faster iteration:

bash
# Start PostgreSQL only
docker compose -f docker-compose.dev.yml up db -d

# Verify healthy
docker compose ps db

# Set up databases (dev + parallel test)
bin/rails db:prepare
bundle exec rake parallel:create
bin/rails db:migrate RAILS_ENV=test
bundle exec rake parallel:load_schema

# Run Rails natively
foreman start -f Procfile.dev

Full Docker Stack (Production-Like Testing) ​

bash
# Generate secrets
./setup-docker-secrets.sh

# Build and start everything
docker compose up --build

# Database setup runs automatically via docker-entrypoint
# First user becomes admin when VULCAN_FIRST_USER_ADMIN=true (default in Docker)

Multi-Project Setup ​

When running multiple MITRE projects simultaneously, assign unique ports to avoid conflicts. See docs/site/development/port-registry.md for port assignments.

bash
# Example .env
DATABASE_PORT=5435
POSTGRES_PORT=5435
PORT=3000
DATABASE_GSSENCMODE=disable

Docker Tips ​

  1. Use docker compose -f docker-compose.dev.yml up db -d (database-only) for fastest development cycle
  2. Use .dockerignore for faster builds (excludes docs/, downloads/, coverage/)
  3. Production image uses UBI 9 multi-stage build with jemalloc + YJIT (~529MB)
  4. docker-compose.yml supports Caddy or nginx reverse proxy profiles

Performance Optimization ​

Development Speed ​

  1. Bootsnap (enabled by default):
ruby
# config/boot.rb
require 'bootsnap/setup'
  1. Parallel Testing:
bash
bin/parallel_rspec spec/

Database Performance ​

sql
-- Add indexes for slow queries
CREATE INDEX index_rules_on_project_id ON rules(project_id);

-- Analyze query performance
EXPLAIN ANALYZE SELECT * FROM rules WHERE project_id = 1;

Debugging ​

Rails Console ​

bash
# Start console
rails console

# With sandbox (rollback on exit)
rails console --sandbox

# Production console (careful!)
RAILS_ENV=production rails console

Debugging Tools ​

ruby
# Add to Gemfile
group :development do
  gem 'pry-rails'
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'letter_opener'
end

Debug in Code ​

ruby
# Using pry
binding.pry

# Rails logger
Rails.logger.debug "Variable value: #{variable}"

# JavaScript console
console.log('Debug output:', variable);

Security in Development ​

Credentials Management ​

bash
# Edit credentials
EDITOR=nano rails credentials:edit

# Access in code
Rails.application.credentials.secret_key

Security Scanning ​

bash
# Ruby security audit
bundle exec bundler-audit check --update

# Brakeman for Rails
bundle exec brakeman

# JavaScript audit
yarn npm audit --all --recursive

Useful Commands ​

Rails Generators ​

bash
# Generate model
rails generate model User name:string email:string

# Generate controller
rails generate controller Users index show

# Generate migration
rails generate migration AddAdminToUsers admin:boolean

Database Seeds ​

ruby
# db/seeds.rb
10.times do |i|
  User.create!(
    email: "user#{i}@example.com",
    password: '1qaz!QAZ1qaz!QAZ'
  )
end

Rails Tasks ​

bash
# List all tasks
rails -T

# Custom tasks in lib/tasks/
rails vulcan:custom_task

Resources ​

Part of the MITRE Security Automation Framework (SAF)