├── log └── .gitkeep ├── public ├── favicon.ico ├── docs │ ├── Dental_n_Stuff.pdf │ └── Health_n_Stuff.pdf ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── .ruby-version ├── lib ├── assets │ └── .gitkeep ├── tasks │ ├── traning.rake │ └── server.rake └── encryption.rb ├── .ruby-gemset ├── app ├── models │ ├── concerns │ │ └── .keep │ ├── retirement.rb │ ├── application_record.rb │ ├── key_management.rb │ ├── schedule.rb │ ├── performance.rb │ ├── message.rb │ ├── analytics.rb │ ├── paid_time_off.rb │ ├── pay.rb │ ├── benefits.rb │ ├── work_info.rb │ └── user.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── retirement_controller.rb │ ├── performance_controller.rb │ ├── paid_time_off_controller.rb │ ├── tutorials_controller.rb │ ├── work_info_controller.rb │ ├── dashboard_controller.rb │ ├── benefit_forms_controller.rb │ ├── api │ │ └── v1 │ │ │ ├── mobile_controller.rb │ │ │ └── users_controller.rb │ ├── sessions_controller.rb │ ├── messages_controller.rb │ ├── pay_controller.rb │ ├── users_controller.rb │ ├── schedule_controller.rb │ ├── application_controller.rb │ ├── admin_controller.rb │ └── password_resets_controller.rb ├── helpers │ ├── pay_helper.rb │ ├── admin_helper.rb │ ├── users_helper.rb │ ├── messages_helper.rb │ ├── schedule_helper.rb │ ├── sessions_helper.rb │ ├── dashboard_helper.rb │ ├── retirement_helper.rb │ ├── tutorials_helper.rb │ ├── work_info_helper.rb │ ├── api │ │ └── v1 │ │ │ └── users_helper.rb │ ├── application_helper.rb │ ├── benefit_forms_helper.rb │ ├── paid_time_off_helper.rb │ ├── performance_helper.rb │ └── password_resets_helper.rb ├── assets │ ├── images │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── logo.psd │ │ ├── loading.gif │ │ ├── profile.jpg │ │ ├── html-screen.jpg │ │ ├── loading-blue.gif │ │ ├── loading-red.gif │ │ ├── fonts │ │ │ ├── icomoon.eot │ │ │ ├── icomoon.ttf │ │ │ └── icomoon.woff │ │ ├── loading-black.gif │ │ ├── loading-green.gif │ │ ├── loading-orange.gif │ │ └── profile_color.jpg │ ├── stylesheets │ │ ├── password_resets.css.scss │ │ ├── charts-graphs.css │ │ ├── application.scss │ │ └── timepicker.css │ └── javascripts │ │ ├── password_resets.js.coffee │ │ ├── validation.js │ │ ├── load-image.min.js │ │ ├── html5.js │ │ ├── application.js │ │ ├── jquery.scrollUp.js │ │ ├── tiny-scrollbar.js │ │ └── bootstrap-image-gallery-main.js ├── mailers │ └── user_mailer.rb └── views │ ├── user_mailer │ ├── forgot_password.text.erb │ └── forgot_password.html.erb │ ├── layouts │ ├── shared │ │ ├── _messages.html.erb │ │ ├── _footer.html.erb │ │ ├── _header.html.erb │ │ └── _sidebar.html.erb │ └── application.html.erb │ ├── password_resets │ ├── forgot_password.html.erb │ └── reset_password.html.erb │ ├── dashboard │ ├── bar_graph.html.erb │ └── home.html.erb │ ├── users │ ├── new.html.erb │ └── account_settings.html.erb │ ├── admin │ ├── analytics.html.erb │ ├── dashboard.html.erb │ ├── get_all_users.html.erb │ └── get_user.html.erb │ ├── messages │ ├── show.html.erb │ └── index.html.erb │ ├── sessions │ └── new.html.erb │ ├── work_info │ └── index.html.erb │ ├── tutorials │ └── credentials.html.erb │ ├── retirement │ └── index.html.erb │ ├── performance │ └── index.html.erb │ └── benefit_forms │ └── index.html.erb ├── .rspec ├── vendor └── assets │ ├── javascripts │ └── .gitkeep │ └── stylesheets │ └── .gitkeep ├── Procfile ├── versions.tf ├── 1-Build-Docker-Image.sh ├── script ├── start └── rails ├── spec ├── models │ ├── message_spec.rb │ ├── key_management_spec.rb │ ├── pay_spec.rb │ ├── benefits_spec.rb │ └── user_spec.rb ├── mailers │ └── user_mailer_spec.rb ├── helpers │ ├── messages_helper_spec.rb │ ├── pay_helper_spec.rb │ ├── api │ │ └── v1 │ │ │ └── users_helper_spec.rb │ └── password_resets_helper_spec.rb ├── controllers │ ├── messages_controller_spec.rb │ ├── password_resets_controller_spec.rb │ ├── pay_controller_spec.rb │ └── api │ │ └── v1 │ │ └── users_controller_spec.rb ├── views │ └── password_resets │ │ └── new.html.erb_spec.rb ├── vulnerabilities │ ├── url_access_spec.rb │ ├── password_hashing_spec.rb │ ├── unvalidated_redirects_spec.rb │ ├── sensitive_data_exposure.rb │ ├── password_complexity_spec.rb │ ├── command_injection_spec.rb │ ├── insecure_dor_spec.rb │ ├── sql_injection_spec.rb │ ├── broken_auth_spec.rb │ ├── xss_spec.rb │ ├── mass_assignment_spec.rb │ └── csrf_spec.rb ├── support │ ├── user_fixture.rb │ └── capybara_shared.rb └── spec_helper.rb ├── config ├── initializers │ ├── html_entities.rb │ ├── strong_parameters.rb │ ├── constants.rb │ ├── assets.rb │ ├── key.rb │ ├── session_store.rb │ ├── filter_parameter_logging.rb │ ├── mime_types.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── secret_token.rb │ ├── inflections.rb │ └── populate_user_data.rb ├── environment.rb ├── boot.rb ├── locales │ └── en.yml ├── database.yml ├── environments │ ├── test.rb │ ├── mysql.rb │ ├── development.rb │ └── production.rb ├── routes.rb └── application.rb ├── parseyaml.py ├── entrypoint.sh ├── config.ru ├── .rubocop.yml ├── db ├── migrate │ ├── 20171007010129_remove_users_user_id.rb │ ├── 20140312002642_add_auth_token_to_users.rb │ ├── 20131112235256_add_encrypted_ssn_to_work_infos.rb │ ├── 20130708202859_create_benefits.rb │ ├── 20131113200708_create_key_managements.rb │ ├── 20140408185601_create_analytics.rb │ ├── 20131011180207_create_messages.rb │ ├── 20140315002730_create_pays.rb │ ├── 20130524222129_create_retirements.rb │ ├── 20130531182058_create_performances.rb │ ├── 20130424220355_create_users.rb │ ├── 20130531143853_create_work_infos.rb │ ├── 20130525001150_create_paid_time_offs.rb │ └── 20130527165832_create_schedules.rb └── schema.rb ├── doc └── README_FOR_APP ├── 2-Deploy-Docker-Image-To-Docker-Hub.sh ├── .gitignore ├── Rakefile ├── .powrc ├── outputs.tf ├── ISSUE_TEMPLATE.md ├── LICENSE.md ├── variables.tf ├── .overcommit.yml ├── Gemfile ├── main.tf ├── Guardfile ├── Dockerfile ├── CONTRIBUTING.md ├── README.md └── CODE_OF_CONDUCT.md /log/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.6.2 2 | -------------------------------------------------------------------------------- /lib/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-gemset: -------------------------------------------------------------------------------- 1 | railsgoat 2 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --backtrace -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: rvmsudo bundle exec unicorn -p 9000 2 | -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | 2 | terraform { 3 | required_version = ">= 0.12" 4 | } 5 | -------------------------------------------------------------------------------- /1-Build-Docker-Image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker build . -t railsgoat:1.0 --no-cache -------------------------------------------------------------------------------- /script/start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | rails db:setup 5 | rails server 6 | -------------------------------------------------------------------------------- /app/helpers/pay_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module PayHelper 3 | end 4 | -------------------------------------------------------------------------------- /spec/models/message_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | -------------------------------------------------------------------------------- /app/helpers/admin_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module AdminHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module UsersHelper 3 | end 4 | -------------------------------------------------------------------------------- /spec/mailers/user_mailer_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | -------------------------------------------------------------------------------- /app/helpers/messages_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module MessagesHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/schedule_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module ScheduleHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/sessions_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module SessionsHelper 3 | end 4 | -------------------------------------------------------------------------------- /spec/helpers/messages_helper_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | -------------------------------------------------------------------------------- /spec/models/key_management_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | -------------------------------------------------------------------------------- /app/helpers/dashboard_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module DashboardHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/retirement_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module RetirementHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/tutorials_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module TutorialsHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/work_info_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module WorkInfoHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/api/v1/users_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module Api::V1::UsersHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module ApplicationHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/benefit_forms_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module BenefitFormsHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/paid_time_off_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module PaidTimeOffHelper 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/performance_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module PerformanceHelper 3 | end 4 | -------------------------------------------------------------------------------- /spec/controllers/messages_controller_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | -------------------------------------------------------------------------------- /app/helpers/password_resets_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module PasswordResetsHelper 3 | end 4 | -------------------------------------------------------------------------------- /spec/controllers/password_resets_controller_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | -------------------------------------------------------------------------------- /app/assets/images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/1.jpg -------------------------------------------------------------------------------- /app/assets/images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/2.jpg -------------------------------------------------------------------------------- /app/assets/images/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/3.jpg -------------------------------------------------------------------------------- /app/assets/images/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/4.jpg -------------------------------------------------------------------------------- /app/assets/images/logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/logo.psd -------------------------------------------------------------------------------- /app/assets/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/loading.gif -------------------------------------------------------------------------------- /app/assets/images/profile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/profile.jpg -------------------------------------------------------------------------------- /app/models/retirement.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class Retirement < ApplicationRecord 3 | belongs_to :user 4 | end 5 | -------------------------------------------------------------------------------- /public/docs/Dental_n_Stuff.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/public/docs/Dental_n_Stuff.pdf -------------------------------------------------------------------------------- /public/docs/Health_n_Stuff.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/public/docs/Health_n_Stuff.pdf -------------------------------------------------------------------------------- /app/assets/images/html-screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/html-screen.jpg -------------------------------------------------------------------------------- /app/assets/images/loading-blue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/loading-blue.gif -------------------------------------------------------------------------------- /app/assets/images/loading-red.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/loading-red.gif -------------------------------------------------------------------------------- /config/initializers/html_entities.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | ActiveSupport::JSON::Encoding::escape_html_entities_in_json = false 3 | -------------------------------------------------------------------------------- /app/assets/images/fonts/icomoon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/fonts/icomoon.eot -------------------------------------------------------------------------------- /app/assets/images/fonts/icomoon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/fonts/icomoon.ttf -------------------------------------------------------------------------------- /app/assets/images/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/fonts/icomoon.woff -------------------------------------------------------------------------------- /app/assets/images/loading-black.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/loading-black.gif -------------------------------------------------------------------------------- /app/assets/images/loading-green.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/loading-green.gif -------------------------------------------------------------------------------- /app/assets/images/loading-orange.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/loading-orange.gif -------------------------------------------------------------------------------- /app/assets/images/profile_color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Contrast-Security-OSS/demo-railsgoat/master/app/assets/images/profile_color.jpg -------------------------------------------------------------------------------- /parseyaml.py: -------------------------------------------------------------------------------- 1 | import yaml, json 2 | with open('./contrast_security.yaml') as f: 3 | config = yaml.load(f) 4 | print(json.dumps(config['api'])) -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class ApplicationRecord < ActiveRecord::Base 3 | self.abstract_class = true 4 | end 5 | -------------------------------------------------------------------------------- /config/initializers/strong_parameters.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection) 3 | -------------------------------------------------------------------------------- /spec/controllers/pay_controller_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # require 'spec_helper' 3 | # 4 | # describe PayController do 5 | # 6 | # end 7 | -------------------------------------------------------------------------------- /app/models/key_management.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class KeyManagement < ApplicationRecord 3 | belongs_to :work_info 4 | belongs_to :user 5 | end 6 | -------------------------------------------------------------------------------- /config/initializers/constants.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | ACCESS_TOKEN_SALT = "S4828341189aefiasd#ASDF" 3 | 4 | RG_IV = "PPKLKAJDKGHALDJL482823458028" 5 | -------------------------------------------------------------------------------- /lib/tasks/traning.rake: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | desc "run training tests" 3 | task :training do 4 | Rake::Task["spec:vulnerabilities"].invoke 5 | end 6 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | rm -f tmp/pids/server.pid 2 | if [[ $TEST = true ]] 3 | then 4 | bundle exec rails training 5 | else 6 | bundle exec rails s -p 3000 -b '0.0.0.0' 7 | fi -------------------------------------------------------------------------------- /spec/controllers/api/v1/users_controller_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # require 'spec_helper' 3 | # 4 | # describe Api::V1::UsersController do 5 | # 6 | # end 7 | -------------------------------------------------------------------------------- /spec/models/pay_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # require 'spec_helper' 3 | # 4 | # describe Pay do 5 | # pending "add some examples to (or delete) #{__FILE__}" 6 | # end 7 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | Rails.application.config.assets.precompile += %w( validation.js jquery.dataTables.min.js fullcalendar.min.js moment.min.js ) 3 | -------------------------------------------------------------------------------- /app/controllers/retirement_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class RetirementController < ApplicationController 3 | 4 | def index 5 | @info = current_user.retirement 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/controllers/performance_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class PerformanceController < ApplicationController 3 | 4 | def index 5 | @perf = current_user.performance 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # This file is used by Rack-based servers to start the application. 3 | 4 | require ::File.expand_path("../config/environment", __FILE__) 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | inherit_gem: 2 | rubocop-github: 3 | - config/default.yml 4 | - config/rails.yml 5 | 6 | 7 | Rails/OutputSafety: 8 | Exclude: 9 | - 'app/controllers/password_resets_controller.rb' 10 | -------------------------------------------------------------------------------- /db/migrate/20171007010129_remove_users_user_id.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class RemoveUsersUserId < ActiveRecord::Migration[5.1] 3 | def change 4 | remove_column :users, :user_id, :integer 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/models/schedule.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class Schedule < ApplicationRecord 3 | belongs_to :paid_time_off 4 | 5 | validates_presence_of :date_begin, :date_end, :event_desc, :event_name, :event_type 6 | end 7 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Load the Rails application. 3 | require File.expand_path("../application", __FILE__) 4 | 5 | # Initialize the Rails application. 6 | Railsgoat::Application.initialize! 7 | -------------------------------------------------------------------------------- /config/initializers/key.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | if Rails.env.production? 3 | # Specify env variable/location/etc. to retrieve key from 4 | else 5 | KEY = "123456789101112123456789101112123456789101112" 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20140312002642_add_auth_token_to_users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class AddAuthTokenToUsers < ActiveRecord::Migration[4.2] 3 | def change 4 | add_column :users, :auth_token, :string 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Set up gems listed in the Gemfile. 3 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__) 4 | 5 | require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) 6 | -------------------------------------------------------------------------------- /doc/README_FOR_APP: -------------------------------------------------------------------------------- 1 | Use this README file to introduce your application and point to useful places in the API for learning more. 2 | Run "rails doc:app" to generate API documentation for your models, controllers, helpers, and libraries. 3 | -------------------------------------------------------------------------------- /spec/views/password_resets/new.html.erb_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # require 'spec_helper' 3 | # 4 | # describe "password_resets/new.html.erb" do 5 | # pending "add some examples to (or delete) #{__FILE__}" 6 | # end 7 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/password_resets.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the password_resets controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/controllers/paid_time_off_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class PaidTimeOffController < ApplicationController 3 | 4 | def index 5 | @pto = current_user.paid_time_off 6 | @schedule = Schedule.new 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | Railsgoat::Application.config.session_store :cookie_store, key: "_railsgoat_session", httponly: false 5 | -------------------------------------------------------------------------------- /db/migrate/20131112235256_add_encrypted_ssn_to_work_infos.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class AddEncryptedSsnToWorkInfos < ActiveRecord::Migration[4.2] 3 | def change 4 | add_column :work_infos, :encrypted_ssn, :binary 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/controllers/tutorials_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class TutorialsController < ApplicationController 3 | skip_before_action :has_info 4 | skip_before_action :authenticated 5 | 6 | layout false, only: [:credentials] 7 | end 8 | -------------------------------------------------------------------------------- /db/migrate/20130708202859_create_benefits.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateBenefits < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :benefits do |t| 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /app/assets/stylesheets/charts-graphs.css: -------------------------------------------------------------------------------- 1 | /* Easy Pie Chart CSS */ 2 | 3 | .easyPieChart { 4 | position: relative; 5 | text-align: center; 6 | } 7 | 8 | .easyPieChart canvas { 9 | position: absolute; 10 | top: 0; 11 | left: 0; 12 | } -------------------------------------------------------------------------------- /app/models/performance.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class Performance < ApplicationRecord 3 | belongs_to :user 4 | 5 | def reviewer_name 6 | u = User.find_by_id(self.reviewer) 7 | u.full_name if u.respond_to?("fullname") 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /2-Deploy-Docker-Image-To-Docker-Hub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Please log in using your Docker Hub credentials to update the container image" 4 | docker login 5 | docker tag railsgoat:1.0 contrastsecuritydemo/railsgoat:1.0 6 | docker push contrastsecuritydemo/railsgoat:1.0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle 2 | /bin 3 | /db/*.sqlite3 4 | /log/*.log 5 | /tmp 6 | .elasticbeanstalk/ 7 | .DS_Store 8 | /public/data 9 | /public/assets 10 | *.png 11 | coverage 12 | .tags 13 | /.vagrant 14 | /vendor/ruby 15 | run.sh 16 | test.sh 17 | contrast_security.yaml 18 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Add your own tasks in files placed in lib/tasks ending in .rake, 3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 4 | 5 | require_relative "config/application" 6 | 7 | Rails.application.load_tasks 8 | -------------------------------------------------------------------------------- /app/assets/javascripts/password_resets.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ 4 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Configure sensitive parameters which will be filtered from the log file. 5 | Rails.application.config.filter_parameters += [:password] 6 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Add new mime types for use in respond_to blocks: 5 | # Mime::Type.register "text/richtext", :rtf 6 | # Mime::Type.register_alias "text/html", :iphone 7 | -------------------------------------------------------------------------------- /.powrc: -------------------------------------------------------------------------------- 1 | if [ -f "${rvm_path}/scripts/rvm" ]; then 2 | source "${rvm_path}/scripts/rvm" 3 | 4 | if [ -f ".rvmrc" ]; then 5 | source ".rvmrc" 6 | elif [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then 7 | rvm use `cat .ruby-version`@`cat .ruby-gemset` 8 | fi 9 | fi 10 | -------------------------------------------------------------------------------- /db/migrate/20131113200708_create_key_managements.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateKeyManagements < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :key_managements do |t| 5 | t.string :iv 6 | t.integer :user_id 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20140408185601_create_analytics.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateAnalytics < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :analytics do |t| 5 | t.string :ip_address 6 | t.string :referrer 7 | t.string :user_agent 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 4 | 5 | APP_PATH = File.expand_path("../../config/application", __FILE__) 6 | require File.expand_path("../../config/boot", __FILE__) 7 | require "rails/commands" 8 | -------------------------------------------------------------------------------- /db/migrate/20131011180207_create_messages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateMessages < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :messages do |t| 5 | t.integer :creator_id 6 | t.integer :receiver_id 7 | t.text :message 8 | t.boolean :read 9 | 10 | t.timestamps 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/models/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class Message < ApplicationRecord 3 | belongs_to :user 4 | validates_presence_of :creator_id, :receiver_id, :message 5 | 6 | def creator_name 7 | if creator = User.where(id: self.creator_id).first 8 | creator.full_name 9 | else 10 | "Name unavailable" 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/controllers/work_info_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class WorkInfoController < ApplicationController 3 | def index 4 | @user = User.find_by(id: params[:user_id]) 5 | if !(@user) || @user.admin 6 | flash[:error] = "Sorry, no user with that user id exists" 7 | redirect_to home_dashboard_index_path 8 | end 9 | end 10 | 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20140315002730_create_pays.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreatePays < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :pays do |t| 5 | t.integer :user_id 6 | t.string :bank_account_num 7 | t.string :bank_routing_num 8 | t.integer :percent_of_deposit 9 | 10 | t.timestamps 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /db/migrate/20130524222129_create_retirements.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateRetirements < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :retirements do |t| 5 | t.string :total 6 | t.string :employee_contrib 7 | t.string :employer_contrib 8 | t.integer :user_id 9 | 10 | t.timestamps 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /db/migrate/20130531182058_create_performances.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreatePerformances < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :performances do |t| 5 | t.integer :user_id 6 | t.date :date_submitted 7 | t.integer :score 8 | t.string :comments 9 | t.integer :reviewer 10 | 11 | t.timestamps 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /db/migrate/20130424220355_create_users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateUsers < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :users do |t| 5 | t.string :email 6 | t.string :password 7 | t.boolean :admin 8 | t.string :first_name 9 | t.string :last_name 10 | t.integer :user_id 11 | 12 | t.timestamps 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /db/migrate/20130531143853_create_work_infos.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateWorkInfos < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :work_infos do |t| 5 | t.integer :user_id 6 | t.string :income 7 | t.string :bonuses 8 | t.integer :years_worked 9 | t.string :SSN 10 | t.date :DoB 11 | 12 | t.timestamps 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/mailers/user_mailer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class UserMailer < ActionMailer::Base 3 | default from: "noreply@railsgoat.dev" 4 | 5 | def forgot_password(email, token) 6 | @token = token 7 | @url = url_for(controller: "password_resets", action: "reset_password", only_path: false) + "?token=#{token}" 8 | 9 | mail(to: "#{email}", subject: "Reset your MetaCorp password") 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20130525001150_create_paid_time_offs.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreatePaidTimeOffs < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :paid_time_offs do |t| 5 | t.integer :user_id 6 | t.integer :sick_days_taken 7 | t.integer :sick_days_earned 8 | t.integer :pto_taken 9 | t.integer :pto_earned 10 | 11 | t.timestamps 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /db/migrate/20130527165832_create_schedules.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class CreateSchedules < ActiveRecord::Migration[4.2] 3 | def change 4 | create_table :schedules do |t| 5 | t.string :event_type 6 | t.date :date_begin 7 | t.date :date_end 8 | t.string :event_name 9 | t.string :event_desc 10 | t.integer :user_id 11 | 12 | t.timestamps 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | #### Azure Output Variables #### 2 | 3 | output "ip_address" { 4 | value = "${azurerm_container_group.app.ip_address}:3000" 5 | } 6 | 7 | #the dns fqdn of the container group if dns_name_label is set 8 | output "fqdn" { 9 | value = "http://${azurerm_container_group.app.fqdn}:3000" 10 | } 11 | 12 | output "contrast" { 13 | value = "This app should appear in the environment ${data.external.yaml.result.url}" 14 | } -------------------------------------------------------------------------------- /app/views/user_mailer/forgot_password.text.erb: -------------------------------------------------------------------------------- 1 | Need help logging in? 2 | ========================================================== 3 | 4 | A password reset was requested for your user account. 5 | 6 | To reset your MetaCorp password, simply copy the 7 | following link and follow the instructions: 8 | 9 | <%= @url %> 10 | 11 | If you don't want to change your password, you can ignore this email. 12 | 13 | Thanks, and have a great day! -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 5 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 6 | 7 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 8 | # Rails.backtrace_cleaner.remove_silencers! 9 | -------------------------------------------------------------------------------- /app/models/analytics.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class Analytics < ApplicationRecord 3 | scope :hits_by_ip, ->(ip, col = "*") { select("#{col}").where(ip_address: ip).order("id DESC") } 4 | 5 | def self.count_by_col(col) 6 | calculate(:count, col) 7 | end 8 | 9 | def self.parse_field(field) 10 | valid_fields = ["ip_address", "referrer", "user_agent"] 11 | 12 | if valid_fields.include?(field) 13 | field 14 | else 15 | "1" 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/helpers/pay_helper_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # require 'spec_helper' 3 | # 4 | # Specs in this file have access to a helper object that includes 5 | # the PayHelper. For example: 6 | # 7 | # describe PayHelper do 8 | # describe "string concat" do 9 | # it "concats two strings with spaces" do 10 | # expect(helper.concat_strings("this","that")).to eq("this that") 11 | # end 12 | # end 13 | # end 14 | # describe PayHelper do 15 | # pending "add some examples to (or delete) #{__FILE__}" 16 | # end 17 | -------------------------------------------------------------------------------- /app/models/paid_time_off.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class PaidTimeOff < ApplicationRecord 3 | belongs_to :user 4 | has_many :schedule, foreign_key: :user_id, primary_key: :user_id, dependent: :destroy 5 | 6 | def sick_days_remaining 7 | self.sick_days_earned - self.sick_days_taken 8 | end 9 | 10 | def pto_days_remaining 11 | self.pto_earned - self.pto_taken 12 | end 13 | 14 | def sick_days_taken_percentage 15 | result = self.sick_days_taken.to_f / self.sick_days_earned.to_f * 100.0 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/helpers/api/v1/users_helper_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # require 'spec_helper' 3 | # 4 | # Specs in this file have access to a helper object that includes 5 | # the Api::V1::UsersHelper. For example: 6 | # 7 | # describe Api::V1::UsersHelper do 8 | # describe "string concat" do 9 | # it "concats two strings with spaces" do 10 | # expect(helper.concat_strings("this","that")).to eq("this that") 11 | # end 12 | # end 13 | # end 14 | # describe Api::V1::UsersHelper do 15 | # pending "add some examples to (or delete) #{__FILE__}" 16 | # end 17 | -------------------------------------------------------------------------------- /spec/helpers/password_resets_helper_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # require 'spec_helper' 3 | # 4 | # Specs in this file have access to a helper object that includes 5 | # the PasswordResetsHelper. For example: 6 | # 7 | # describe PasswordResetsHelper do 8 | # describe "string concat" do 9 | # it "concats two strings with spaces" do 10 | # expect(helper.concat_strings("this","that")).to eq("this that") 11 | # end 12 | # end 13 | # end 14 | # describe PasswordResetsHelper do 15 | # pending "add some examples to (or delete) #{__FILE__}" 16 | # end 17 | -------------------------------------------------------------------------------- /spec/vulnerabilities/url_access_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | 4 | feature "url access" do 5 | let(:normal_user) { UserFixture.normal_user } 6 | 7 | before do 8 | UserFixture.reset_all_users 9 | 10 | pending unless verifying_fixed? 11 | end 12 | 13 | scenario "attack\nTutorial: https://github.com/OWASP/railsgoat/wiki/A7-Missing-Function-Level-Access-Control--(Admin-Controller)", js: true do 14 | login(normal_user) 15 | 16 | visit "/admin/1/dashboard" 17 | 18 | expect(current_path).to eq("/") 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | # 4 | # This file contains settings for ActionController::ParamsWrapper which 5 | # is enabled by default. 6 | 7 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 8 | ActiveSupport.on_load(:action_controller) do 9 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 10 | end 11 | 12 | # Disable root element in JSON by default. 13 | ActiveSupport.on_load(:active_record) do 14 | self.include_root_in_json = false 15 | end 16 | -------------------------------------------------------------------------------- /spec/support/user_fixture.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class UserFixture 3 | def self.reset_all_users 4 | User.delete_all 5 | Rails.application.load_seed 6 | end 7 | 8 | def self.normal_user 9 | password = "thi$ 1s cOmplExEr" 10 | User.create!(first_name: "Joe", last_name: "Schmoe", email: "joe@schmoe.com", 11 | password: password, password_confirmation: password).tap do |user| 12 | def user.clear_password 13 | "thi$ 1s cOmplExEr" 14 | end 15 | end 16 | end 17 | 18 | def self.admin_user 19 | User.where(admin: true).first 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/models/pay.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class Pay < ApplicationRecord 3 | # Associations 4 | belongs_to :user 5 | 6 | # Validations 7 | validates :bank_account_num, presence: true 8 | validates :bank_routing_num, presence: true 9 | validates :percent_of_deposit, presence: true 10 | 11 | # callbacks 12 | before_save :encrypt_bank_account_num 13 | 14 | def as_json 15 | super(only: [:bank_account_num, :bank_routing_num, :percent_of_deposit, :id]) 16 | end 17 | 18 | def encrypt_bank_account_num 19 | self.bank_account_num = Encryption.encrypt_sensitive_value(self.bank_account_num) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/tasks/server.rake: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | namespace :server do 3 | 4 | desc "Start Rails" 5 | task :start do 6 | pid_file = "tmp/pids/server.pid" 7 | if !(File.exist?(pid_file)) 8 | sh("rails s -d") 9 | else 10 | puts "[+] Server is already running" 11 | end 12 | end 13 | 14 | desc "Stop Rails" 15 | task :stop do 16 | pid_file = "tmp/pids/server.pid" 17 | if File.exist?(pid_file) 18 | Process.kill("INT", File.read(pid_file).to_i) 19 | else 20 | puts "[-] Server isn't running" 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /app/controllers/dashboard_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class DashboardController < ApplicationController 3 | skip_before_action :has_info 4 | layout false, only: [:change_graph] 5 | 6 | def home 7 | @user = current_user 8 | 9 | # See if the user has a font preference 10 | if params[:font] 11 | cookies[:font] = params[:font] 12 | end 13 | end 14 | 15 | def change_graph 16 | self.try(params[:graph]) 17 | 18 | if params[:graph] == "bar_graph" 19 | render "dashboard/bar_graph" 20 | else 21 | @user = current_user 22 | render "dashboard/pie_charts" 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/models/benefits_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper.rb" 3 | 4 | describe Benefits do 5 | before(:all) do 6 | UserFixture.reset_all_users 7 | DatabaseCleaner.strategy = :transaction 8 | end 9 | 10 | after(:all) do 11 | DatabaseCleaner.strategy = :truncation 12 | end 13 | 14 | it "can be instantiated" do 15 | expect(Benefits.new).to be_an_instance_of(Benefits) 16 | end 17 | 18 | it "name can be updated" do 19 | new_name = "Bobby" 20 | user = User.all.first 21 | user.first_name = new_name 22 | user.save! 23 | expect(User.all.first.first_name).to eq(new_name) 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/vulnerabilities/password_hashing_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require "spec_helper" 3 | 4 | feature "improper password hashing" do 5 | let(:normal_user) { UserFixture.normal_user } 6 | 7 | before do 8 | UserFixture.reset_all_users 9 | pending unless verifying_fixed? 10 | end 11 | 12 | scenario "with just md5\nTutorial: https://github.com/OWASP/railsgoat/wiki/A6-Sensitive-Data-Exposure-Insecure-Password-Storage" do 13 | new_pass = "testPassw0rd!" 14 | normal_user.password = new_pass 15 | normal_user.password_confirmation = new_pass 16 | normal_user.save! 17 | 18 | expect(normal_user.password).not_to eq(Digest::MD5.hexdigest(new_pass)) 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /app/views/user_mailer/forgot_password.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |
9 | A password reset was requested for your user account.
10 |
11 |
12 | To reset your MetaCorp password, simply click on the
13 | following link and follow the instructions:
14 |
15 |
16 | <%= link_to "Click here to reset your password", @url %>
17 |
18 |
19 | If you don't want to change your password, you can ignore this email.
20 |
Thanks, and have a great day!
22 | 23 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | *= require jquery.fileupload-ui 14 | */ 15 | 16 | p.desc { 17 | max-width: 850px; 18 | word-wrap: break-word; 19 | } -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Your secret key for verifying the integrity of signed cookies. 5 | # If you change this key, all old signed cookies will become invalid! 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | Railsgoat::Application.config.secret_token = "2f1d90a26236c3245d96f5606c201a780dc9ca687e5ed82b45e211bb5dc84c1870f61ca9e002dad5dd8a149c9792d8f07f31a9575065cca064bd6af44f8750e4" 9 | Railsgoat::Application.config.secret_key_base = "2f1d90a26236c3245d96f5606c201a780dc9ca687e5ed82b45e211bb5dc84c1870f61ca9e002dad5dd8a149c9792d8f07f31a9575065cca064bd6af44f8750e4" 10 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Add new inflection rules using the following format. Inflections 5 | # are locale specific, and you may define rules for as many different 6 | # locales as you wish. All of these examples are active by default: 7 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 8 | # inflect.plural /^(ox)$/i, '\1en' 9 | # inflect.singular /^(ox)en/i, '\1' 10 | # inflect.irregular 'person', 'people' 11 | # inflect.uncountable %w( fish sheep ) 12 | # end 13 | 14 | # These inflection rules are supported but not enabled by default: 15 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 16 | # inflect.acronym 'RESTful' 17 | # end 18 | -------------------------------------------------------------------------------- /app/views/layouts/shared/_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% flash.each do |name, msg| %> 2 | <% name = name.to_sym %> 3 | <% if name == :error %> 4 |Fill out the form below to reset your password.
14 |If you are the application owner check the logs for more information.
56 | 57 | 58 | -------------------------------------------------------------------------------- /app/views/password_resets/reset_password.html.erb: -------------------------------------------------------------------------------- 1 |Fill out the form below to create a new password.
18 |Maybe you tried to change something you didn't have access to.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /app/controllers/api/v1/users_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | class Api::V1::UsersController < ApplicationController 3 | skip_before_action :authenticated 4 | before_action :valid_api_token 5 | before_action :extrapolate_user 6 | 7 | respond_to :json 8 | 9 | def index 10 | respond_with @user.admin ? User.all : @user 11 | end 12 | 13 | def show 14 | respond_with @user.as_json 15 | end 16 | 17 | private 18 | 19 | def valid_api_token 20 | authenticate_or_request_with_http_token do |token, options| 21 | # TODO :add some functionality to check if the HTTP Header is valid 22 | if !identify_user(token) 23 | redirect_to root_url 24 | end 25 | end 26 | end 27 | 28 | def identify_user(token = "") 29 | # We've had issues with URL encoding, etc. causing issues so just to be safe 30 | # we will go ahead and unescape the user's token 31 | unescape_token(token) 32 | @clean_token =~ /(.*?)-(.*)/ 33 | id = $1 34 | hash = $2 35 | 36 | check_hash(id, hash) 37 | end 38 | 39 | def check_hash(id, hash) 40 | digest = OpenSSL::Digest::SHA1.hexdigest("#{ACCESS_TOKEN_SALT}:#{id}") 41 | hash == digest 42 | end 43 | 44 | # We had some issues with the token and url encoding... 45 | # this is an attempt to normalize the data. 46 | def unescape_token(token = "") 47 | @clean_token = CGI::unescape(token) 48 | end 49 | 50 | # Added a method to make it easy to figure out who the user is. 51 | def extrapolate_user 52 | @user = User.find_by_id(@clean_token.split("-").first) 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /app/views/dashboard/bar_graph.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/views/users/new.html.erb: -------------------------------------------------------------------------------- 1 |Fill out the form below to login
11 |You may have mistyped the address or the page may have moved.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /app/views/admin/analytics.html.erb: -------------------------------------------------------------------------------- 1 | 7 | 8 || 16 | <% end %> 17 | |
|---|
| <%= v %> | 24 | <% end %> 25 |
| 6 | Name 7 | | 8 |9 | Email 10 | | 11 |12 | Admin User 13 | | 14 |15 | Action 16 | | 17 |
|---|---|---|---|
| 23 | <%= "#{u.first_name} #{u.last_name}"%> 24 | | 25 |26 | <%= u.email%> 27 | | 28 |29 | <%= u.admin ? %{ | 31 |32 | <%= link_to "Edit", "#", {:onClick => "javascript:openEditModal(#{u.id});", :role => "button", :style => "width:70px", :class => "btn btn-inverse", "data-toggle" => "modal"}%> 33 | | 34 |
Fill out the form below to login to your control panel.
30 | elements with the class "js"
39 | // and snippet highlights the JAVASCRIPT code within
40 | // using a random style from the selection of 39
41 | // with a transparent background
42 | // without showing line numbers.
43 |
44 |
45 |
46 | $("pre.javascript").snippet("javascript",{style:"rand01",transparent:true,showNum:true});
47 | // Finds elements with the class "js"
48 | // and snippet highlights the JAVASCRIPT code within
49 | // using a random style from the selection of 39
50 | // with a transparent background
51 | // without showing line numbers.
52 |
53 | };
54 |
55 | function coerceToString(val) {
56 | return String((val === null || val === undefined) ? '' : val);
57 | }
58 |
59 | var rAmp = /&/g,
60 | rLt = /Warning, this is a spoiler
15 |Are you sure you want to see the credentials?
16 | 91 |