summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authoricebaker <icebaker@proton.me>2023-06-03 20:33:53 -0300
committericebaker <icebaker@proton.me>2023-06-03 20:33:53 -0300
commit7d728d02dea1430005ec9a24c20dd48ffa2c8efa (patch)
tree7b5cf92efa043f9633813838864fcde272f0687e /controllers
parentec1975b2c499f1639d0926641128d9382bd84485 (diff)
security
Diffstat (limited to 'controllers')
-rw-r--r--controllers/interfaces/cli.rb6
-rw-r--r--controllers/interfaces/eval.rb4
-rw-r--r--controllers/security.rb10
3 files changed, 12 insertions, 8 deletions
diff --git a/controllers/interfaces/cli.rb b/controllers/interfaces/cli.rb
index 5967c75..ae066cd 100644
--- a/controllers/interfaces/cli.rb
+++ b/controllers/interfaces/cli.rb
@@ -13,11 +13,11 @@ module NanoBot
puts NanoBot::GEM[:version]
exit
when 'security'
- result = NanoBot.security
+ result = NanoBot.security.check
if result[:encryption]
puts "\n✅ Encryption is enabled and properly working."
- puts ' It means that your data is cyrptographed stored in your disk.'
+ puts ' This means that your data is stored in an encrypted format on your disk.'
else
puts "\n❌ Encryption is not being utilized to store your content."
puts ' This means that your data can be easily read because it is stored in plaintext.'
@@ -27,7 +27,7 @@ module NanoBot
puts "\n✅ A password is being used for the encrypted content."
puts ' This means that only those who possess the password can decrypt your data.'
else
- puts "\n❌ No password is being used for the encrypted content."
+ puts "\n❌ No custom password is being used for the encrypted content."
puts ' This means that anyone can easily decrypt your data.'
end
diff --git a/controllers/interfaces/eval.rb b/controllers/interfaces/eval.rb
index 5f472ad..9613b28 100644
--- a/controllers/interfaces/eval.rb
+++ b/controllers/interfaces/eval.rb
@@ -1,9 +1,5 @@
# frozen_string_literal: true
-require 'pry'
-require 'rainbow'
-
-require_relative '../../logic/helpers/hash'
require_relative '../../logic/cartridge/affixes'
module NanoBot
diff --git a/controllers/security.rb b/controllers/security.rb
index 94cc9ff..8f066a5 100644
--- a/controllers/security.rb
+++ b/controllers/security.rb
@@ -5,12 +5,20 @@ require_relative '../components/crypto'
module NanoBot
module Controllers
module Security
+ def self.decrypt(content)
+ Components::Crypto.decrypt(content)
+ end
+
def self.check
password = ENV.fetch('NANO_BOTS_ENCRYPTION_PASSWORD', nil)
password = 'UNSAFE' unless password && password != ''
{
- encryption: Components::Crypto.encrypt('SAFE') != 'SAFE',
+ encryption: (
+ Components::Crypto.encrypt('SAFE') != 'SAFE' &&
+ Components::Crypto.encrypt('SAFE') != Components::Crypto.encrypt('SAFE') &&
+ Components::Crypto.decrypt(Components::Crypto.encrypt('SAFE')) == 'SAFE'
+ ),
password: password != 'UNSAFE'
}
end