Skip to content

Commit

Permalink
fix scripts/gen_ram_slim.py so that it can handle redirects configs (#…
Browse files Browse the repository at this point in the history
…191)

* update scripts/gen_ram_slim.py

Signed-off-by: hirokuni-kitahara <[email protected]>

* remove unncessary codes

Signed-off-by: hirokuni-kitahara <[email protected]>

---------

Signed-off-by: hirokuni-kitahara <[email protected]>
  • Loading branch information
hirokuni-kitahara authored Sep 28, 2023
1 parent 51baac1 commit a4962b0
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit a4962b0

Please sign in to comment.