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
-
#initialize(config = Aikido::Zen.config) ⇒ SystemInfo
constructor
A new instance of SystemInfo.
-
#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
Constructor Details
#initialize(config = Aikido::Zen.config) ⇒ SystemInfo
Returns a new instance of SystemInfo.
11 12 13 |
# File 'lib/aikido/zen/system_info.rb', line 11 def initialize(config = Aikido::Zen.config) @config = config end |
Instance Method Details
#as_json ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/aikido/zen/system_info.rb', line 66 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
19 20 21 |
# File 'lib/aikido/zen/system_info.rb', line 19 def attacks_are_only_reported? !attacks_block_requests? end |
#attacks_block_requests? ⇒ Boolean
15 16 17 |
# File 'lib/aikido/zen/system_info.rb', line 15 def attacks_block_requests? !!@config.blocking_mode end |
#hostname ⇒ Object
35 36 37 |
# File 'lib/aikido/zen/system_info.rb', line 35 def hostname @hostname ||= Socket.gethostname end |
#ip_address ⇒ String
Returns the first non-loopback IPv4 address that we can use to identify this host. If the machine is solely identified by IPv6 addresses, then this will instead return an IPv6 address.
51 52 53 54 55 56 |
# File 'lib/aikido/zen/system_info.rb', line 51 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
23 24 25 |
# File 'lib/aikido/zen/system_info.rb', line 23 def library_name "firewall-ruby" end |
#library_version ⇒ Object
27 28 29 |
# File 'lib/aikido/zen/system_info.rb', line 27 def library_version VERSION end |
#os_name ⇒ Object
58 59 60 |
# File 'lib/aikido/zen/system_info.rb', line 58 def os_name Gem::Platform.local.os end |
#os_version ⇒ Object
62 63 64 |
# File 'lib/aikido/zen/system_info.rb', line 62 def os_version Gem::Platform.local.version end |
#packages ⇒ Array<Aikido::Zen::Package>
Returns 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).
42 43 44 45 46 |
# File 'lib/aikido/zen/system_info.rb', line 42 def packages @packages ||= Gem.loaded_specs .map { |_, spec| Package.new(spec.name, spec.version) } .select(&:supported?) end |
#platform_version ⇒ Object
31 32 33 |
# File 'lib/aikido/zen/system_info.rb', line 31 def platform_version RUBY_VERSION end |