Giter Site home page Giter Site logo

helloimalemur / filesystem-hashing Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 87 KB

Snapshots contain a HashMap of the files and their corresponding hash signature from a specified directory.

Home Page: https://docs.rs/crate/filesystem-hashing/

Rust 100.00%
file-hashing file-integrity file-integrity-check hashing-library

filesystem-hashing's Introduction

filesystem-hashing

Track Filesystem Integrity via Snapshots

~ contain a HashMap of the files and their corresponding hash signature from a specified directory.
~ are exported as JSON files.

Snapshot structure

pub enum HashType {
    MD5,
    SHA3,
    BLAKE3,
}
pub struct Snapshot {
    pub file_hashes: Arc<Mutex<HashMap<String, FileMetadata>>>,
    pub black_list: Vec<String>,
    pub root_path: String,
    pub hash_type: HashType,
    pub uuid: String,
    pub date_created: i64,
}
pub struct FileMetadata {
    pub path: String,
    pub check_sum: Vec<u8>,
    pub size: u64,
    pub ino: u64,
    pub ctime: i64,
    pub mtime: i64,
}

Snapshot Comparison result structure

    pub enum SnapshotChangeType {
        None,
        Created,
        Deleted,
        Changed,
    }
    pub struct SnapshotCompareResult {
        pub created: Vec<String>,
        pub deleted: Vec<String>,
        pub changed: Vec<String>,
    }

Usage

fn main() {
    /// snapshot creation
    let snapshot = create_snapshot("/etc", BLAKE3, vec![])?;
    let snapshot2 = create_snapshot("/etc", BLAKE3, vec![])?;
    
    /// snapshot export
    export_snapshot(snapshot.clone(), "./".to_string(), true)?;
    
    /// compare snapshots
    let results: (SnapshotChangeType, SnapshotCompareResult) = compare_snapshots(snapshot(), snapshot2)?;
}

Utilized in the following project(s)

Notes

~ It is advised to **exclude** tmp directories, mail spools, log directories, proc filesystems,
user's home directories, web content directories, and psuedo-device files.
~ It is advised to **include** all system binaries, libraries, include files, system source files.
~ It is also advisable to include directories you don't often look in such as /dev, or /usr/man/.

Development and Collaboration

Feel free to open a pull request, please run the following prior to your submission please!

echo "Run clippy"; cargo clippy -- -D clippy::all
echo "Format source code"; cargo fmt -- --check

filesystem-hashing's People

Contributors

helloimalemur avatar

Watchers

 avatar

filesystem-hashing's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.