/* Copyright (c) 2021 Contrast Security, Inc. See * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */ #include "cs__os_information.h" #include #include #include VALUE contrast, utils, os; VALUE contrast_get_system_information() { struct utsname uname_pointer; uname (&uname_pointer); VALUE rb_data_hash = rb_hash_new(); rb_hash_aset(rb_data_hash, rb_str_new2("os_type"), rb_str_new2(uname_pointer.sysname)); rb_hash_aset(rb_data_hash, rb_str_new2("os_version"), rb_str_new2(uname_pointer.release)); rb_hash_aset(rb_data_hash, rb_str_new2("os_complete_version"), rb_str_new2(uname_pointer.version)); rb_hash_aset(rb_data_hash, rb_str_new2("os_arch"), rb_str_new2(uname_pointer.machine)); return rb_data_hash; } void Init_cs__os_information(void) { contrast = rb_define_module("Contrast"); utils = rb_define_module_under(contrast, "Utils"); os = rb_define_module_under(utils, "OS"); rb_define_module_function(os, "get_system_information", contrast_get_system_information, 0); }