summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoricebaker <icebaker@proton.me>2023-06-03 19:31:24 -0300
committericebaker <icebaker@proton.me>2023-06-03 19:31:24 -0300
commitec1975b2c499f1639d0926641128d9382bd84485 (patch)
treed256b88c54f2ecb2b0a71dcfee3ae8cd8b3c7e47
parentcb8a84a60773cfe9e7fab03d93fc6430e4574351 (diff)
security check
-rw-r--r--controllers/interfaces/cli.rb23
-rw-r--r--controllers/security.rb19
-rw-r--r--ports/dsl/nano-bots.rb5
3 files changed, 47 insertions, 0 deletions
diff --git a/controllers/interfaces/cli.rb b/controllers/interfaces/cli.rb
index da027f7..5967c75 100644
--- a/controllers/interfaces/cli.rb
+++ b/controllers/interfaces/cli.rb
@@ -12,6 +12,28 @@ module NanoBot
when 'version'
puts NanoBot::GEM[:version]
exit
+ when 'security'
+ result = NanoBot.security
+
+ if result[:encryption]
+ puts "\n✅ Encryption is enabled and properly working."
+ puts ' It means that your data is cyrptographed stored in 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.'
+ end
+
+ if result[:password]
+ 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 ' This means that anyone can easily decrypt your data.'
+ end
+
+ puts ''
+
+ exit
when 'help', '', nil
puts ''
puts "Nano Bots #{NanoBot::GEM[:version]}"
@@ -34,6 +56,7 @@ module NanoBot
puts ' nb - STATE-KEY state'
puts ' nb cartridge.yml STATE-KEY state'
puts ''
+ puts ' nb security'
puts ' nb version'
puts ' nb help'
puts ''
diff --git a/controllers/security.rb b/controllers/security.rb
new file mode 100644
index 0000000..94cc9ff
--- /dev/null
+++ b/controllers/security.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require_relative '../components/crypto'
+
+module NanoBot
+ module Controllers
+ module Security
+ def self.check
+ password = ENV.fetch('NANO_BOTS_ENCRYPTION_PASSWORD', nil)
+ password = 'UNSAFE' unless password && password != ''
+
+ {
+ encryption: Components::Crypto.encrypt('SAFE') != 'SAFE',
+ password: password != 'UNSAFE'
+ }
+ end
+ end
+ end
+end
diff --git a/ports/dsl/nano-bots.rb b/ports/dsl/nano-bots.rb
index cbfe7f9..eca824e 100644
--- a/ports/dsl/nano-bots.rb
+++ b/ports/dsl/nano-bots.rb
@@ -5,6 +5,7 @@ require 'dotenv/load'
require_relative '../../static/gem'
require_relative '../../controllers/cartridges'
require_relative '../../controllers/instance'
+require_relative '../../controllers/security'
require_relative '../../controllers/interfaces/cli'
require_relative '../../components/stream'
@@ -18,6 +19,10 @@ module NanoBot
)
end
+ def self.security
+ Controllers::Security.check
+ end
+
def self.cartridges
Controllers::Cartridges.all
end