Commit Graph

100 Commits

Author SHA1 Message Date
Ken Johnson 5dd05249ec Fix remaining CSS selector and form field issues from UI/UX overhaul
This addresses the remaining test failures @jasnow reported in issue #486.

Fixes:
1. Ambiguous Login button - Changed from click_button "Login" to
   find("input[type='submit'][value='Login']").click to specifically
   target the form submit button and avoid the header Login button

2. Fixed password_complexity_spec field names:
   - user_email → email
   - user_first_name → first_name
   - user_last_name → last_name
   - user_password → password
   - user_password_confirmation → password_confirmation
   - Submit → Create Account (correct button text)

3. Applied same selector fix to login helper in capybara_shared.rb

These changes complete the test suite fixes for the new UI that was
introduced in the file upload UX improvements.

Related: #486

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 08:21:46 -05:00
Ken Johnson 7afaabdb9b Remove confusing pending status from password_hashing_spec
The password_hashing_spec was using 'pending unless verifying_fixed?' which caused
confusing output in maintainer mode:
- Before: "1 example, 0 failures, 1 pending" with "(compared using ==)" message
- After: "1 example, 0 failures" - clean output

The spec now uses conditional expectations:
- Training mode: expects password is NOT MD5 hashed (test fails, vulnerability exists)
- Maintainer mode: expects password IS MD5 hashed (test passes, verifies vulnerability)

This addresses the "(compared using ==)" error message that @jasnow reported in issue #486.

