diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..d7a5900 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,200 @@ +name: Build && deploy + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build_FreeBSD_14_x: + runs-on: ubuntu-latest + name: Build - FreeBSD 14.x + steps: + - uses: actions/checkout@v4 + - name: Run tests under FreeBSD + uses: vmactions/freebsd-vm@v1 + with: + release: "14.1" + usesh: true + sync: rsync + copyback: true + prepare: | + pkg install -y rust + run: | + cargo build --locked --release + - name: Get package info + id: info + uses: rabbitson87/get-cargo-package-info@v1 + with: + package: | + version + - name: Create zip file + run: | + cp target/release/fusioninventory-agent fusioninventory-agent + cp -fr src/static static + zip -r "fusioninventory-agent-${{ fromJson(steps.info.outputs.object).package.version }}_freebsd_14.x.zip" fusioninventory-agent agent.cfg static + - name: Deploy with rsync + if: ${{ github.event.pull_request.merged }} + uses: "Pendect/action-rsyncer@v1.1.0" + env: + DEPLOY_KEY: ${{ secrets.SSH_DOCUMENTATION_KEY }} + with: + flags: '-avzr' + options: '' + ssh_options: '' + src: 'fusioninventory-agent-${{ fromJson(steps.info.outputs.object).package.version }}_freebsd_14.x.zip' + dest: '${{ secrets.SSH_DOCUMENTATION_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEV_PATH }}' + + build_FreeBSD_13_x: + runs-on: ubuntu-latest + name: Build - FreeBSD 13.x + steps: + - uses: actions/checkout@v4 + - name: Run tests under FreeBSD + uses: vmactions/freebsd-vm@v1 + with: + release: "13.3" + usesh: true + sync: rsync + copyback: true + prepare: | + pkg install -y rust + run: | + cargo build --locked --release + - name: Get package info + id: info + uses: rabbitson87/get-cargo-package-info@v1 + with: + package: | + version + - name: Create zip file + run: | + cp target/release/fusioninventory-agent fusioninventory-agent + cp -fr src/static static + zip -r "fusioninventory-agent-${{ fromJson(steps.info.outputs.object).package.version }}_freebsd_13.x.zip" fusioninventory-agent agent.cfg static + - name: Deploy with rsync + if: ${{ github.event.pull_request.merged }} + uses: "Pendect/action-rsyncer@v1.1.0" + env: + DEPLOY_KEY: ${{ secrets.SSH_DOCUMENTATION_KEY }} + with: + flags: '-avzr' + options: '' + ssh_options: '' + src: 'fusioninventory-agent-${{ fromJson(steps.info.outputs.object).package.version }}_freebsd_13.x.zip' + dest: '${{ secrets.SSH_DOCUMENTATION_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEV_PATH }}' + + build_others: + name: Build - ${{ matrix.platform.release_for }} + strategy: + matrix: + platform: + - release_for: Windows-x86_64 + os: windows-latest + target: x86_64-pc-windows-msvc + bin: fusioninventory-agent.exe + name: fusioninventory-agent-Windows-x86_64.zip + command: build + + - release_for: Windows-i686 + os: windows-latest + target: i686-pc-windows-msvc + bin: fusioninventory-agent.exe + name: fusioninventory-agent-Windows-i686.zip + command: build + + # - release_for: macOS-x86_64 + # os: macOS-latest + # target: x86_64-apple-darwin + # bin: fusioninventory-agent + # name: fusioninventory-agent-Darwin-x86_64.tar.gz + # command: both + + - release_for: Linux-x86_64 + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + bin: fusioninventory-agent + name: fusioninventory-agent-Linux-x86_64.tar.gz + command: build + + # - release_for: Linux-i686 + # os: ubuntu-latest + # target: i686-unknown-linux-gnu + # bin: fusioninventory-agent + # name: fusioninventory-agent-Linux-i686.tar.gz + # command: build + + # For rapsberry pi + # armv7-unknown-linux-gnueabihf + + runs-on: ${{ matrix.platform.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Rust cache + uses: Swatinem/rust-cache@v2 + - name: Get package info + id: info + uses: rabbitson87/get-cargo-package-info@v1 + with: + package: | + version + - name: Build binary + uses: houseabsolute/actions-rust-cross@v0 + with: + command: ${{ matrix.platform.command }} + target: ${{ matrix.platform.target }} + args: "--locked --release" + cross-version: "19be83481fd3e50ea103d800d72e0f8eddb1c90c" + strip: true + - name: Create zip file + if: runner.os != 'Windows' + uses: vimtor/action-zip@v1.2 + with: + files: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} agent.cfg src/static + dest: fusioninventory-agent-${{ fromJson(steps.info.outputs.object).package.version }}_${{ matrix.platform.target }}.zip + + - name: Prepare windows dmidecode x64 + if: runner.os == 'Windows' && matrix.platform.target == 'x86_64-pc-windows-msvc' + run: | + unzip win32\dmidecode_x64.zip + + - name: Prepare windows dmidecode x86 + if: runner.os == 'Windows' && matrix.platform.target == 'i686-pc-windows-msvc' + run: | + unzip win32\dmidecode_x86.zip + + # TODO windows update agent.cfg /tmp => c:/ + # TODO Linux chmod 755 fusioninventory-agent + + - name: Create zip file + if: runner.os == 'Windows' + uses: vimtor/action-zip@v1.2 + with: + files: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} agent.cfg src/static dmidecode.exe + dest: fusioninventory-agent-${{ fromJson(steps.info.outputs.object).package.version }}_${{ matrix.platform.target }}.zip + + + - uses: GuillaumeFalourd/setup-rsync@v1.2 + id: rsync + with: + ssh_key: ${{ secrets.SSH_DOCUMENTATION_KEY }} + - if: runner.os == 'Windows' + run: | + choco install --no-progress openssh + New-Variable -Name Key -Value "D:\a\_temp\sshkey" + Icacls $Key + Icacls $Key /c /t /Inheritance:d + Icacls $Key /c /t /grant ${env:UserName}:F + TakeOwn /F $Key + Icacls $Key /c /t /grant:r ${env:UserName}:F + Icacls $Key /c /t /remove:g Administrator "Authenticated Users" BUILTIN\Administrators BUILTIN Everyone System Users BUILTIN\Users + Icacls $Key /c /t /remove:g BUILTIN\Users + Icacls $Key + Remove-Variable -Name Key + # TODO for windows get dmidecode.exe to put in zip file + - name: scp deployments + if: ${{ github.event.pull_request.merged }} + run: | + scp -o StrictHostKeyChecking=no -i "${{ steps.rsync.outputs.ssh_key_path }}" 'fusioninventory-agent-${{ fromJson(steps.info.outputs.object).package.version }}_${{ matrix.platform.target }}.zip' '${{ secrets.SSH_DOCUMENTATION_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEV_PATH }}/' diff --git a/.github/workflows/test_build.yaml b/.github/workflows/test.yaml similarity index 50% rename from .github/workflows/test_build.yaml rename to .github/workflows/test.yaml index ce0d709..5394bb0 100644 --- a/.github/workflows/test_build.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: Test & build +name: Test on: push: @@ -47,63 +47,12 @@ jobs: name: fusioninventory-agent-Linux-x86_64.tar.gz command: test - # For rapsberry pi - # armv7-unknown-linux-gnueabihf - - runs-on: ${{ matrix.platform.os }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Rust cache - uses: Swatinem/rust-cache@v2 - - name: Build binary - uses: houseabsolute/actions-rust-cross@v0 - with: - command: ${{ matrix.platform.command }} - target: ${{ matrix.platform.target }} - args: "--locked --release" - cross-version: "19be83481fd3e50ea103d800d72e0f8eddb1c90c" - strip: true - - build_FreeBSD: - runs-on: ubuntu-latest - name: Build - FreeBSD - steps: - - uses: actions/checkout@v4 - - name: Run tests under FreeBSD - uses: vmactions/freebsd-vm@v1 - with: - usesh: true - prepare: | - pkg install -y rust - run: | - cargo build --locked --release - - build_others: - name: Build - ${{ matrix.platform.release_for }} - strategy: - matrix: - platform: - - release_for: Windows-x86_64 - os: windows-latest - target: x86_64-pc-windows-msvc - bin: fusioninventory-agent.exe - name: fusioninventory-agent-Windows-x86_64.zip - command: build - - # - release_for: macOS-x86_64 - # os: macOS-latest - # target: x86_64-apple-darwin + # - release_for: Linux-i686 + # os: ubuntu-latest + # target: i686-unknown-linux-gnu # bin: fusioninventory-agent - # name: fusioninventory-agent-Darwin-x86_64.tar.gz - # command: both - - - release_for: Linux-x86_64 - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - bin: fusioninventory-agent - name: fusioninventory-agent-Linux-x86_64.tar.gz - command: build + # name: fusioninventory-agent-Linux-i686.tar.gz + # command: test # For rapsberry pi # armv7-unknown-linux-gnueabihf @@ -111,7 +60,7 @@ jobs: runs-on: ${{ matrix.platform.os }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Rust cache uses: Swatinem/rust-cache@v2 - name: Build binary diff --git a/Cargo.lock b/Cargo.lock index 426dd17..5e1daca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -466,7 +466,7 @@ dependencies = [ [[package]] name = "fusioninventory-agent" -version = "3.0.0" +version = "3.0.0-dev" dependencies = [ "chrono", "clap", @@ -487,6 +487,7 @@ dependencies = [ "single_value_channel", "sysctl", "sysinfo", + "text-to-ascii-art", "tokio", "toml", "winreg", @@ -826,7 +827,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -1827,17 +1828,16 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.30.12" +version = "0.31.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732ffa00f53e6b2af46208fba5718d9662a421049204e156328b66791ffa15ae" +checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" dependencies = [ - "cfg-if", "core-foundation-sys", "libc", + "memchr", "ntapi", - "once_cell", "rayon", - "windows 0.52.0", + "windows 0.57.0", ] [[package]] @@ -1861,6 +1861,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "text-to-ascii-art" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a0c8033260679bf366827afb9e13c308599a4b89aaabc7c6924495f88a248d3" + [[package]] name = "thiserror" version = "1.0.61" @@ -2363,11 +2369,11 @@ dependencies = [ [[package]] name = "windows" -version = "0.52.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" dependencies = [ - "windows-core", + "windows-core 0.57.0", "windows-targets 0.52.6", ] @@ -2380,6 +2386,49 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 6a8ed1c..91aecf6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fusioninventory-agent" -version = "3.0.0" +version = "3.0.0-dev" authors = ["David Durieux ", "FusionInventory contributors"] description = "Agent FusionInventory for local and remote (SNMP / ESX) inventory, have also network discovery and deploy features" edition = "2021" @@ -18,7 +18,7 @@ futures = "0.3.25" serde = { version = "1.0.152", features = ["derive"] } serde_json = "1.0" nparse = "0.0.10" -sysinfo = "0.30.11" +sysinfo = "0.31.4" simple-xml = "0.1.10" chrono = "0.4.38" iana-time-zone = "0.1.60" @@ -30,6 +30,7 @@ rocket = "0.5.0" ctrlc = "3.4.4" single_value_channel = "1.2.2" regex = "1.10.4" +text-to-ascii-art = "0.1.5" [target.'cfg(unix)'.dependencies] sysctl = "0.5.5" diff --git a/src/main.rs b/src/main.rs index fa8a924..e9ee20f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ use std::env; use clap::Parser; use lazy_static::lazy_static; use crate::common::config::Data; +use text_to_ascii_art::to_art; mod local_inventory_sender; mod module; @@ -56,6 +57,13 @@ struct Args { } fn main() { + let devVersion: bool = true; + + match to_art("FusionInventory ".to_string() + env!("CARGO_PKG_VERSION"), "small", 0, 0, 20) { + Ok(string) => println!("{}", string), + Err(err) => println!("Error: {}", err), + } + let args = Args::parse(); if args.debug || CONFIG.logging.logger_level == "debug" { env::set_var("RUST_LOG", "debug"); @@ -64,6 +72,21 @@ fn main() { } env_logger::init(); + if devVersion { + match to_art("--------------------------------".to_string(), "small", 0, 0, 0) { + Ok(string) => println!("{}", string), + Err(err) => println!("Error: {}", err), + } + match to_art("WARNING - IT IS A DEV VERSION".to_string(), "small", 0, 0, 0) { + Ok(string) => println!("{}", string), + Err(err) => println!("Error: {}", err), + } + match to_art("--------------------------------".to_string(), "small", 0, 0, 0) { + Ok(string) => println!("{}", string), + Err(err) => println!("Error: {}", err), + } + } + println!("args: {:?}", args); // return; diff --git a/src/module/localinventory/data/filesystem/mod.rs b/src/module/localinventory/data/filesystem/mod.rs index 709a7bc..bf5daa8 100644 --- a/src/module/localinventory/data/filesystem/mod.rs +++ b/src/module/localinventory/data/filesystem/mod.rs @@ -12,3 +12,4 @@ pub mod freebsd; pub mod linux; +pub mod windows; diff --git a/src/module/localinventory/data/filesystem/windows.rs b/src/module/localinventory/data/filesystem/windows.rs new file mode 100644 index 0000000..56a3103 --- /dev/null +++ b/src/module/localinventory/data/filesystem/windows.rs @@ -0,0 +1,46 @@ +#![cfg(target_os = "windows")] +// Copyright (C) 2024 FusionSuite Team +// +// This program is free software: you can redistribute it and/or modify it under +// the terms of the GNU Affero General Public License as published by the Free +// Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +// details. You should have received a copy of the GNU Affero General Public +// License along with this program. If not, see . + + +use std::process::{Command, Stdio}; +use regex::Regex; +use std::collections::HashMap; +use sysinfo::Disks; + +pub fn run_inventory() -> Vec { + fill_properties() +} + +fn fill_properties() -> Vec { + let mut filesystems_prop = Vec::new(); + + let disks = Disks::new_with_refreshed_list(); + for disk in &disks { + filesystems_prop.push(serde_json::json!([ + { + "key": "type", + "value": disk.file_system().to_str() + }, + { + "key": "name", + "value": disk.name().to_str() + }, + { + "key": "partition", + "value": disk.mount_point() + } + ])); + } + + return filesystems_prop; +} diff --git a/src/module/localinventory/data/operatingsystem/mod.rs b/src/module/localinventory/data/operatingsystem/mod.rs index d9666e3..c50ce33 100644 --- a/src/module/localinventory/data/operatingsystem/mod.rs +++ b/src/module/localinventory/data/operatingsystem/mod.rs @@ -13,3 +13,4 @@ pub mod common; pub mod freebsd; pub mod linux; +pub mod windows; diff --git a/src/module/localinventory/data/operatingsystem/windows.rs b/src/module/localinventory/data/operatingsystem/windows.rs new file mode 100644 index 0000000..7741788 --- /dev/null +++ b/src/module/localinventory/data/operatingsystem/windows.rs @@ -0,0 +1,86 @@ +#![cfg(target_os = "windows")] +// Copyright (C) 2024 FusionSuite Team +// +// This program is free software: you can redistribute it and/or modify it under +// the terms of the GNU Affero General Public License as published by the Free +// Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +// details. You should have received a copy of the GNU Affero General Public +// License along with this program. If not, see . + +use std::fs; +use chrono::prelude::{DateTime, Utc}; +use crate::module::localinventory::data::operatingsystem::common::*; + +pub fn run_inventory() -> serde_json::Value { + let osname: String = get_os_name(); + let osversion: String = get_os_version(); + // split os_version in OS version + servicepack/patch level + + let cpuarch: String = get_cpu_arch(); + let hostname: String = get_hostname(); + let lastboottime: u64 = get_boottime(); + let timezone: String = get_timezone_name(); + let timezoneoffset: i32 = get_timezone_offset(); + let installdate: String = get_installation_date(); + + // perhaps get the KELNEL ident: uname -i + // kernel version: uname -k + // + return fill_properties(osname, osversion, cpuarch, hostname, lastboottime, timezone, timezoneoffset, installdate) +} + +fn get_installation_date() -> String { + String::from("") +} + +fn fill_properties(osname: String, osversion: String, cpuarch: String, hostname: String, + lastboottime: u64, timezone: String, timezoneoffset: i32, installdate: String) -> serde_json::Value { + serde_json::json!([ + { + "key": "completename", + "value": osname + }, + { + "key": "version", + "value": osversion + }, + { + "key": "architecture", + "value": cpuarch + }, + { + "key": "servicepack", + "value": "" + }, + { + "key": "installationdate", + "value": installdate + }, + { + "key": "hostname", + "value": hostname + }, + { + "key": "domain", + "value": "" + }, + { + "key": "lastboottime", + "type": "integer", + "unit": "s", + "value": lastboottime + }, + { + "key": "timezonename", + "value": timezone + }, + { + "key": "timezoneutcoffset", + "value": timezoneoffset + } + ]) +} diff --git a/src/module/localinventory/data/software/freebsd.rs b/src/module/localinventory/data/software/freebsd.rs index 295897e..d9ee10f 100644 --- a/src/module/localinventory/data/software/freebsd.rs +++ b/src/module/localinventory/data/software/freebsd.rs @@ -123,9 +123,9 @@ fn fill_properties(packages: Vec) -> Vec { let mut uninstallcommand = String::from("pkg delete -f "); uninstallcommand.push_str(package.name.as_str()); let data: FinalPackageStruct = FinalPackageStruct { - name: package.name.clone(), + name: module::localinventory::data::software::common::clean_name(package.name.clone()), originalname: package.name, - version: package.version.clone(), + version: module::localinventory::data::software::common::clean_version(package.version.clone()), revision: "".to_string(), originalversion: package.version, publisher: "".to_string(), diff --git a/src/module/localinventory/data/software/windows/registry.rs b/src/module/localinventory/data/software/windows/registry.rs index b1c7bf9..a68cc4e 100644 --- a/src/module/localinventory/data/software/windows/registry.rs +++ b/src/module/localinventory/data/software/windows/registry.rs @@ -19,23 +19,46 @@ use winreg::enums::*; use winreg::RegKey; pub fn run_inventory() -> Vec { - // let output_snap = get_snap_list(); - let data: Vec = Vec::new(); - return data; + get_registry_softwares() } -fn get_registry_softwares() { +fn get_registry_softwares() -> Vec { + let mut softwares: Vec = Vec::new(); let hklm = RegKey::predef(HKEY_LOCAL_MACHINE); - let cur_path = hklm.open_subkey("SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall"); + let cur_path = hklm.open_subkey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"); + + // let info = cur_path.query_info(); + if let Ok(x) = cur_path { + for nm in x.enum_keys().map(|x| x.unwrap()) { + let subkey = x.open_subkey(&nm).unwrap(); - // path => 'HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall', - // wmiopts => { # Only used for remote WMI optimization - // values => [ qw/ - // DisplayName Comments HelpLink ReleaseType DisplayVersion - // Publisher URLInfoAbout UninstallString InstallDate MinorVersion - // MajorVersion NoRemove SystemComponent - // / ] - // }, + let name: String = subkey.get_value("DisplayName").unwrap_or_default(); + if name == "" { + continue; + } + let my_software: FinalPackageStruct = FinalPackageStruct { + name: name.clone(), + originalname: name, + version: subkey.get_value("DisplayVersion").unwrap_or_default(), + revision: "".to_string(), + originalversion: subkey.get_value("DisplayVersion").unwrap_or_default(), + publisher: subkey.get_value("Publisher").unwrap_or_default(), + maintainer: subkey.get_value("Publisher").unwrap_or_default(), + repository: "".to_string(), + pkgtype: "".to_string(), + architecture: "".to_string(), + category: "".to_string(), + installationdate: subkey.get_value("InstallDate").unwrap_or_default(), + uninstallcommand: "".to_string(), + id: "".to_string(), + comment: subkey.get_value("Comments").unwrap_or_default(), + mainurl: subkey.get_value("URLInfoAbout").unwrap_or_default(), + helpurl: subkey.get_value("HelpLink").unwrap_or_default() + }; + softwares.push(my_software); + } + }; + return softwares; } diff --git a/src/module/localinventory/data/volume/mod.rs b/src/module/localinventory/data/volume/mod.rs index 709a7bc..bf5daa8 100644 --- a/src/module/localinventory/data/volume/mod.rs +++ b/src/module/localinventory/data/volume/mod.rs @@ -12,3 +12,4 @@ pub mod freebsd; pub mod linux; +pub mod windows; diff --git a/src/module/localinventory/data/volume/windows.rs b/src/module/localinventory/data/volume/windows.rs new file mode 100644 index 0000000..994e689 --- /dev/null +++ b/src/module/localinventory/data/volume/windows.rs @@ -0,0 +1,60 @@ +#![cfg(target_os = "windows")] + +use sysinfo::Disks; + +pub fn run_inventory() -> Vec { + fill_properties() +} + +fn fill_properties() -> Vec { + let mut vols = Vec::new(); + + + let disks = Disks::new_with_refreshed_list(); + for disk in &disks { + vols.push(serde_json::json!([ + { + "key": "type", + "value": "" + }, + { + "key": "name", + "value": disk.name().to_str() + }, + { + "key": "partitions", + "type": "list", + "value": [] + }, + { + "key": "totalsize", + "type": "integer", + "unit": "B", + "value": disk.total_space() + }, + { + "key": "allocatedsize", + "type": "integer", + "unit": "B", + "value": (disk.total_space() - disk.available_space()) + }, + { + "key": "freesize", + "type": "integer", + "unit": "B", + "value": disk.available_space() + }, + { + "key": "allocatedpercentage", + "type": "integer", + "unit": "%", + "value": 0 + }, + { + "key": "health", + "value": "ONLINE" + } + ])); + } + return vols; +} diff --git a/src/module/localinventory/structure/filesystem.rs b/src/module/localinventory/structure/filesystem.rs index 5bb54c1..1a052f1 100644 --- a/src/module/localinventory/structure/filesystem.rs +++ b/src/module/localinventory/structure/filesystem.rs @@ -38,7 +38,7 @@ pub fn run_inventory(vol_type: String, vol_name: String) -> Vec Vec Vec { #[cfg(target_os = "windows")] fn get_data_novolume() -> Vec { - // TODO - let data = Vec::new(); - return data; + module::localinventory::data::filesystem::windows::run_inventory() } #[cfg(target_os = "macos")] diff --git a/src/module/localinventory/structure/operatingsystem.rs b/src/module/localinventory/structure/operatingsystem.rs index c3771c7..160c280 100644 --- a/src/module/localinventory/structure/operatingsystem.rs +++ b/src/module/localinventory/structure/operatingsystem.rs @@ -51,7 +51,7 @@ fn get_data() -> serde_json::Value { #[cfg(target_os = "windows")] fn get_data() -> serde_json::Value { - return serde_json::json!([]); + module::localinventory::data::operatingsystem::windows::run_inventory() } #[cfg(target_os = "macos")] diff --git a/src/module/localinventory/structure/software.rs b/src/module/localinventory/structure/software.rs index fbd4e19..a3ee9f1 100644 --- a/src/module/localinventory/structure/software.rs +++ b/src/module/localinventory/structure/software.rs @@ -170,11 +170,7 @@ fn get_data() -> Vec { #[cfg(target_os = "windows")] fn get_data() -> Vec { - // TODO - module::localinventory::data::software::windows::registry::run_inventory(); - - let data = Vec::new(); - return data; + module::localinventory::data::software::windows::registry::run_inventory() } #[cfg(target_os = "macos")] diff --git a/src/module/localinventory/structure/volume.rs b/src/module/localinventory/structure/volume.rs index fd81e87..9897b6b 100644 --- a/src/module/localinventory/structure/volume.rs +++ b/src/module/localinventory/structure/volume.rs @@ -108,9 +108,7 @@ fn get_data() -> Vec { #[cfg(target_os = "windows")] fn get_data() -> Vec { - // module::localinventory::data::partition::windows::run_inventory(disk) - let data = Vec::new(); - return data; + module::localinventory::data::volume::windows::run_inventory() } #[cfg(target_os = "macos")] diff --git a/win32/dmidecode_x64.zip b/win32/dmidecode_x64.zip new file mode 100644 index 0000000..4931085 Binary files /dev/null and b/win32/dmidecode_x64.zip differ diff --git a/win32/dmidecode_x86.zip b/win32/dmidecode_x86.zip new file mode 100644 index 0000000..6d75d1c Binary files /dev/null and b/win32/dmidecode_x86.zip differ