Class: DradisTasks::Reset

Inherits:
Thor
  • Object
show all
Defined in:
lib/tasks/thorfile.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) attachments



195
196
197
198
199
# File 'lib/tasks/thorfile.rb', line 195

def attachments
  print "** Deleting all attachments...                                        "
  FileUtils.rm_rf(Dir.glob( Attachment::AttachmentPwd.join('*')) )
  puts(Dir.glob( Attachment::AttachmentPwd.join('*')).empty? ? "[  DONE  ]" : "[ FAILED ]")
end

- (Object) database



202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/tasks/thorfile.rb', line 202

def database
  require 'config/environment'
  
  print "** Cleaning database...                                               "

  Note.destroy_all
  Node.destroy_all
  Category.destroy_all
  
  Feed.destroy_all
  Log.destroy_all
  
  puts "[  DONE  ]"
end

- (Object) logs



218
219
220
221
222
# File 'lib/tasks/thorfile.rb', line 218

def logs
  print "** Deleting all log files...                                          "
  FileUtils.rm_rf(Dir.glob('log/*.log'))
  puts(Dir.glob('log/*.log').empty? ? "[  DONE  ]" : "[ FAILED ]")
end

- (Object) password



225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/tasks/thorfile.rb', line 225

def password()
  require 'config/environment'

  say "Changing password for Dradis server."
  password = ask "Enter new Dradis password:"
  confirmation = ask "Retype new Dradis password:"

  if !password.blank? && password == confirmation
    Configuration.find_or_create_by_name('password').update_attribute(:value, ::Digest::SHA512.hexdigest(password))
    say("Password Changed.", Thor::Shell::Color::GREEN)
  else
    say("Passwords do not match. Password Unchanged.", Thor::Shell::Color::RED)
  end
end