Skip to content

Commit d94aa7b

Browse files
authored
Merge pull request #162 from splunk/init_update
fleshing out init dirs
2 parents 1b7470c + 86088c8 commit d94aa7b

File tree

9 files changed

+15
-10
lines changed

9 files changed

+15
-10
lines changed

contentctl/actions/new_content.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,21 @@ def buildDetection(self)->dict[str,Any]:
1919
answers = questionary.prompt(questions)
2020
answers.update(answers)
2121
answers['name'] = answers['detection_name']
22+
del answers['detection_name']
2223
answers['id'] = str(uuid.uuid4())
2324
answers['version'] = 1
2425
answers['date'] = datetime.today().strftime('%Y-%m-%d')
2526
answers['author'] = answers['detection_author']
27+
del answers['detection_author']
2628
answers['data_source'] = answers['data_source']
2729
answers['type'] = answers['detection_type']
30+
del answers['detection_type']
2831
answers['status'] = "production" #start everything as production since that's what we INTEND the content to become
2932
answers['description'] = 'UPDATE_DESCRIPTION'
3033
file_name = answers['name'].replace(' ', '_').replace('-','_').replace('.','_').replace('/','_').lower()
34+
answers['kind'] = answers['detection_kind']
3135
answers['search'] = answers['detection_search'] + ' | `' + file_name + '_filter`'
36+
del answers['detection_search']
3237
answers['how_to_implement'] = 'UPDATE_HOW_TO_IMPLEMENT'
3338
answers['known_false_positives'] = 'UPDATE_KNOWN_FALSE_POSITIVES'
3439
answers['references'] = ['REFERENCE']
@@ -52,7 +57,7 @@ def buildDetection(self)->dict[str,Any]:
5257
'name': "True Positive Test",
5358
'attack_data': [
5459
{
55-
'data': "Enter URL for Dataset Here. This may also be a relative or absolute path on your local system for testing.",
60+
'data': "https://github.com/splunk/contentctl/wiki",
5661
"sourcetype": "UPDATE SOURCETYPE",
5762
"source": "UPDATE SOURCE"
5863
}
@@ -65,32 +70,35 @@ def buildStory(self)->dict[str,Any]:
6570
questions = NewContentQuestions.get_questions_story()
6671
answers = questionary.prompt(questions)
6772
answers['name'] = answers['story_name']
73+
del answers['story_name']
6874
answers['id'] = str(uuid.uuid4())
6975
answers['version'] = 1
7076
answers['date'] = datetime.today().strftime('%Y-%m-%d')
7177
answers['author'] = answers['story_author']
78+
del answers['story_author']
7279
answers['description'] = 'UPDATE_DESCRIPTION'
7380
answers['narrative'] = 'UPDATE_NARRATIVE'
7481
answers['references'] = []
7582
answers['tags'] = dict()
76-
answers['tags']['analytic_story'] = answers['name']
7783
answers['tags']['category'] = answers['category']
84+
del answers['category']
7885
answers['tags']['product'] = ['Splunk Enterprise','Splunk Enterprise Security','Splunk Cloud']
7986
answers['tags']['usecase'] = answers['usecase']
87+
del answers['usecase']
8088
answers['tags']['cve'] = ['UPDATE WITH CVE(S) IF APPLICABLE']
8189
return answers
8290

8391

8492
def execute(self, input_dto: new) -> None:
8593
if input_dto.type == NewContentType.detection:
8694
content_dict = self.buildDetection()
87-
subdirectory = pathlib.Path('detections') / content_dict.get('type')
95+
subdirectory = pathlib.Path('detections') / content_dict.pop('detection_kind')
8896
elif input_dto.type == NewContentType.story:
8997
content_dict = self.buildStory()
9098
subdirectory = pathlib.Path('stories')
9199
else:
92100
raise Exception(f"Unsupported new content type: [{input_dto.type}]")
93-
101+
94102
full_output_path = input_dto.path / subdirectory / SecurityContentObject_Abstract.contentNameToFileName(content_dict.get('name'))
95103
YmlWriter.writeYmlFile(str(full_output_path), content_dict)
96104

contentctl/input/new_content_questions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ def get_questions_detection(self) -> list:
2727
'message': 'enter author name',
2828
'name': 'detection_author',
2929
},
30-
{
31-
"type": "text",
32-
"message": "enter author name",
33-
"name": "detection_author",
34-
},
3530
{
3631
"type": "select",
3732
"message": "select a detection type",

contentctl/objects/story_tags.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class StoryUseCase(str,Enum):
1414
APPLICATION_SECURITY = "Application Security"
1515
SECURITY_MONITORING = "Security Monitoring"
1616
ADVANCED_THREAD_DETECTION = "Advanced Threat Detection"
17+
INSIDER_THREAT = "Insider Threat"
18+
OTHER = "Other"
1719

1820
class StoryTags(BaseModel):
1921
model_config = ConfigDict(extra='forbid', use_enum_values=True)

contentctl/templates/detections/application/.gitkeep

Whitespace-only changes.

contentctl/templates/detections/cloud/.gitkeep

Whitespace-only changes.
File renamed without changes.

contentctl/templates/detections/network/.gitkeep

Whitespace-only changes.

contentctl/templates/detections/web/.gitkeep

Whitespace-only changes.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "contentctl"
3-
version = "4.0.4"
3+
version = "4.0.5"
44
description = "Splunk Content Control Tool"
55
authors = ["STRT <[email protected]>"]
66
license = "Apache 2.0"

0 commit comments

Comments
 (0)