Class: Aikido::Zen::SystemInfo
- Inherits:
-
Object
- Object
- Aikido::Zen::SystemInfo
- Defined in:
- lib/aikido/zen/system_info.rb
Overview
Provides information about the currently running Agent.
Instance Method Summary collapse
- #as_json ⇒ Object
- #attacks_are_only_reported? ⇒ Boolean
- #attacks_block_requests? ⇒ Boolean
- #hostname ⇒ Object
-
#ip_address ⇒ String
The first non-loopback IPv4 address that we can use to identify this host.
- #library_name ⇒ Object
- #library_version ⇒ Object
- #os_name ⇒ Object
- #os_version ⇒ Object
-
#packages ⇒ Array<Aikido::Zen::Package>
A list of loaded rubygems that are supported by Aikido (i.e. we have a Sink that scans the package for vulnerabilities and protects you).
- #platform_version ⇒ Object
Instance Method Details
#as_json ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/aikido/zen/system_info.rb', line 62 def as_json { "dryMode" => attacks_are_only_reported?, "library" => library_name, "version" => library_version, "hostname" => hostname, "ipAddress" => ip_address, "platform" => {"version" => platform_version}, "os" => {"name" => os_name, "version" => os_version}, "packages" => packages.reduce({}) { |all, package| all.update(package.as_json) }, "incompatiblePackages" => {}, "stack" => [], "serverless" => false, "nodeEnv" => "", "preventedPrototypePollution" => false } end |
#attacks_are_only_reported? ⇒ Boolean
15 16 17 |
# File 'lib/aikido/zen/system_info.rb', line 15 def attacks_are_only_reported? !attacks_block_requests? end |
#attacks_block_requests? ⇒ Boolean
11 12 13 |
# File 'lib/aikido/zen/system_info.rb', line 11 def attacks_block_requests? !!Aikido::Zen.blocking_mode? end |
#hostname ⇒ Object
31 32 33 |
# File 'lib/aikido/zen/system_info.rb', line 31 def hostname @hostname ||= Socket.gethostname end |
#ip_address ⇒ String
47 48 49 50 51 52 |
# File 'lib/aikido/zen/system_info.rb', line 47 def ip_address @ip_address ||= Socket.ip_address_list .reject { |ip| ip.ipv4_loopback? || ip.ipv6_loopback? || ip.unix? } .min_by { |ip| ip.ipv4? ? 0 : 1 } .ip_address end |
#library_name ⇒ Object
19 20 21 |
# File 'lib/aikido/zen/system_info.rb', line 19 def library_name "firewall-ruby" end |
#library_version ⇒ Object
23 24 25 |
# File 'lib/aikido/zen/system_info.rb', line 23 def library_version VERSION end |
#os_name ⇒ Object
54 55 56 |
# File 'lib/aikido/zen/system_info.rb', line 54 def os_name Gem::Platform.local.os end |
#os_version ⇒ Object
58 59 60 |
# File 'lib/aikido/zen/system_info.rb', line 58 def os_version Gem::Platform.local.version || "unknown" end |
#packages ⇒ Array<Aikido::Zen::Package>
38 39 40 41 42 |
# File 'lib/aikido/zen/system_info.rb', line 38 def packages @packages ||= Gem.loaded_specs .map { |_, spec| Package.new(spec.name, spec.version) } .select(&:supported?) end |
#platform_version ⇒ Object
27 28 29 |
# File 'lib/aikido/zen/system_info.rb', line 27 def platform_version RUBY_VERSION end |