Sha256: 6d0862569c3a679063216b74bb78e8f17e209926e2ac28d441519c231b63583a

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

/* Copyright (c) 2021 Contrast Security, Inc.  See
 * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */

#include "cs__os_information.h"
#include <dlfcn.h>
#include <ruby.h>
#include <sys/utsname.h>

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);
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contrast-agent-4.14.1 ext/cs__os_information/cs__os_information.c
contrast-agent-4.14.0 ext/cs__os_information/cs__os_information.c
contrast-agent-4.13.1 ext/cs__os_information/cs__os_information.c
contrast-agent-4.13.0 ext/cs__os_information/cs__os_information.c