pyrograph 0.1.0

GPU-accelerated taint analysis for supply chain malware detection
Documentation
#[cfg(feature = "js")]
pub mod js;
#[cfg(feature = "go")]
pub mod go;
#[cfg(feature = "python")]
pub mod python;
#[cfg(feature = "rust-lang")]
pub mod rust;
#[cfg(feature = "js")]
pub mod resolve;
#[cfg(feature = "js")]
pub mod package_json;

#[cfg(any(feature = "js", feature = "go", feature = "rust-lang", feature = "python"))]
use crate::error::Result;
#[cfg(any(feature = "js", feature = "go", feature = "rust-lang", feature = "python"))]
use crate::ir::TaintGraph;
#[cfg(feature = "js")]
use std::path::Path;

/// Parse a single JavaScript file into a taint graph with optional custom labels.
#[cfg(feature = "js")]
pub fn parse_js_with_labels(
    source: &str,
    filename: &str,
    labels: Option<&crate::labels::LabelSet>,
) -> Result<TaintGraph> {
    js::parse_js_with_labels(source, filename, labels)
}

/// Parse a single JavaScript file into a taint graph.
#[cfg(feature = "js")]
pub fn parse_js(source: &str, filename: &str) -> Result<TaintGraph> {
    js::parse_js(source, filename)
}

/// Parse a single Go file into a taint graph with optional custom labels.
#[cfg(feature = "go")]
pub fn parse_go_with_labels(
    source: &str,
    filename: &str,
    labels: Option<&crate::labels::LabelSet>,
) -> Result<TaintGraph> {
    go::parse_go_with_labels(source, filename, labels)
}

/// Parse a single Go file into a taint graph.
#[cfg(feature = "go")]
pub fn parse_go(source: &str, filename: &str) -> Result<TaintGraph> {
    parse_go_with_labels(source, filename, None)
}

/// Parse a single Python file into a taint graph with optional custom labels.
#[cfg(feature = "python")]
pub fn parse_python_with_labels(
    source: &str,
    filename: &str,
    labels: Option<&crate::labels::LabelSet>,
) -> Result<TaintGraph> {
    python::parse_python_with_labels(source, filename, labels)
}

/// Parse a single Python file into a taint graph.
#[cfg(feature = "python")]
pub fn parse_python(source: &str, filename: &str) -> Result<TaintGraph> {
    parse_python_with_labels(source, filename, None)
}

/// Parse a single Rust file into a taint graph with optional custom labels.
#[cfg(feature = "rust-lang")]
pub fn parse_rust_with_labels(
    source: &str,
    filename: &str,
    labels: Option<&crate::labels::LabelSet>,
) -> Result<TaintGraph> {
    rust::parse_rust_with_labels(source, filename, labels)
}

/// Parse a single Rust file into a taint graph.
#[cfg(feature = "rust-lang")]
pub fn parse_rust(source: &str, filename: &str) -> Result<TaintGraph> {
    rust::parse_rust(source, filename)
}

/// Parse all `.js` files under `dir` and link them via `require()` calls
/// with optional custom labels.
#[cfg(feature = "js")]
pub fn parse_package_with_labels(
    dir: &Path,
    labels: Option<&crate::labels::LabelSet>,
) -> Result<TaintGraph> {
    js::parse_package_with_labels(dir, labels)
}

/// Parse all `.js` files under `dir` and link them via `require()` calls.
#[cfg(feature = "js")]
pub fn parse_package(dir: &Path) -> Result<TaintGraph> {
    js::parse_package(dir)
}