{"id":15676982,"url":"https://github.com/blaind/hstrace","last_synced_at":"2025-05-05T21:21:38.547Z","repository":{"id":38313800,"uuid":"240900014","full_name":"blaind/hstrace","owner":"blaind","description":"Syscall tracing CLI \u0026 library made in Rust","archived":false,"fork":false,"pushed_at":"2022-12-12T08:10:36.000Z","size":388,"stargazers_count":14,"open_issues_count":12,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T09:31:24.097Z","etag":null,"topics":["cli","command-line","command-line-tool","rust","rust-crate","strace","syscall","syscalls","tracing"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/hstrace","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blaind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-16T13:52:37.000Z","updated_at":"2025-01-12T11:39:05.000Z","dependencies_parsed_at":"2023-01-27T16:16:25.410Z","dependency_job_id":null,"html_url":"https://github.com/blaind/hstrace","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fhstrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fhstrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fhstrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fhstrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blaind","download_url":"https://codeload.github.com/blaind/hstrace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252577117,"owners_count":21770735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","command-line-tool","rust","rust-crate","strace","syscall","syscalls","tracing"],"created_at":"2024-10-03T16:07:55.600Z","updated_at":"2025-05-05T21:21:38.529Z","avatar_url":"https://github.com/blaind.png","language":"Rust","readme":"Syscall tracing CLI \u0026 library\n==================================================\n\n[![Build Status](https://img.shields.io/github/workflow/status/blaind/hstrace/test)](https://github.com/blaind/hstrace/actions?query=branch%3Amaster)\n[![Latest Version](https://img.shields.io/crates/v/hstrace.svg)](https://crates.io/crates/hstrace)\n[![Rust Documentation](https://docs.rs/hstrace/badge.svg)](https://docs.rs/hstrace)\n![License](https://img.shields.io/crates/l/hstrace.svg)\n[![Lines of Code](https://tokei.rs/b1/github/blaind/hstrace?category=code)](https://github.com/blaind/hstrace)\n\nSyscall tracing from command line and as a library. See the design draft: https://github.com/blaind/hstrace/blob/master/docs/01_hstrace_plan.md\n\nRequires Linux kernel 5.3 or later (uses `PTRACE_GET_SYSCALL_INFO` API)\n\n**This is a WIP implementation, and not production ready. Might not be finished**. Multiple issues exist: 1) codebase is not ready to be expanded yet, major refactoring is needed especially for the `AV` and `Value` structs to be more generic, 2) attach to process is not instant, some calls are missed at beginning, 3) not all syscalls are implemented, 4) cross-platform support is missing, 5) as a comparison, `strace` codebase is over 200k LoC in total (incl comments), so finishing the work is quite an undertaking\n\n## Prequisites\n\nInstall dependencies:\n```\n$ apt-get install libclang1\n```\n\n## Command line tool\n\n![Syscall-output](docs/cli-hstrace.png)\n\nInstall the binary:\n```\n$ cargo install hstrace\n```\n\nRun the command\n```\n$ hstrace -h\n\nhstrace for stracing processes\n\nUSAGE:\n    hstrace [FLAGS] [OPTIONS] \u003cprog\u003e...\n\nFLAGS:\n    -h, --help         Prints help information\n        --no-follow    Do not follow child processes as they are created\n    -V, --version      Prints version information\n\nOPTIONS:\n    -e \u003cexpr\u003e           Expression\n    -m \u003cmode\u003e           Run mode [default: strace]\n    -o \u003cfile\u003e           Save output to a file instead of stderr. If suffix is `.json`, will be stored in JSON-format\n                        (format subject to change)\n    -p \u003cpid\u003e            PID to trace\n    -s \u003cstrsize\u003e        Maximum length of printable strings [default: 32]\n\nARGS:\n    \u003cprog\u003e...    Program to strace\n```\n\n## Stracing library\n\n### Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nhstrace = \"0.0.4\"\n```\n\nAnd this to your code:\n\n```rust\nuse hstrace::prelude::*;\n\nfn main() {\n    let mut tracer = HStraceBuilder::new().program(\"ps\").arg(\"uxaw\").build();\n\n    tracer.start().unwrap();\n\n    for syscall in tracer.iter_as_syscall() {\n        match syscall.name {\n            hstrace::Ident::Openat | hstrace::Ident::Fstat | hstrace::Ident::Stat =\u003e {\n                println!(\"File operation detected: {:?}\", syscall);\n            }\n\n            hstrace::Ident::Socket | hstrace::Ident::Bind | hstrace::Ident::Connect =\u003e {\n                println!(\"Network operation detected: {:?}\", syscall);\n            }\n\n            _ =\u003e (),\n        }\n    }\n}\n```\n\nSee [examples/03_match_syscall_name.rs](examples/03_match_syscall_name.rs) and other [examples](examples).\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaind%2Fhstrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblaind%2Fhstrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaind%2Fhstrace/lists"}