Skip to content

Commit

Permalink
fixing broken utilities (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
himynamesdave authored Dec 11, 2024
1 parent 95f211d commit 11f4584
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 36 deletions.
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Where:
* `insert_archive_atlas.py`

* `--database` (required): is the name of the Arango database the objects should be stored in. If database does not exist, stix2arango will create it
* `--ignore_embedded_relationships` (optional): boolean, if `True` passed, this will stop any embedded relationships from being generated. Default is `False`
* `--ignore_embedded_relationships` (optional): if flag passed this will stop any embedded relationships from being generated.
* `--versions` (optional): are one or more of the versions listed in each script. e.g. for `insert_archive_disarm.py` are currently `1_2`, `1_3`, `1_4`. If no `version` flag is passed, all listed versions will be downloaded. IMPORTANT: flag does not work with `insert_archive_cve.py` and `insert_archive_cpe.py`

e.g.
Expand All @@ -34,7 +34,7 @@ Download and insert all versions of MITRE ATT&CK Enterprise
```shell
python3 utilities/arango_cti_processor/insert_archive_attack_enterprise.py \
--database cti_knowledge_base_store \
--ignore_embedded_relationships True
--ignore_embedded_relationships true
```

Download specific versions of MITRE ATT&CK Enterprise and ignore embedded relationships
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def parse_arguments():
parser = argparse.ArgumentParser(description="Process MITRE ATT&CK versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 1_0,2_0). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -49,7 +49,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def parse_arguments():
parser = argparse.ArgumentParser(description="Process MITRE ATT&CK versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 1_0,2_0). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -52,7 +52,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_attack_ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def parse_arguments():
parser = argparse.ArgumentParser(description="Process MITRE ATT&CK ICS versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 8_0,9_0). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -51,7 +51,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def version_key(version):
def parse_arguments():
parser = argparse.ArgumentParser(description="Process MITRE ATT&CK Mobile versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 1_0,2_0). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -57,7 +57,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_capec.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def version_key(version):
def parse_arguments():
parser = argparse.ArgumentParser(description="Process MITRE CAPEC versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 3_5,3_6). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -58,7 +58,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_cwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def version_key(version):
def parse_arguments():
parser = argparse.ArgumentParser(description="Process MITRE CWE versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 4_5,4_6). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -65,7 +65,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_disarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def version_key(version):
def parse_arguments():
parser = argparse.ArgumentParser(description="Process DISARM versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 1_2,1_3). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -57,7 +57,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def version_key(version):
def parse_arguments():
parser = argparse.ArgumentParser(description="Process location versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -54,7 +54,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_sigma_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def version_key(version):
def parse_arguments():
parser = argparse.ArgumentParser(description="Process SIGMA rules versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 2023-08-24,2023-10-09). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -71,7 +71,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_tlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def parse_arguments():
parser = argparse.ArgumentParser(description="Process MITRE ATT&CK versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 1_0,2_0). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -49,7 +49,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions utilities/arango_cti_processor/insert_archive_yara_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def version_key(version):
def parse_arguments():
parser = argparse.ArgumentParser(description="Process YARA rules versions.")
parser.add_argument('--versions', type=str, help='Comma-separated list of versions to process (e.g., 0f93570). Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
return parser.parse_args()

Expand Down Expand Up @@ -54,7 +54,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--database", command["database"],
"--collection", command["collection"],
"--stix2arango_note", command.get("stix2arango_note", ""),
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down
16 changes: 13 additions & 3 deletions utilities/arango_cve_processor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Where:
* `insert_archive_cve.py`
* `insert_archive_cpe.py` (ARCHIVED -- logic now exists in [cpe2stix](https://github.com/muchdogesec/cpe2stix), and thus these objects are now imported via `insert_archive_cve.py`))
* `--database` (required): is the name of the Arango database the objects should be stored in. If database does not exist, stix2arango will create it
* `--ignore_embedded_relationships` (optional): boolean, if `True` passed, this will stop any embedded relationships from being generated. Default is `false`
* `--ignore_embedded_relationships` (optional): if flag passes this will stop any embedded relationships from being generated
* `--years` (optional): the years for which you want CPE and CVE data separated by a comma (e.g. `2024,2023)`. If no `years` flag is passed, all available years will be downloaded. IMPORTANT: flag only works with `insert_archive_cve.py` and `insert_archive_cpe.py`

e.g.
Expand All @@ -24,15 +24,25 @@ Download all CVE data
```shell
python3 utilities/arango_cve_processor/insert_archive_cve.py \
--database cti_knowledge_base_store \
--ignore_embedded_relationships True
--ignore_embedded_relationships
```

Download only CVE data for year 2023 and 2024

```shell
python3 utilities/arango_cve_processor/insert_archive_cve.py \
--database cti_knowledge_base_store \
--years 2023,2024
--years 2023,2024 \
--ignore_embedded_relationships
```

Download only CPE data for 2024

```shell
python3 utilities/arango_cve_processor/insert_archive_cpe.py \
--database cti_knowledge_base_store \
--years 2024 \
--ignore_embedded_relationships
```

#### A note on CVE and CPE data
Expand Down
8 changes: 4 additions & 4 deletions utilities/arango_cve_processor/insert_archive_cpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
def parse_arguments():
parser = argparse.ArgumentParser(description="Process NVD CPE versions.")
parser.add_argument('--years', type=str, help='Comma-separated list of years to process. Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti_knowledge_base_store".')
return parser.parse_args()

def create_directory(path):
Expand Down Expand Up @@ -89,7 +89,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--file", file_path,
"--database", command["database"],
"--collection", command["collection"],
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True, cwd=stix2arango_dir)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down Expand Up @@ -165,4 +165,4 @@ def main():
print(error)

if __name__ == "__main__":
main()
main()
9 changes: 4 additions & 5 deletions utilities/arango_cve_processor/insert_archive_cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
def parse_arguments():
parser = argparse.ArgumentParser(description="Process NVD CVE versions.")
parser.add_argument('--years', type=str, help='Comma-separated list of years to process. Default is all versions.')
parser.add_argument('--ignore_embedded_relationships', type=bool, default=False, help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti".')
parser.add_argument('--ignore_embedded_relationships', action='store_true', help='Flag to ignore embedded relationships. Default is false.')
parser.add_argument('--database', type=str, default="cti_knowledge_base_store", help='Name of the database to use. Default is "cti_knowledge_base_store".')
return parser.parse_args()

def create_directory(path):
Expand Down Expand Up @@ -89,7 +89,7 @@ def run_command(command, root_path, ignore_embedded_relationships):
"--file", file_path,
"--database", command["database"],
"--collection", command["collection"],
"--ignore_embedded_relationships", str(ignore_embedded_relationships).lower()
"--ignore_embedded_relationships", str(ignore_embedded_relationships)
], check=True, cwd=stix2arango_dir)
print(f"Successfully processed {file_path}")
except subprocess.CalledProcessError as e:
Expand Down Expand Up @@ -164,5 +164,4 @@ def main():
print(error)

if __name__ == "__main__":
main()

main()

0 comments on commit 11f4584

Please sign in to comment.