Sha256: 9ee39c92fb99309681ff3b9027961c051ef069316c6ab6b020389c7692dec688

Contents?: true

Size: 1.16 KB

Versions: 18

Compression:

Stored size: 1.16 KB

Contents

/* Copyright (c) 2023 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

18 entries across 18 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 ext/cs__os_information/cs__os_information.c
contrast-agent-7.6.0 ext/cs__os_information/cs__os_information.c
contrast-agent-7.5.0 ext/cs__os_information/cs__os_information.c
contrast-agent-7.4.1 ext/cs__os_information/cs__os_information.c
contrast-agent-7.4.0 ext/cs__os_information/cs__os_information.c
contrast-agent-7.3.2 ext/cs__os_information/cs__os_information.c
contrast-agent-7.3.1 ext/cs__os_information/cs__os_information.c
contrast-agent-7.3.0 ext/cs__os_information/cs__os_information.c
contrast-agent-7.2.0 ext/cs__os_information/cs__os_information.c
contrast-agent-7.1.0 ext/cs__os_information/cs__os_information.c
contrast-agent-7.0.0 ext/cs__os_information/cs__os_information.c
contrast-agent-6.15.3 ext/cs__os_information/cs__os_information.c
contrast-agent-6.15.2 ext/cs__os_information/cs__os_information.c
contrast-agent-6.15.1 ext/cs__os_information/cs__os_information.c
contrast-agent-6.15.0 ext/cs__os_information/cs__os_information.c
contrast-agent-6.14.0 ext/cs__os_information/cs__os_information.c
contrast-agent-6.13.0 ext/cs__os_information/cs__os_information.c
contrast-agent-6.12.0 ext/cs__os_information/cs__os_information.c