Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scripts/gen_ram_slim.py so that it can handle redirects configs #191

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions scripts/gen_ram_slim.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,27 @@ def gen_slim(self, priority_file=None):
definitions = findings.root_definitions.get("definitions", {})
if "modules" not in definitions:
continue
# remove all types other than `modules`

# remove all types other than `modules` and `collections`
# NOTE: `collections` are necessary to register `redirects` to module_index
# but it should be removed later
definitions = {
"modules": definitions["modules"],
"collections": definitions["collections"],
}
findings.root_definitions["definitions"] = definitions
findings.ext_definitions = {}

# register modules and redirects to module_index
ram_client.register_indices_to_ram(findings=findings)
# remove `collections` here
findings.root_definitions["definitions"].pop("collections")

relative_path = f_json.replace(self.ram_all_dir, "").strip("/")
dest_path = os.path.join(self.ram_slim_dir, relative_path)
dest_dir = os.path.dirname(dest_path)
os.makedirs(dest_dir, exist_ok=True)
findings.dump(fpath=dest_path)
ram_client.register_indices_to_ram(findings=findings)

def copy_priority_file(self, priority_file=None):
if not priority_file:
Expand Down
Loading