Skip to content

Commit

Permalink
Use published rather than vendored version of Vectorscan (#168)
Browse files Browse the repository at this point in the history
* Delete vendored version of vectorscan, and instead, use the new `vectorscan-rs` and `vectorscan-rs-sys` crates
published on crates.io.
* Update CHANGELOG
  • Loading branch information
bradlarsen authored Apr 5, 2024
1 parent 9bd5b45 commit f2b1d1d
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 15,300 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project aspires to use [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## Unreleased

### Additions
Expand All @@ -31,6 +32,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- The `rules list` command now includes additional fields when using JSON format ([#161](https://github.com/praetorian-inc/noseyparker/pull/161)).

- The `vectorscan` and `vectorscan-sys` crates have been split off into a [separate project](https://github.com/bradlarsen/vectorscan-rs) with crates published on crates.io ([#168](https://github.com/praetorian-inc/noseyparker/pull/168)).


## [v0.17.0](https://github.com/praetorian-inc/noseyparker/releases/v0.17.0) (2024-03-05)

Expand Down
148 changes: 25 additions & 123 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ opt-level = 3
[profile.dev.package.similar]
opt-level = 3

# `vectorscan` and `vectorscan-sys` benefit from being build in release mode,
# `vectorscan-rs` and `vectorscan-rs-sys` benefit from being build in release mode,
# even as a dev dependency: doing so saves about 6 seconds on each integration
# test case!
[profile.dev.package.vectorscan]
[profile.dev.package.vectorscan-rs]
opt-level = 3
[profile.dev.package.vectorscan-sys]
[profile.dev.package.vectorscan-rs-sys]
opt-level = 3
6 changes: 3 additions & 3 deletions crates/noseyparker-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ disable_trace = ["log/release_max_level_debug", "tracing/release_max_level_debug

# Specialize the build of Vectorscan for the microarchitecture of the build system's CPU.
# This will result in binary that is not portable to other CPUs.
vectorscan_cpu_native = ["vectorscan/cpu_native"]
vectorscan_cpu_native = ["vectorscan-rs/cpu_native"]

# Specialize the build of Vectorscan to use available SIMD instructions on the build system's CPU.
# This will result in binary that is not portable to other CPUs.
vectorscan_simd_specialization = ["vectorscan/simd_specialization"]
vectorscan_simd_specialization = ["vectorscan-rs/simd_specialization"]

# Enable all Vectorscan features that can improve speed but break binary portability.
vectorscan_fast_nonportable = ["vectorscan_cpu_native", "vectorscan_simd_specialization"]
Expand Down Expand Up @@ -90,7 +90,7 @@ tracing = "0.1"
tracing-log = "0.2"
tracing-subscriber = { version = "0.3", features = ["tracing-log", "ansi", "env-filter", "smallvec", "fmt"], default_features = false }
url = "2.3"
vectorscan = { path = "../vectorscan" }
vectorscan-rs = { version = "0.0.1" }

[dev-dependencies]
assert_cmd = { version = "2.0", features = ["color-auto"] }
Expand Down
6 changes: 3 additions & 3 deletions crates/noseyparker-cli/src/cmd_rules/cmd_rules_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{bail, Context, Result};
use regex::Regex;
use std::collections::HashSet;
use tracing::{debug_span, error, error_span, info, warn};
use vectorscan::{BlockDatabase, Flag, Pattern, Scan};
use vectorscan_rs::{BlockDatabase, Flag, Pattern, Scan};

use noseyparker::rules_database::RulesDatabase;
use noseyparker_rules::{Rule, RulesetSyntax};
Expand Down Expand Up @@ -189,7 +189,7 @@ fn hs_compile_pattern(pat: &str) -> Result<BlockDatabase> {
// fn hs_compile_pattern_streaming(pat: &str) -> Result<StreamingDatabase> {
// let pattern = pattern!{pat};
// let mut pattern = pattern.left_most();
// pattern.som = Some(vectorscan::SomHorizon::Large);
// pattern.som = Some(vectorscan_rs::SomHorizon::Large);
// let db: StreamingDatabase = pattern.build()?;
// Ok(db)
// }
Expand Down Expand Up @@ -270,7 +270,7 @@ fn check_rule(rule_num: usize, rule: &Rule) -> Result<CheckStats> {
num_errors += 1;
}
Ok(db) => {
let mut scanner = vectorscan::BlockScanner::new(&db)?;
let mut scanner = vectorscan_rs::BlockScanner::new(&db)?;

let mut num_succeeded = 0;
let mut num_failed = 0;
Expand Down
2 changes: 1 addition & 1 deletion crates/noseyparker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ thiserror = "1"
tokio = "1.23"
tracing = "0.1"
url = "2.3"
vectorscan = { path = "../vectorscan" }
vectorscan-rs = { version = "0.0.1" }

[dev-dependencies]
pretty_assertions = "1.3"
6 changes: 3 additions & 3 deletions crates/noseyparker/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct UserData {
/// If doing multi-threaded scanning, use a separate `Matcher` for each thread.
pub struct Matcher<'a> {
/// A scratch buffer for Vectorscan
vs_scanner: vectorscan::BlockScanner<'a>,
vs_scanner: vectorscan_rs::BlockScanner<'a>,

/// The rules database used for matching
rules_db: &'a RulesDatabase,
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<'a> Matcher<'a> {
raw_matches_scratch,
input_len: 0,
};
let vs_scanner = vectorscan::BlockScanner::new(&rules_db.vsdb)?;
let vs_scanner = vectorscan_rs::BlockScanner::new(&rules_db.vsdb)?;
Ok(Matcher {
vs_scanner,
rules_db,
Expand All @@ -141,7 +141,7 @@ impl<'a> Matcher<'a> {
start_idx,
end_idx: to,
});
vectorscan::Scan::Continue
vectorscan_rs::Scan::Continue
})?;
Ok(())
}
Expand Down
Loading

0 comments on commit f2b1d1d

Please sign in to comment.