diff --git a/.powrc b/.powrc
index 52c4a57..b8d32ef 100644
--- a/.powrc
+++ b/.powrc
@@ -1,4 +1,9 @@
-if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
- source "$rvm_path/scripts/rvm"
- source ".rvmrc"
-fi
+if [ -f "${rvm_path}/scripts/rvm" ]; then
+ source "${rvm_path}/scripts/rvm"
+
+ if [ -f ".rvmrc" ]; then
+ source ".rvmrc"
+ elif [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then
+ rvm use `cat .ruby-version`@`cat .ruby-gemset`
+ fi
+fi
\ No newline at end of file
diff --git a/.ruby-gemset b/.ruby-gemset
new file mode 100644
index 0000000..b7f2343
--- /dev/null
+++ b/.ruby-gemset
@@ -0,0 +1 @@
+railsgoat
\ No newline at end of file
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 0000000..8f9174b
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+2.1.2
\ No newline at end of file
diff --git a/.rvmrc b/.rvmrc
deleted file mode 100755
index 97ca0d8..0000000
--- a/.rvmrc
+++ /dev/null
@@ -1 +0,0 @@
-rvm use 2.1.2@railsgoat --create
diff --git a/LICENSE.md b/LICENSE.md
index 122db6d..b47c765 100755
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2013 The Open Web Application Security Project
+Copyright (c) 2013-2014 The Open Web Application Security Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index d9ac783..1c469ad 100755
--- a/README.md
+++ b/README.md
@@ -4,13 +4,10 @@ RailsGoat is a vulnerable version of the Ruby on Rails Framework. It includes vu
## Getting Started
-
-
To begin, install the Ruby Version Manager (RVM):
```
-$ curl -L https://get.rvm.io | bash -s stable --autolibs=3 --ruby=1.9.3
-$ rvm use 2.1.2@railsgoat --create # https://rvm.io/
+$ curl -L https://get.rvm.io | bash -s stable --autolibs=3 --ruby=2.1.2
```
After installing the package, clone this repo:
@@ -19,22 +16,7 @@ After installing the package, clone this repo:
$ git clone git@github.com:OWASP/railsgoat.git
```
-Navigate into the directory and accept the notice by typing `yes`:
-```
-****************************************************************************************************
-* NOTICE *
-****************************************************************************************************
-* RVM has encountered a new or modified .rvmrc file in the current directory, this is a shell *
-* script and therefore may contain any shell commands. *
-* *
-* Examine the contents of this file carefully to be sure the contents are safe before trusting it! *
-* Do you wish to trust '/path/to/railsgoat/.rvmrc'? *
-* Choose v[view] below to view the contents *
-****************************************************************************************************
-y[es], n[o], v[iew], c[cancel]>
-```
-
-Install the project dependencies:
+Navigate into the directory and install the dependencies:
```
$ bundle install
@@ -52,7 +34,7 @@ Initialize the database:
$ rake db:setup
```
-Start the WEBrick HTTP Server:
+Start the Thin web server:
```
$ rails server
@@ -101,7 +83,7 @@ Conversion to the OWASP Top Ten 2013 completed in November, 2013.
The MIT License (MIT)
-Copyright (c) 2013 The Open Web Application Security Project
+Copyright (c) 2013-2014 The Open Web Application Security Project
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 4cde79f..f82afc5 100755
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -1,8 +1,7 @@
class AdminController < ApplicationController
-
before_filter :administrative, :if => :admin_param
skip_before_filter :has_info
-
+
def dashboard
end
@@ -27,14 +26,14 @@ class AdminController < ApplicationController
@users = User.all
render :partial => "layouts/admin/get_all_users"
end
-
+
def get_user
@user = User.find_by_id(params[:admin_id].to_s)
arr = ["true", "false"]
@admin_select = @user.admin ? arr : arr.reverse
render :partial => "layouts/admin/get_user"
end
-
+
def update_user
user = User.find_by_id(params[:admin_id])
if user
@@ -48,7 +47,7 @@ class AdminController < ApplicationController
format.json { render :json => { :msg => message ? "success" : "failure"} }
end
end
-
+
def delete_user
user = User.find_by_user_id(params[:admin_id])
if user && !(current_user.user_id == user.user_id)
@@ -67,5 +66,4 @@ class AdminController < ApplicationController
def admin_param
params[:admin_id] != '1'
end
-
end
diff --git a/app/controllers/api/v1/mobile_controller.rb b/app/controllers/api/v1/mobile_controller.rb
index 63a575d..f4c01e3 100644
--- a/app/controllers/api/v1/mobile_controller.rb
+++ b/app/controllers/api/v1/mobile_controller.rb
@@ -1,5 +1,4 @@
class Api::V1::MobileController < ApplicationController
-
skip_before_filter :authenticated
before_filter :mobile_request?
@@ -30,5 +29,4 @@ class Api::V1::MobileController < ApplicationController
request.user_agent =~ /ios|android/i
end
end
-
end
diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb
index 6866774..643e5f9 100644
--- a/app/controllers/api/v1/users_controller.rb
+++ b/app/controllers/api/v1/users_controller.rb
@@ -1,57 +1,54 @@
class Api::V1::UsersController < ApplicationController
-
- skip_before_filter :authenticated
- before_filter :valid_api_token
- before_filter :extrapolate_user
-
- respond_to :json
-
- def index
- # We removed the .as_json code from the model, just seemed like extra work.
- # dunno, maybe useful at a later time?
- #respond_with @user.admin ? User.all.as_json : @user.as_json
-
- respond_with @user.admin ? User.all : @user
- end
-
- def show
- respond_with @user.as_json
- end
-
-private
+ skip_before_filter :authenticated
+ before_filter :valid_api_token
+ before_filter :extrapolate_user
- def valid_api_token
- authenticate_or_request_with_http_token do |token, options|
- # TODO :add some functionality to check if the HTTP Header is valid
- identify_user(token)
- end
- end
-
- def identify_user(token="")
- # We've had issues with URL encoding, etc. causing issues so just to be safe
- # we will go ahead and unescape the user's token
- unescape_token(token)
- @clean_token =~ /(.*?)-(.*)/
- id = $1
- hash = $2
- (id && hash) ? true : false
- check_hash(id, hash) ? true : false
- end
-
- def check_hash(id, hash)
- digest = OpenSSL::Digest::SHA1.hexdigest("#{ACCESS_TOKEN_SALT}:#{id}")
- hash == digest
- end
-
- # We had some issues with the token and url encoding...
- # this is an attempt to normalize the data.
- def unescape_token(token="")
- @clean_token = CGI::unescape(token)
- end
-
- # Added a method to make it easy to figure out who the user is.
- def extrapolate_user
- @user = User.find_by_id(@clean_token.split("-").first)
- end
-
+ respond_to :json
+
+ def index
+ # We removed the .as_json code from the model, just seemed like extra work.
+ # dunno, maybe useful at a later time?
+ #respond_with @user.admin ? User.all.as_json : @user.as_json
+ respond_with @user.admin ? User.all : @user
+ end
+
+ def show
+ respond_with @user.as_json
+ end
+
+ private
+
+ def valid_api_token
+ authenticate_or_request_with_http_token do |token, options|
+ # TODO :add some functionality to check if the HTTP Header is valid
+ identify_user(token)
+ end
+ end
+
+ def identify_user(token="")
+ # We've had issues with URL encoding, etc. causing issues so just to be safe
+ # we will go ahead and unescape the user's token
+ unescape_token(token)
+ @clean_token =~ /(.*?)-(.*)/
+ id = $1
+ hash = $2
+ (id && hash) ? true : false
+ check_hash(id, hash) ? true : false
+ end
+
+ def check_hash(id, hash)
+ digest = OpenSSL::Digest::SHA1.hexdigest("#{ACCESS_TOKEN_SALT}:#{id}")
+ hash == digest
+ end
+
+ # We had some issues with the token and url encoding...
+ # this is an attempt to normalize the data.
+ def unescape_token(token="")
+ @clean_token = CGI::unescape(token)
+ end
+
+ # Added a method to make it easy to figure out who the user is.
+ def extrapolate_user
+ @user = User.find_by_id(@clean_token.split("-").first)
+ end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 3e56186..dcf7d08 100755
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,5 +1,4 @@
class ApplicationController < ActionController::Base
-
before_filter :authenticated, :has_info, :create_analytic
helper_method :current_user, :is_admin?, :sanitize_font
@@ -10,7 +9,7 @@ class ApplicationController < ActionController::Base
def current_user
@current_user ||= (
- User.find_by_auth_token(cookies[:auth_token].to_s) ||
+ User.find_by_auth_token(cookies[:auth_token].to_s) ||
User.find_by_user_id(session[:user_id].to_s)
)
end
@@ -53,5 +52,4 @@ class ApplicationController < ActionController::Base
css
# css if css.match(/\A[0-9]+([\%]|pt)\z/)
end
-
end
diff --git a/app/controllers/benefit_forms_controller.rb b/app/controllers/benefit_forms_controller.rb
index 64b851e..23546ba 100644
--- a/app/controllers/benefit_forms_controller.rb
+++ b/app/controllers/benefit_forms_controller.rb
@@ -1,12 +1,11 @@
class BenefitFormsController < ApplicationController
-
+
def index
@benefits = Benefits.new
end
-
def download
- begin
+ begin
path = params[:name]
file = params[:type].constantize.new(path)
send_file file, :disposition => 'attachment'
@@ -14,7 +13,7 @@ class BenefitFormsController < ApplicationController
redirect_to user_benefit_forms_path(:user_id => current_user.user_id)
end
end
-
+
def upload
file = params[:benefits][:upload]
if file
@@ -22,23 +21,22 @@ class BenefitFormsController < ApplicationController
Benefits.save(file, params[:benefits][:backup])
else
flash[:error] = "Something went wrong"
- end
+ end
redirect_to user_benefit_forms_path(:user_id => current_user.user_id)
end
-
-=begin
+=begin
# More secure version
def download
file_assoc = {"1" => "Health_n_Stuff.pdf", "2" => "Dental_n_Stuff.pdf"}
- begin
+ begin
if file_assoc.has_key?(params[:name].to_s)
path = Rails.root.join('public', 'docs', file_assoc[params[:name].to_s])
if params[:type] == "File"
- file = params[:type].constantize.new(path)
+ file = params[:type].constantize.new(path)
send_file file, :disposition => 'attachment'
- end
- else
+ end
+ else
file = Rails.root.join('public', 'docs', "Dental_n_Stuff.pdf")
send_file file, :disposition => 'attachment'
end
@@ -46,7 +44,5 @@ class BenefitFormsController < ApplicationController
redirect_to user_benefit_forms_path(:user_id => current_user.user_id)
end
end
-=end
-
-
+=end
end
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 41d4236..4bb1c20 100755
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -1,7 +1,6 @@
class DashboardController < ApplicationController
-
skip_before_filter :has_info
-
+
def home
@user = current_user
@@ -10,5 +9,4 @@ class DashboardController < ApplicationController
cookies[:font] = params[:font]
end
end
-
end
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 706f103..83b992c 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -33,5 +33,4 @@ class MessagesController < ApplicationController
end
end
end
-
end
\ No newline at end of file
diff --git a/app/controllers/paid_time_off_controller.rb b/app/controllers/paid_time_off_controller.rb
index ea64301..fb63087 100644
--- a/app/controllers/paid_time_off_controller.rb
+++ b/app/controllers/paid_time_off_controller.rb
@@ -1,5 +1,5 @@
class PaidTimeOffController < ApplicationController
-
+
def index
@pto = current_user.paid_time_off
@schedule = Schedule.new
diff --git a/app/controllers/password_resets_controller.rb b/app/controllers/password_resets_controller.rb
index 533643a..98ebdab 100644
--- a/app/controllers/password_resets_controller.rb
+++ b/app/controllers/password_resets_controller.rb
@@ -1,7 +1,6 @@
class PasswordResetsController < ApplicationController
skip_before_filter :authenticated
-
def reset_password
user = Marshal.load(Base64.decode64(params[:user])) unless params[:user].nil?
diff --git a/app/controllers/pay_controller.rb b/app/controllers/pay_controller.rb
index 6a71dc3..6245c62 100644
--- a/app/controllers/pay_controller.rb
+++ b/app/controllers/pay_controller.rb
@@ -1,28 +1,28 @@
class PayController < ApplicationController
-
+
def index
end
-
+
def update_dd_info
msg = false
pay = Pay.new(
- :bank_account_num => params[:bank_account_num],
- :bank_routing_num => params[:bank_routing_num],
+ :bank_account_num => params[:bank_account_num],
+ :bank_routing_num => params[:bank_routing_num],
:percent_of_deposit => params[:dd_percent]
)
pay.user_id = current_user.user_id
- msg = true if pay.save!
+ msg = true if pay.save!
respond_to do |format|
format.json {render :json => {:msg => msg } }
end
end
-
+
def show
respond_to do |format|
format.json { render :json => {:user => current_user.pay.as_json} }
end
end
-
+
def destroy
pay = Pay.find_by_id(params[:id])
if pay.present? and pay.destroy
@@ -32,12 +32,11 @@ class PayController < ApplicationController
end
redirect_to user_pay_index_path
end
-
+
def decrypted_bank_acct_num
decrypted = Encryption.decrypt_sensitive_value(params[:value_to_decrypt])
respond_to do |format|
format.json {render :json => {:account_num => decrypted || "No Data" }}
end
end
-
end
diff --git a/app/controllers/performance_controller.rb b/app/controllers/performance_controller.rb
index bdbff15..1ba6aa8 100644
--- a/app/controllers/performance_controller.rb
+++ b/app/controllers/performance_controller.rb
@@ -1,7 +1,6 @@
class PerformanceController < ApplicationController
-
+
def index
@perf = current_user.performance
end
-
end
diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb
index 1a376ee..541b083 100644
--- a/app/controllers/retirement_controller.rb
+++ b/app/controllers/retirement_controller.rb
@@ -1,7 +1,6 @@
class RetirementController < ApplicationController
-
+
def index
@info = current_user.retirement
end
-
end
diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb
index 82d4736..65caa2e 100644
--- a/app/controllers/schedule_controller.rb
+++ b/app/controllers/schedule_controller.rb
@@ -1,7 +1,8 @@
class ScheduleController < ApplicationController
+
def create
message = false
-
+
if params[:schedule][:event_type] == "pto"
sched = Schedule.new(params[:schedule])
sched.date_begin, sched.date_end = format_schedule_date(params[:date_range1])
@@ -11,12 +12,12 @@ class ScheduleController < ApplicationController
message = true
end
end
-
+
respond_to do |format|
format.json {render :json => {:msg => message ? "success" : "failure" }}
end
end
-
+
def get_pto_schedule
begin
schedules = current_user.paid_time_off.schedule
@@ -29,17 +30,17 @@ class ScheduleController < ApplicationController
hash[:end] = s[:date_end]
jfs << hash
end
- rescue
+ rescue
end
respond_to do |format|
format.json do
render :json => jfs.to_json
- end
+ end
end
end
-
+
private
-
+
# Returns a two part array consisting of dates
# First value is the begin date and the second is the end date
def format_schedule_date(date_array)
@@ -50,10 +51,9 @@ class ScheduleController < ApplicationController
date = Date.strptime(s.strip, '%m/%d/%Y')
vals <<(date)
end
- rescue ArgumentError
+ rescue ArgumentError
return []
end
return vals
end
-
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index a13bbc7..fdf2edc 100755
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,41 +1,39 @@
class SessionsController < ApplicationController
-
skip_before_filter :has_info
skip_before_filter :authenticated, :only => [:new, :create]
-
+
def new
- @url = params[:url]
- redirect_to home_dashboard_index_path if current_user
+ @url = params[:url]
+ redirect_to home_dashboard_index_path if current_user
end
-
+
def create
- path = params[:url].present? ? params[:url] : home_dashboard_index_path
- begin
- # Normalize the email address, why not
- user = User.authenticate(params[:email].to_s.downcase, params[:password])
- # @url = params[:url]
+ path = params[:url].present? ? params[:url] : home_dashboard_index_path
+ begin
+ # Normalize the email address, why not
+ user = User.authenticate(params[:email].to_s.downcase, params[:password])
+ # @url = params[:url]
rescue Exception => e
- end
-
- if user
- if params[:remember_me]
- cookies.permanent[:auth_token] = user.auth_token if User.where(:user_id => user.user_id).exists?
- else
- session[:user_id] = user.user_id if User.where(:user_id => user.user_id).exists?
- end
- redirect_to path
+ end
+
+ if user
+ if params[:remember_me]
+ cookies.permanent[:auth_token] = user.auth_token if User.where(:user_id => user.user_id).exists?
else
- # Removed this code, just doesn't seem specific enough!
- # flash[:error] = "Either your username and password is incorrect"
- flash[:error] = e.message
- render "new"
- end
+ session[:user_id] = user.user_id if User.where(:user_id => user.user_id).exists?
+ end
+ redirect_to path
+ else
+ # Removed this code, just doesn't seem specific enough!
+ # flash[:error] = "Either your username and password is incorrect"
+ flash[:error] = e.message
+ render "new"
+ end
end
-
+
def destroy
cookies.delete(:auth_token)
reset_session
redirect_to root_path
end
-
end
diff --git a/app/controllers/tutorials_controller.rb b/app/controllers/tutorials_controller.rb
index 7f878f3..d8e977b 100755
--- a/app/controllers/tutorials_controller.rb
+++ b/app/controllers/tutorials_controller.rb
@@ -1,41 +1,40 @@
class TutorialsController < ApplicationController
-
skip_before_filter :has_info
skip_before_filter :authenticated
-
+
def index
end
-
+
def credentials
render :partial => "layouts/tutorial/credentials/creds"
end
-
+
def show
render "injection"
end
-
+
def injection
end
-
+
def xss
- @code = %{
-
-
- Welcome, <%= current_user.first_name.html_safe %>
-
- }
+ @code = %{
+
+
+ Welcome, <%= current_user.first_name.html_safe %>
+
+ }
end
-
+
def broken_auth
end
-
+
def insecure_dor
end
-
+
def csrf
@meta_code_bad = %{<%#= csrf_meta_tags %> }
@meta_code_good = %{<%= csrf_meta_tags %> }
@@ -45,20 +44,20 @@ class TutorialsController < ApplicationController
event.preventDefault();
$.ajax(\{
url: "/example",
- data: valuesToSubmit,
- type: "POST",
- success: function(response) \{
- alert('success!');
- },
- error: function(event) \{
- alert('failure!');
- \}
- \});
+ data: valuesToSubmit,
+ type: "POST",
+ success: function(response) \{
+ alert('success!');
+ },
+ error: function(event) \{
+ alert('failure!');
+ \}
+ \});
\});
-
+
\} }
end
-
+
def misconfig
end
@@ -67,33 +66,32 @@ class TutorialsController < ApplicationController
def access_control
end
-
+
def crypto
end
-
+
def url_access
end
-
+
def ssl_tls
end
-
+
def redirects
end
-
+
def guard
end
-
+
def logic_flaws
end
-
+
def mass_assignment
end
-
+
def guantlt
-
+
end
-
+
def metaprogramming
end
-
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9a48c27..1fb5d4a 100755
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,9 +1,7 @@
class UsersController < ApplicationController
-
skip_before_filter :has_info
skip_before_filter :authenticated, :only => [:new, :create]
-
def new
@user = User.new
end
@@ -52,5 +50,4 @@ class UsersController < ApplicationController
redirect_to user_account_settings_path(:user_id => current_user.user_id)
end
end
-
end
diff --git a/app/controllers/work_info_controller.rb b/app/controllers/work_info_controller.rb
index 1ba3981..29727f4 100644
--- a/app/controllers/work_info_controller.rb
+++ b/app/controllers/work_info_controller.rb
@@ -1,8 +1,7 @@
class WorkInfoController < ApplicationController
-
def index
@user = User.find_by_user_id(params[:user_id])
- if !(@user) || @user.admin
+ if !(@user) || @user.admin
flash[:error] = "Sorry, no user with that user id exists"
redirect_to home_dashboard_index_path
end
@@ -12,11 +11,10 @@ class WorkInfoController < ApplicationController
# More secure version
def index
@user = current_user
- if !(@user) || @user.admin
+ if !(@user) || @user.admin
flash[:error] = "Apologies, looks like something went wrong"
redirect_to home_dashboard_index_path
end
end
-=end
-
+=end
end
diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep
deleted file mode 100755
index e69de29..0000000
diff --git a/app/models/.gitkeep b/app/models/.gitkeep
deleted file mode 100755
index e69de29..0000000
diff --git a/app/models/analytics.rb b/app/models/analytics.rb
index 6690504..2d9fbe5 100644
--- a/app/models/analytics.rb
+++ b/app/models/analytics.rb
@@ -4,16 +4,16 @@ class Analytics < ActiveRecord::Base
scope :hits_by_ip, ->(ip,col="*") { select("#{col}").where(:ip_address => ip).order("id DESC")}
def self.count_by_col(col)
- calculate(:count, col)
+ calculate(:count, col)
end
def self.parse_field(field)
- valid_fields = ["ip_address", "referrer", "user_agent"]
+ valid_fields = ["ip_address", "referrer", "user_agent"]
- if valid_fields.include?(field)
- field
- else
- "1"
- end
+ if valid_fields.include?(field)
+ field
+ else
+ "1"
+ end
end
end
diff --git a/app/models/benefits.rb b/app/models/benefits.rb
index 5764c9d..4a1cb9d 100644
--- a/app/models/benefits.rb
+++ b/app/models/benefits.rb
@@ -1,38 +1,37 @@
class Benefits < ActiveRecord::Base
- attr_accessor :backup
-
- def self.save(file, backup=false)
- data_path = Rails.root.join("public", "data")
- full_file_name = "#{data_path}/#{file.original_filename}"
- f = File.open(full_file_name, "wb+")
- f.write file.read
- f.close
- make_backup(file, data_path, full_file_name) if backup == "true"
- end
-
- def self.make_backup(file, data_path, full_file_name)
- if File.exists?(full_file_name)
- silence_streams(STDERR) { system("cp #{full_file_name} #{data_path}/bak#{Time.now.to_i}_#{file.original_filename}") }
- end
- end
+ attr_accessor :backup
-=begin
+ def self.save(file, backup=false)
+ data_path = Rails.root.join("public", "data")
+ full_file_name = "#{data_path}/#{file.original_filename}"
+ f = File.open(full_file_name, "wb+")
+ f.write file.read
+ f.close
+ make_backup(file, data_path, full_file_name) if backup == "true"
+ end
+
+ def self.make_backup(file, data_path, full_file_name)
+ if File.exists?(full_file_name)
+ silence_streams(STDERR) { system("cp #{full_file_name} #{data_path}/bak#{Time.now.to_i}_#{file.original_filename}") }
+ end
+ end
+
+=begin
def self.make_backup(file, data_path, full_file_name)
FileUtils.cp "#{full_file_name}", "#{data_path}/bak#{Time.now.to_i}_#{file.original_filename}"
end
-=end
+=end
- def self.silence_streams(*streams)
- on_hold = streams.collect { |stream| stream.dup }
- streams.each do |stream|
- stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
- stream.sync = true
- end
- yield
- ensure
- streams.each_with_index do |stream, i|
- stream.reopen(on_hold[i])
- end
- end
-
+ def self.silence_streams(*streams)
+ on_hold = streams.collect { |stream| stream.dup }
+ streams.each do |stream|
+ stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
+ stream.sync = true
+ end
+ yield
+ ensure
+ streams.each_with_index do |stream, i|
+ stream.reopen(on_hold[i])
+ end
+ end
end
diff --git a/app/models/key_management.rb b/app/models/key_management.rb
index 174b80c..70adbd1 100644
--- a/app/models/key_management.rb
+++ b/app/models/key_management.rb
@@ -2,5 +2,4 @@ class KeyManagement < ActiveRecord::Base
attr_accessible :iv, :user_id
belongs_to :work_info
belongs_to :user
-
end
diff --git a/app/models/paid_time_off.rb b/app/models/paid_time_off.rb
index 3628d22..409d355 100644
--- a/app/models/paid_time_off.rb
+++ b/app/models/paid_time_off.rb
@@ -6,13 +6,12 @@ class PaidTimeOff < ActiveRecord::Base
def sick_days_remaining
self.sick_days_earned - self.sick_days_taken
end
-
+
def pto_days_remaining
self.pto_earned - self.pto_taken
end
-
+
def sick_days_taken_percentage
result = self.sick_days_taken.to_f / self.sick_days_earned.to_f * 100.0
end
-
end
diff --git a/app/models/pay.rb b/app/models/pay.rb
index 78f0278..2218d11 100644
--- a/app/models/pay.rb
+++ b/app/models/pay.rb
@@ -1,25 +1,23 @@
class Pay < ActiveRecord::Base
-
# mass-assignable attributes
attr_accessible :bank_account_num, :bank_routing_num, :percent_of_deposit
-
+
# Associations
- belongs_to :user
-
+ belongs_to :user
+
# Validations
validates :bank_account_num, presence: true
validates :bank_routing_num, presence: true
validates :percent_of_deposit, presence: true
-
+
# callbacks
before_save :encrypt_bank_account_num
-
+
def as_json
super(only: [:bank_account_num, :bank_routing_num, :percent_of_deposit, :id])
end
-
+
def encrypt_bank_account_num
self.bank_account_num = Encryption.encrypt_sensitive_value(self.bank_account_num)
end
-
end
diff --git a/app/models/performance.rb b/app/models/performance.rb
index f6785b1..73f25c1 100644
--- a/app/models/performance.rb
+++ b/app/models/performance.rb
@@ -1,7 +1,7 @@
class Performance < ActiveRecord::Base
attr_accessible :comments, :date_submitted, :reviewer, :score
- belongs_to :user
-
+ belongs_to :user
+
def reviewer_name
u = User.find_by_id(self.reviewer)
u.full_name if u.respond_to?('fullname')
diff --git a/app/models/schedule.rb b/app/models/schedule.rb
index ed7dcc5..fc66df7 100644
--- a/app/models/schedule.rb
+++ b/app/models/schedule.rb
@@ -1,6 +1,6 @@
class Schedule < ActiveRecord::Base
attr_accessible :date_begin, :date_end, :event_desc, :event_name, :event_type
belongs_to :paid_time_off
-
+
validates_presence_of :date_begin, :date_end, :event_desc, :event_name, :event_type
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 261703e..9c5cc7f 100755
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,7 +1,6 @@
require 'encryption'
class User < ActiveRecord::Base
-
attr_accessible :email, :admin, :first_name, :last_name, :user_id, :password, :password_confirmation
validates :password, :presence => true,
:confirmation => true,
@@ -13,7 +12,7 @@ class User < ActiveRecord::Base
:confirmation => true,
:if => :password,
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
-=end
+=end
validates_presence_of :email
validates_uniqueness_of :email
validates_format_of :email, :with => /.+@.+\..+/i
@@ -37,11 +36,11 @@ class User < ActiveRecord::Base
#work_info.build_key_management(:iv => SecureRandom.hex(32))
performance.build(POPULATE_PERFORMANCE.shuffle.first)
end
-
+
def full_name
"#{self.first_name} #{self.last_name}"
end
-
+
=begin
# Instead of the entire user object being returned, we can use this to filter.
def as_json
@@ -49,20 +48,20 @@ class User < ActiveRecord::Base
end
=end
-private
+ private
def self.authenticate(email, password)
- auth = nil
- user = find_by_email(email)
- raise "#{email} doesn't exist!" if !(user)
- if user.password == Digest::MD5.hexdigest(password)
- auth = user
- else
- raise "Incorrect Password!"
- end
- return auth
- end
-
+ auth = nil
+ user = find_by_email(email)
+ raise "#{email} doesn't exist!" if !(user)
+ if user.password == Digest::MD5.hexdigest(password)
+ auth = user
+ else
+ raise "Incorrect Password!"
+ end
+ return auth
+ end
+
=begin
# More secure version, still lacking a decent hashing routine, this is for timing attack prevention
def self.authenticate(email, password)
@@ -71,18 +70,18 @@ private
return user
else
raise "Incorrect username or password"
- end
+ end
end
-=end
+=end
def assign_user_id
- unless @skip_user_id_assign.present? || self.user_id.present?
+ unless @skip_user_id_assign.present? || self.user_id.present?
user = User.order("user_id").last
uid = user.user_id.to_i + 1 if user && user.user_id && !(User.exists?(:user_id => "#{user.user_id.to_i + 1}"))
self.user_id = uid.to_s if uid
- end
+ end
end
-
+
def hash_password
unless @skip_hash_password == true
if password.present?
@@ -90,11 +89,10 @@ private
end
end
end
-
+
def generate_token(column)
begin
self[column] = Encryption.encrypt_sensitive_value(self.user_id)
end while User.exists?(column => self[column])
end
-
end
diff --git a/app/models/work_info.rb b/app/models/work_info.rb
index c8e30d8..2816dfa 100644
--- a/app/models/work_info.rb
+++ b/app/models/work_info.rb
@@ -3,42 +3,40 @@ class WorkInfo < ActiveRecord::Base
belongs_to :user
has_one :key_management, :foreign_key => :user_id, :primary_key => :user_id, :dependent => :destroy
#before_save :encrypt_ssn
-
-
+
# We should probably use this
def last_four
- "***-**-" << self.decrypt_ssn[-4,4]
+ "***-**-" << self.decrypt_ssn[-4,4]
end
-
+
def encrypt_ssn
- aes = OpenSSL::Cipher::Cipher.new(cipher_type)
- aes.encrypt
- aes.key = key
- aes.iv = iv if iv != nil
- self.encrypted_ssn = aes.update(self.SSN) + aes.final
- self.SSN = nil
+ aes = OpenSSL::Cipher::Cipher.new(cipher_type)
+ aes.encrypt
+ aes.key = key
+ aes.iv = iv if iv != nil
+ self.encrypted_ssn = aes.update(self.SSN) + aes.final
+ self.SSN = nil
end
-
+
def decrypt_ssn
- aes = OpenSSL::Cipher::Cipher.new(cipher_type)
- aes.decrypt
- aes.key = key
- aes.iv = iv if iv != nil
- aes.update(self.encrypted_ssn) + aes.final
+ aes = OpenSSL::Cipher::Cipher.new(cipher_type)
+ aes.decrypt
+ aes.key = key
+ aes.iv = iv if iv != nil
+ aes.update(self.encrypted_ssn) + aes.final
end
-
+
def key
raise "Key Missing" if !(KEY)
KEY
end
-
+
def iv
raise "No IV for this User" if !(self.key_management.iv)
self.key_management.iv
end
-
+
def cipher_type
'aes-256-cbc'
end
-
end
diff --git a/app/views/admin/dashboard.html.erb b/app/views/admin/dashboard.html.erb
index da2c845..854f39c 100755
--- a/app/views/admin/dashboard.html.erb
+++ b/app/views/admin/dashboard.html.erb
@@ -1,70 +1,60 @@
-
-
-
-
-
- Success!
-
-
- User information successfully updated.
-
-
-
-
-
-
-
-
- Error!
-
-
- Something went wrong.
-
-
-
-
-
-
-
-
-
+
+
+
+
+
Success!
+
User information successfully updated.
+
+
+
+
+
+
+
+
Error!
+
Something went wrong.
+
+
+
+
+
+
+
<%= javascript_include_tag "jquery.dataTables.js"%>
\ No newline at end of file
diff --git a/app/views/benefit_forms/index.html.erb b/app/views/benefit_forms/index.html.erb
index 3c48e5c..818ab08 100644
--- a/app/views/benefit_forms/index.html.erb
+++ b/app/views/benefit_forms/index.html.erb
@@ -1,134 +1,126 @@
+
\ No newline at end of file
diff --git a/app/views/dashboard/home.html.erb b/app/views/dashboard/home.html.erb
index 4cdbdbf..8fc9788 100755
--- a/app/views/dashboard/home.html.erb
+++ b/app/views/dashboard/home.html.erb
@@ -1,172 +1,167 @@
-
-
-
-
-
- <% if @user.paid_time_off %>
- <%= render :partial => "layouts/dashboard/dashboard_stats"%>
- <% end %>
-
-
-
+
+
+
+ <% if @user.paid_time_off %>
+ <%= render :partial => "layouts/dashboard/dashboard_stats"%>
+ <% end %>
+
+
+
diff --git a/app/views/layouts/admin/_analytics.html.erb b/app/views/layouts/admin/_analytics.html.erb
index 299286f..be676a0 100644
--- a/app/views/layouts/admin/_analytics.html.erb
+++ b/app/views/layouts/admin/_analytics.html.erb
@@ -6,11 +6,11 @@