Skip to content

Commit

Permalink
Rename top-level directories.
Browse files Browse the repository at this point in the history
In the future we want to add a `go` directory that contains the Go bindings for YARA-X. Having a `yara-x-go` directory is not ideal, because the import path for that Go module would be `github.com/VirusTotal/yara-x/yara-x-go`. Instead we want the more natural `github.com/VirusTotal/yara-x/go`. However, adding a `go` directory makes the current naming incoherent, but with this change everything fits well again.
  • Loading branch information
plusvic committed Feb 9, 2024
1 parent 0443b6e commit c8af699
Show file tree
Hide file tree
Showing 365 changed files with 45 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
pwd
python -m pip install --upgrade pip maturin
python -m pip install pytest
maturin develop --manifest-path yara-x-py/Cargo.toml
pytest yara-x-py
maturin develop --manifest-path py/Cargo.toml
pytest py
# Non-windows
- name: Test Python - Non-Windows
Expand All @@ -58,6 +58,6 @@ jobs:
virtualenv venv; source venv/bin/activate
python -m pip install --upgrade pip maturin
python -m pip install pytest
maturin develop --manifest-path yara-x-py/Cargo.toml
pytest yara-x-py
maturin develop --manifest-path py/Cargo.toml
pytest py
29 changes: 15 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ rust-version = "1.73.0"

[workspace]
members = [
"yara-x",
"yara-x-cli",
"yara-x-fmt",
"yara-x-macros",
"yara-x-parser",
"yara-x-proto",
"yara-x-proto-yaml",
"yara-x-py",
"lib",
"clib",
"cli",
"fmt",
"macros",
"parser",
"proto",
"proto-yaml",
"py",
]
resolver = "2"

Expand Down Expand Up @@ -84,12 +85,12 @@ walrus = "0.20.2"
wasmtime = "17.0.0"
yaml-rust = "0.4.5"
yansi = "0.5.1"
yara-x = { path = "yara-x" }
yara-x-fmt = { path = "yara-x-fmt" }
yara-x-macros = { path = "yara-x-macros" }
yara-x-parser = { path = "yara-x-parser" }
yara-x-proto = { path = "yara-x-proto" }
yara-x-proto-yaml = { path = "yara-x-proto-yaml" }
yara-x = { path = "lib" }
yara-x-fmt = { path = "fmt" }
yara-x-macros = { path = "macros" }
yara-x-parser = { path = "parser" }
yara-x-proto = { path = "proto" }
yara-x-proto-yaml = { path = "proto-yaml" }

# Special profile that builds a release binary with link-time optimization.
# Compiling with this profile takes a while, but the resulting binary is
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions yara-x-cli/src/commands/scan.rs → cli/src/commands/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@ fn print_matching_rules(
format!(
"{}:{} {}",
Cyan.paint(matching_rule.namespace()).bold(),
Cyan.paint(matching_rule.name()).bold(),
Cyan.paint(matching_rule.identifier()).bold(),
file_path.display(),
)
} else {
format!(
"{} {}",
Cyan.paint(matching_rule.name()).bold(),
Cyan.paint(matching_rule.identifier()).bold(),
file_path.display()
)
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions yara-x/build.rs → lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ fn main() {
.pure()
.cargo_out_dir("protos")
//.out_dir("src/modules/protos")
.include("../yara-x-proto/src")
.include("../yara-x-proto-yaml/src")
.include("../proto/src")
.include("../proto-yaml/src")
.include("src/modules/protos")
.input("../yara-x-proto/src/yara.proto")
.input("../yara-x-proto-yaml/src/yaml.proto");
.input("../proto/src/yara.proto")
.input("../proto-yaml/src/yaml.proto");

proto_parser
.include("../yara-x-proto/src")
.include("../yara-x-proto-yaml/src")
.include("../proto/src")
.include("../proto-yaml/src")
.include("src/modules/protos");

for entry in fs::read_dir("src/modules/protos").unwrap() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion yara-x/src/scanner/mod.rs → lib/src/scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ pub struct Rule<'a, 'r> {

impl<'a, 'r> Rule<'a, 'r> {
/// Returns the rule's name.
pub fn name(&self) -> &'r str {
pub fn identifier(&self) -> &'r str {
self.rules.ident_pool().get(self.rule_info.ident_id).unwrap()
}

Expand Down
16 changes: 8 additions & 8 deletions yara-x/src/scanner/tests.rs → lib/src/scanner/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ rule rule_4 { condition: false }
let mut iter = results.matching_rules();

assert_eq!(iter.len(), 2);
assert_eq!(iter.next().unwrap().name(), "rule_1");
assert_eq!(iter.next().unwrap().identifier(), "rule_1");
assert_eq!(iter.len(), 1);
assert_eq!(iter.next().unwrap().name(), "rule_3");
assert_eq!(iter.next().unwrap().identifier(), "rule_3");
assert_eq!(iter.len(), 0);
assert!(iter.next().is_none());

let mut iter = results.non_matching_rules();

assert_eq!(iter.len(), 2);
assert_eq!(iter.next().unwrap().name(), "rule_2");
assert_eq!(iter.next().unwrap().identifier(), "rule_2");
assert_eq!(iter.len(), 1);
assert_eq!(iter.next().unwrap().name(), "rule_4");
assert_eq!(iter.next().unwrap().identifier(), "rule_4");
assert_eq!(iter.len(), 0);
assert!(iter.next().is_none());
}
Expand Down Expand Up @@ -372,16 +372,16 @@ fn global_rules() {
assert_eq!(results.matching_rules().len(), 1);

let mut matching = results.matching_rules();
assert_eq!(matching.next().unwrap().name(), "matching");
assert_eq!(matching.next().unwrap().identifier(), "matching");
assert!(matching.next().is_none());

let mut non_matching = results.non_matching_rules();

// `global_true` and `non_matching` don't match because they are in the
// namespace as `global_false`.
assert_eq!(non_matching.next().unwrap().name(), "global_true");
assert_eq!(non_matching.next().unwrap().name(), "non_matching");
assert_eq!(non_matching.next().unwrap().name(), "global_false");
assert_eq!(non_matching.next().unwrap().identifier(), "global_true");
assert_eq!(non_matching.next().unwrap().identifier(), "non_matching");
assert_eq!(non_matching.next().unwrap().identifier(), "global_false");

assert!(non_matching.next().is_none());
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c8af699

Please sign in to comment.