1- import shutil
21import os
32import pathlib
3+ import shutil
4+
5+ from contentctl .objects .baseline import Baseline
46from contentctl .objects .config import test
7+ from contentctl .objects .dashboard import Dashboard
8+ from contentctl .objects .data_source import DataSource
9+ from contentctl .objects .deployment import Deployment
10+ from contentctl .objects .detection import Detection
11+ from contentctl .objects .investigation import Investigation
12+ from contentctl .objects .lookup import Lookup
13+ from contentctl .objects .macro import Macro
14+ from contentctl .objects .playbook import Playbook
15+ from contentctl .objects .removed_security_content_object import (
16+ RemovedSecurityContentObject ,
17+ )
18+ from contentctl .objects .story import Story
519from contentctl .output .yml_writer import YmlWriter
620
721
@@ -13,21 +27,33 @@ def execute(self, config: test) -> None:
1327
1428 YmlWriter .writeYmlFile (str (config .path / "contentctl.yml" ), config .model_dump ())
1529
16- # Create the following empty directories:
30+ # Create the following empty directories. Each type of content,
31+ # even if you don't have any of that type of content, need its own directory to exist.
32+ for contentType in [
33+ Detection ,
34+ Playbook ,
35+ Story ,
36+ DataSource ,
37+ Investigation ,
38+ Macro ,
39+ Lookup ,
40+ Dashboard ,
41+ Baseline ,
42+ Deployment ,
43+ RemovedSecurityContentObject ,
44+ ]:
45+ contentType .containing_folder ().mkdir (exist_ok = False , parents = True )
46+
47+ # Some other directories that do not map directly to a piece of content also must exist
48+
1749 for emptyDir in [
18- "lookups" ,
19- "baselines" ,
20- "data_sources" ,
2150 "docs" ,
2251 "reporting" ,
23- "investigations" ,
2452 "detections/application" ,
2553 "detections/cloud" ,
2654 "detections/endpoint" ,
2755 "detections/network" ,
2856 "detections/web" ,
29- "macros" ,
30- "stories" ,
3157 ]:
3258 # Throw an error if this directory already exists
3359 (config .path / emptyDir ).mkdir (exist_ok = False , parents = True )
@@ -60,7 +86,7 @@ def execute(self, config: test) -> None:
6086 source_directory = pathlib .Path (os .path .dirname (__file__ )) / templateDir
6187 target_directory = config .path / targetDir
6288 # Throw an exception if the target exists
63- shutil .copytree (source_directory , target_directory , dirs_exist_ok = False )
89+ shutil .copytree (source_directory , target_directory , dirs_exist_ok = True )
6490
6591 # Create a README.md file. Note that this is the README.md for the repository, not the
6692 # one which will actually be packaged into the app. That is located in the app_template folder.
0 commit comments