Related to #486
2026-01-04 17:38:40 -05:00
Ken Johnson 7712f5867f Fix test failures on Ubuntu and other platforms (issue #486)
Fixes test suite to run cleanly across different platforms (macOS, Linux, Windows)
after the Rails 5→8 upgrade and UI/UX overhaul.

## Issues Fixed

1. **Firefox/Selenium driver errors**: Removed deprecated Poltergeist/PhantomJS
   configuration and properly configured Selenium with headless Chrome. This
   works across all platforms without requiring Firefox.

2. **CSS selector errors** ('Unable to find css ".signup"'): The UI/UX overhaul
   removed the .signup CSS class. Updated the login helper to work with the
   new login form structure.

3. **Ambiguous Login button**: The new UI has both a Login button and Login link.
   Changed from `click_on "Login"` to `click_button "Login"` to be specific.

4. **Deprecation warning**: Opted into Rails 8.1 behavior for to_time timezone
   preservation to eliminate deprecation warnings.

## Changes

- spec/support/capybara_shared.rb:
  * Removed deprecated Poltergeist/PhantomJS configuration
  * Configured Selenium with headless Chrome
  * Updated login helper to work with new UI (removed .signup/.actions selectors)
  * Changed click_on to click_button for specificity

- spec/spec_helper.rb:
  * Removed conflicting Capybara.javascript_driver override that was forcing
    selenium_headless (which tried to use Firefox)

- config/application.rb:
  * Added config.active_support.to_time_preserves_timezone = :zone to opt into
    Rails 8.1 behavior and eliminate deprecation warning

## Test Results

Before: 43 failures (driver errors, CSS selector errors)
After: 46 examples, 0 failures, 14 pending 

The 14 pending specs are expected - they verify vulnerabilities still exist.

## Platform Requirements

JavaScript tests now require Chrome/Chromium to be installed:
- macOS: Chrome is usually installed
- Ubuntu: `sudo apt-get install chromium-browser chromium-chromedriver`
- Windows: Chrome is usually installed

Fixes #486

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 11:09:14 -05:00
Ken Johnson 9f157012b0 Add Rails 8 vulnerabilities aligned with OWASP Top 10 2025
This commit adds comprehensive coverage of OWASP Top 10 2025 categories,
implementing both ReDoS (A05:2025) and Software Supply Chain (A03:2025)
vulnerabilities for educational purposes.

## New Vulnerabilities Added

### A05:2025 - Injection (ReDoS)
- Implemented three ReDoS endpoints in TutorialsController:
  - POST /tutorials/redos_email - Vulnerable email regex with nested quantifiers
  - POST /tutorials/redos_username - Classic (a+)+ pattern
  - POST /tutorials/redos_email_safe - Secure version using URI::MailTo::EMAIL_REGEXP
- Added Regexp.timeout = 1.0 configuration (Rails 8 protection)
- All endpoints include timing and error handling demonstrations

### A03:2025 - Software Supply Chain Failures
- Demonstrated missing SRI on CDN assets in application.html.erb
- Added educational endpoints:
  - GET /tutorials/supply_chain - Comprehensive supply chain vulnerabilities overview
  - GET /tutorials/check_dependencies - Dependency scanning simulation
- Covers: Missing SRI, outdated dependencies, no SBOM, insecure gem sources

## Files Changed

### New Files
- config/initializers/regexp_timeout.rb: Enables Rails 8 ReDoS protection
- spec/controllers/tutorials_controller_spec.rb: 23 passing tests for all endpoints

### Modified Files
- app/controllers/tutorials_controller.rb: Added 5 new educational endpoints
- app/views/layouts/application.html.erb: Added CDN assets WITHOUT SRI (intentional vuln)
- config/routes.rb: Added routes for ReDoS and supply chain endpoints

## Test Coverage
- 23 RSpec tests covering both ReDoS and A03 vulnerabilities
- Tests validate vulnerability behavior, error handling, and educational content
- All tests passing

## Educational Value
- Demonstrates OWASP 2025 categories A03 and A05
- Shows both vulnerable and secure implementations
- Includes real-world CVE examples (British Airways, Magecart)
- Provides mitigation guidance and tool recommendations

This completes 100% coverage of OWASP Top 10 2025 categories in RailsGoat Rails 8.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 15:11:54 -05:00
Ken Johnson f716836c15 Upgrade to Ruby 3.3.6 and Rails 8.0.4
This major upgrade brings RailsGoat up to date with the latest versions:
- Ruby 2.6.5 → 3.3.6
- Rails 6.0.0 → 8.0.4

## Key Changes

### Dependencies
- Upgraded all gems to Rails 8-compatible versions
- Removed deprecated gems: therubyracer, coffee-rails, poltergeist,
  travis-lint, rails-perftest, unicorn, powder, rubocop-github
- Updated puma to 6.6.1, sqlite3 to 2.8.1, rspec-rails to 8.0.2
- Added modern Rails 8 features: importmap-rails, stimulus-rails, turbo-rails
- Replaced poltergeist with selenium-webdriver for integration tests

### Code Changes
- Converted CoffeeScript files to plain JavaScript
- Updated test configuration to use Selenium headless driver
- Updated database schema to Rails 8 format

## Testing
- Application starts successfully and responds to requests
- Test suite runs with 23 examples (14 intentional vulnerability failures)
- Database migrations applied successfully

## Notes
This upgrade maintains all intentional security vulnerabilities that make
RailsGoat an effective training tool. The failing tests are expected and
demonstrate the vulnerabilities the application is designed to teach.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 15:30:49 -05:00
Ken Johnson ce7482aec6 Merge pull request #372 from rifkinni/clean_up_specs
Clean up specs
2020-03-19 12:43:49 -04:00
Justin Collins 7e25fd0f6c Fix decryption IV 2020-03-18 09:12:58 -07:00
Nicole Rifkin 5191409db6 validate root is localhost in redirect_spec 2019-11-21 09:07:38 -05:00
Nicole Rifkin 483112bb18 clean up mass_assignment_spec 2019-11-20 17:06:23 -05:00
Nicole Rifkin e72f4ca64f update tutorial links 2019-11-20 14:27:56 -05:00
Nicole Rifkin 02dcd42bc7 clean up unvalidated_redirects_spec 2019-11-20 09:57:58 -05:00
Nicole Rifkin d82ff9a66a clean up insecure_dor_spec 2019-11-20 09:24:24 -05:00
Nicole Rifkin 18433833d3 clean up url_access_spec 2019-11-20 07:53:25 -05:00
Nicole Rifkin 7eb0ddf229 clean up insecure_dor_spec 2019-11-20 07:49:52 -05:00
Al Snow 23d145129d Upgraded Ruby to 2.7.0-preview1 and Rails to 6.0.0 - fixed 1 spec 2019-09-09 15:13:29 -04:00
Al Snow b8262ecb0a Fixed rubocop messages 2018-03-08 17:02:24 -05:00
cktricky 00af8293b2 changed user_id to id 2017-12-19 08:26:02 -05:00
Joseph Mastey 656f0a0834 fix copypasta from benefit spec 2017-12-16 10:10:09 -06:00
Joseph Mastey 33d2c46df5 please robot overlords, plus verbiage change 2017-12-13 08:37:23 -06:00
Joseph Mastey 5643edcc5d refactor vulnerabilities so that users can turn them from failing to passing 2017-12-13 08:33:50 -06:00
Joseph Mastey fb2254342e Changes tests to invert the logic, so that users can turn tests from red to green 2017-12-13 08:21:52 -06:00
Joseph Mastey bb863f5156 appease our new robot overlords.
(I voted for Krang)
2017-12-12 21:00:45 -06:00
Joseph Mastey 4587a5ff67 more fixes for tests post-merge 2017-12-12 15:25:37 -06:00
Joseph Mastey 6969322920 feat(tests): fix tests for change in user_id format 2017-12-12 15:22:39 -06:00
Joseph Mastey b6c2259b88 removes user_id column from User model to use idiomatic Rails automatic IDs 2017-12-12 15:19:22 -06:00
Joseph Mastey 6e0a0a8312 feat(cops): clean rubocop run
1. ignoring one file because it's an intentional vuln
2. made a few small semantic changes, but verified that they're equivalent.
2017-12-06 17:14:25 -06:00
Joseph Mastey 9902345291 chore(rubocop): giganto rubocop commit.
muahahahah
2017-12-05 18:46:21 -06:00
Ken Johnson 058b4e08e7 Merge pull request #275 from jmmastey/remove-unused-test-suite
chore(tests): remove unused TestUnit suite, plus fixtures included in it
2017-10-11 11:40:36 -04:00
Joseph Mastey a6802aee5c chore(tests): remove unused TestUnit suite, plus fixtures included in it 2017-10-06 19:58:12 -05:00
Mike McCabe 39e8f75e2d fixing IDOR spec 2017-10-04 13:43:34 -04:00
cktricky f5cfec3bf4 Merge branch 'add-test-case-for-a1-field-injection' of https://github.com/jmmastey/railsgoat into jmmastey-add-test-case-for-a1-field-injection 2017-10-02 19:06:11 -04:00
Ken Johnson 87e8ebc8e5 Merge pull request #263 from jmmastey/fixing-password-vuln-makes-seeds-invalid
Fixing password vuln makes seeds invalid
2017-09-19 19:32:50 -04:00
cktricky 3322441ba4 whoops. Good catch @jmmastey 2017-09-19 11:38:03 -04:00
Joseph Mastey 9fc05eacde feat(vulnerabilities): adds description of vulnerability for sql interpolation
also fixes several small errors on that page, otherwise JS raises errors.

fixes #181
2017-09-18 19:50:23 -05:00
Joseph Mastey b934194ffe bug(passwords): fix situations where better password rules inadvertently break tests
* use bang version of save methods in the seeds file, so that when you fix validation,
  it will at least explode, rather than silently failing to create users
* fix two tests where passwords are hardcoded so that they use stronger passwords,
  since password complexity is not the important bit of either of those tests.
2017-09-18 12:58:26 -05:00
Joseph Mastey 563ada1e04 refer to Rails 5 wiki (to be created) 2017-01-29 19:04:48 -06:00
Joseph Mastey 8c38edd90b upgrade(rails-5): we updated the db/config, broke the test that extracts it 2017-01-19 15:53:24 -06:00
cktricky 79c1ddd45d Fixes #165 2016-06-09 22:33:53 -04:00
Al Snow 0cc4980c46 Upgraded rspec-rails from 2.99.0 to 3.4.0 2016-04-14 17:34:27 -04:00
Al Snow fb923baee4 Upgraded rspec 2.14.2 to 2.99.0 2016-03-19 18:33:01 -04:00
mccabe615 7e11dee133 trying to fix the broken specs. still doesn't pass but it may be due to changes in capybara 2015-11-22 14:55:54 -05:00
Al Snow b6d766329c Based on cane gem, removed tab indents and trailing blanks 2015-09-14 10:11:03 -04:00
cktricky a2c4f46c26 I have changed the second visit statement from the root path (/) to the account settings page. The reason is that the submit button is changed via JS but you need to be at the account settings page to see that change 2015-07-06 13:25:46 -04:00
Al Snow 890b77bdaf Upgraded 5 gems by rebuilding Gemfile.lock file 2015-03-28 10:46:52 -04:00
cktricky 48986b1bbb fixes xss spec failure 2015-03-27 15:04:31 -04:00
Al Snow 4bf596f95f Upgraded 1 gem by rebuilding Gemfile.lock file; Added sleep to try to fix fragile spec 2015-03-19 16:51:22 -04:00
Al Snow ca0526ccc9 Upgraded to Rails 4.0.13; Rebuilt Gemfile.lock file 2015-01-10 09:45:51 -05:00
chrismo 73e8ab972b assign_user_id and UserFixture password fixes.
When the database is empty, which can happen in the test database and in
the dev database if the seeds.rb aren't applied, the assign_user_id
method would not assign an id and the newer before_filter block to
generate_token would fail.

UserFixture had a password on it that wouldn't pass the new validation
rules once that vulnerability is patched.
2015-01-06 13:21:45 -05:00
Al Snow 0957033457 Upgraded to Ruby 2.1.3; Changed timeout value 2014-09-19 19:00:40 -04:00
Al Snow 74d047507a Changed timeout to 25000 for all envs 2014-09-19 11:12:32 -04:00