mirror of
https://github.com/Yamato-Security/WELA.git
synced 2025-12-06 17:22:50 +01:00
add rule parser actions
This commit is contained in:
21
.github/workflows/create-rule-meta.yml
vendored
Normal file
21
.github/workflows/create-rule-meta.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: create-rule-meta.json
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout self repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout hayabusa-rules
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: Yamato-Security/hayabusa-rules
|
||||
path: hayabusa-rules
|
||||
|
||||
- name: Run
|
||||
run: cd wela-extractor && cargo run --release -- ../../hayabusa-rules ../config/eid_subcategory_mapping-org.csv ../config/hayabusa-rule-meta.json
|
||||
@@ -108,18 +108,20 @@ fn load_event_id_guid_pairs(file_path: &str) -> Result<Vec<(String, String)>, Bo
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 3 {
|
||||
if args.len() != 4 {
|
||||
eprintln!("Usage: {} <file_path> <dir>", args[0]);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let file_path = &args[1];
|
||||
let eid_subcategory_pair = load_event_id_guid_pairs(file_path).unwrap();
|
||||
let eid_subcategory_pair = load_event_id_guid_pairs(file_path)?;
|
||||
|
||||
let dir = &args[2];
|
||||
let yml_files = list_yml_files(dir);
|
||||
let mut results = Vec::new();
|
||||
|
||||
let out = &args[3];
|
||||
|
||||
for file in yml_files {
|
||||
let contents = fs::read_to_string(&file).expect("Unable to read file");
|
||||
let docs = YamlLoader::load_from_str(&contents).expect("Unable to parse YAML");
|
||||
@@ -131,6 +133,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
let json_output = serde_json::to_string_pretty(&results)?;
|
||||
write("../config/hayabusa_rules_meta.json", json_output)?;
|
||||
println!("{}", json_output);
|
||||
write(out, json_output)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user