Skip to main content

Crate codewalk

Crate codewalk 

Source
Expand description

§codewalk

Fast, security-aware file tree walker for codebase scanning.

Every security tool that scans codebases needs the same thing: walk a directory tree, skip binaries and huge files, respect .gitignore, and read file contents efficiently. This crate does all of that.

§Usage

use codewalk::{CodeWalker, WalkConfig};

let config = WalkConfig::default();
let walker = CodeWalker::new("/path/to/repo", config);

for entry in walker.walk().unwrap() {
    println!(
        "{} ({} bytes, binary={})",
        entry.path.display(),
        entry.size,
        entry.is_binary
    );
    if let Ok(content) = entry.content() {
        // scan the content...
        let _ = content.len();
    }
}

Modules§

error
Error types returned by codewalk APIs.

Structs§

CodeWalker
File tree walker for codebase scanning.
FileEntry
A discovered file entry with lazy content loading.
WalkConfig
Configuration for directory walking.

Traits§

FileSource
Trait for anything that walks files and yields entries.

Functions§

is_binary
Check if a file is binary using magic bytes and extension heuristics.
scan_files
Convenience: walk and read all text files, returning (path, content) pairs. Propagates walk, I/O, and UTF-8 errors instead of silently dropping files.