
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
HostOS is a module that offers details about the host operating system, the current Ruby interpreter, and the environment currently in use.
This gem helps you write environment-specific code in a clean way. It provides a simple API to get information about the operating system, the current Ruby interpreter, and the configured environment.
Here is a very simple example of OS dependent code:
require 'host-os'
if HostOS.unix?
puts 'Hello Unix world!'
elsif HostOS.windows?
puts 'Clean your Windows!'
elsif HostOS.os2? || HostOS.vms?
puts 'Hello old school!'
end
You are free to write your code in whatever way you prefer. Here is a functionally identical but alternative to the example above:
require 'host-os'
if HostOS.is? :unix
puts 'Hello Unix world!'
elsif HostOS.is? 'windows'
puts 'Clean your Windows!'
elsif %i[os2 vms].include?(HostOS.type)
puts 'Hello old school!'
end
The module also assists with environment- or interpreter-specific code:
require 'host-os'
Logger.log_level = HostOS.env.production? ? Logger::WARN : Logger::INFO
# => set the log level to 'WARN' in production, 'INFO' otherwise
require 'java' if HostOS.interpreter.jruby?
# => load the Java support for JRuby
There are additional methods that can support you on various platforms:
require 'host-os/support'
HostOS.dev_null
# => returns 'NUL' on Windows, 'nul' for OS2 and '/dev/null' on Unix platforms
HostOS.app_config_path('my_app')
# => returns the directory name where 'my_app' stores its configuration files
HostOS.rss_bytes
# => memory consumtion of current process in bytes
# means "total in memory footprint"
📕 See the online help for more details.
This gem is compatible with Ruby 2.3 and higher. You can install it in your system with
gem install host-os
or you can use Bundler to add HostOS just to your own project:
bundle add 'host-os'
After that you only need one line of code to have everything together
require 'host-os'
FAQs
Unknown package
We found that host-os demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.