Skip to content

Commit be760c4

Browse files
author
Detection Testing Service
committed
test:conflict resolved
2 parents a2b6fff + ff33193 commit be760c4

630 files changed

Lines changed: 946513 additions & 957067 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build-and-validate.yml‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,19 @@ jobs:
147147
source venv/bin/activate
148148
python3 contentctl.py --path . --verbose generate --product ESCU --output dist/escu
149149
python3 contentctl.py --path . --verbose generate --product SAAWS --output dist/saaws
150-
python3 contentctl.py --path . --verbose generate --product DevSecOps --output dist/devsecops
151150
python3 contentctl.py --path . --verbose generate --product SSA --output dist/ssa
152151
153152
- name: Copy lookups .csv files
154153
run: |
155154
# clean up current lookups
156155
rm -rf dist/escu/lookups
157156
rm -rf dist/saaws/lookups
158-
rm -rf dist/devsecops/lookups
159157
mkdir dist/escu/lookups
160158
mkdir dist/saaws/lookups
161-
mkdir dist/devsecops/lookups
162159
#copy over lookups
163160
cd lookups
164161
cp -rv *.csv ../dist/escu/lookups
165162
cp -rv *.csv ../dist/saaws/lookups
166-
cp -rv *.csv ../dist/devsecops/lookups
167163
168164
#Tag is '' for non-tagged push and the tag name for a tagged release
169165
- name: Set tag
@@ -203,9 +199,6 @@ jobs:
203199
sed -i "s/version = .*$/version = $CONTENT_VERSION/g" dist/saaws/default/content-version.conf
204200
tar -czf content-pack-build-saaws.tar.gz dist/saaws/*
205201
206-
# update build number and version for devsecops
207-
tar -czf content-pack-build-devsecops.tar.gz dist/devsecops/*
208-
209202
# update build number and version for ssa
210203
tar -czf content-pack-build-ssa.tar.gz dist/ssa/*
211204
@@ -216,7 +209,6 @@ jobs:
216209
path: |
217210
content-pack-build-escu.tar.gz
218211
content-pack-build-saaws.tar.gz
219-
content-pack-build-devsecops.tar.gz
220212
content-pack-build-ssa.tar.gz
221213
222214
@@ -261,17 +253,14 @@ jobs:
261253
cd build
262254
tar -zxf content-pack-build-escu.tar.gz
263255
tar -zxf content-pack-build-saaws.tar.gz
264-
tar -zxf content-pack-build-devsecops.tar.gz
265256
tar -zxf content-pack-build-ssa.tar.gz
266257
267258
mv dist/escu DA-ESS-ContentUpdate
268259
mv dist/saaws DA-ESS_AmazonWebServices_Content
269-
mv dist/devsecops dev_sec_ops_analytics
270260
mv dist/ssa SSA_Content
271261
272262
slim package -o upload DA-ESS-ContentUpdate
273263
slim package -o upload DA-ESS_AmazonWebServices_Content
274-
slim package -o upload dev_sec_ops_analytics
275264
#slim package -o upload SSA_Content
276265
277266
cp upload/DA-ESS-ContentUpdate-*.tar.gz DA-ESS-ContentUpdate-latest.tar.gz
@@ -280,9 +269,6 @@ jobs:
280269
cp upload/DA-ESS_AmazonWebServices_Content-*tar.gz DA-ESS_AmazonWebServices_Content-latest.tar.gz
281270
sha256sum DA-ESS_AmazonWebServices_Content-latest.tar.gz >> checksum.txt
282271
283-
cp upload/dev_sec_ops_analytics-*tar.gz dev_sec_ops_analytics-latest.tar.gz
284-
sha256sum dev_sec_ops_analytics-latest.tar.gz >> checksum.txt
285-
286272
#Do this copy so that we conform as much as possible, and have to make
287273
#as few changes as possible, once we start generating this as a real,
288274
#properly packaged app
@@ -305,7 +291,6 @@ jobs:
305291
path: |
306292
build/DA-ESS-ContentUpdate-latest.tar.gz
307293
build/DA-ESS_AmazonWebServices_Content-latest.tar.gz
308-
build/dev_sec_ops_analytics-latest.tar.gz
309294
build/SSA_Content-latest.tar.gz
310295
build/checksum.txt
311296
@@ -350,7 +335,6 @@ jobs:
350335
#Better not to pass these arguments on the command line, if possible
351336
./appinspect.sh ../ DA-ESS-ContentUpdate-latest.tar.gz "$APPINSPECT_USERNAME" "$APPINSPECT_PASSWORD"
352337
./appinspect.sh ../ DA-ESS_AmazonWebServices_Content-latest.tar.gz "$APPINSPECT_USERNAME" "$APPINSPECT_PASSWORD"
353-
./appinspect.sh ../ dev_sec_ops_analytics-latest.tar.gz "$APPINSPECT_USERNAME" "$APPINSPECT_PASSWORD"
354338
355339
- name: Create report artifact
356340
if: always()

‎.gitlab-ci.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ stages:
1111
- publish_smoketest_runner
1212
- publish_deployer
1313
- smoketest_staging
14+
- publish_build_to_pre_qa
1415

1516

1617
publish_deployer:
@@ -59,3 +60,24 @@ smoketest_staging:
5960
only:
6061
- /^ssa.*$/
6162
- develop
63+
64+
publish_build_to_pre_qa:
65+
stage: publish_build_to_pre_qa
66+
artifacts:
67+
when: always
68+
paths:
69+
- artifacts/*
70+
image: python:3.8-alpine
71+
before_script:
72+
- apk add --update --no-cache make curl bash git
73+
- curl -L https://github.com/screwdriver-cd/gitversion/releases/download/v1.1.1/gitversion_linux_amd64 -o /usr/local/bin/gitversion && chmod +x /usr/local/bin/gitversion
74+
- eval $(ssh-agent -s)
75+
script:
76+
- mkdir -p artifacts
77+
- pip install requests
78+
- python security_content_automation/publish_build_to_pre_qa/publish_build_to_pre_qa.py --version $CI_COMMIT_REF_NAME --builds DA-ESS_AmazonWebServices_Content DA-ESS-ContentUpdate
79+
after_script:
80+
- cp publish_build_to_pre_qa.log artifacts/publish_build_to_pre_qa.log
81+
rules:
82+
- if: '$CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+\.[0-9]$/'
83+
when: always

‎bin/generate.py‎

Lines changed: 60 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,26 @@ def generate_ssa_yaml(detections, TEMPLATE_PATH, OUTPUT_PATH):
104104
# disable yaml pointers https://stackoverflow.com/questions/51272814/python-yaml-dumping-pointer-references
105105
yaml.Dumper.ignore_aliases = lambda *args : True
106106

107+
# wiping old detections for SSA
108+
shutil.rmtree(OUTPUT_PATH + '/detections/*', ignore_errors=True)
109+
107110
for d in detections:
108-
manifest_file = OUTPUT_PATH + '/detections/' + d['name'].lower().replace(" ", "_") + '.yml'
111+
manifest_file = OUTPUT_PATH + '/detections/ssa___' + d['name'].lower().replace(" ", "_") + '.yml'
109112

110113
# remove unused fields
111114
del d['risk']
112115
del d['deployment']
113116
del d['mappings']
114117
del d['savedsearch_annotations']
115118

119+
# add detection test
120+
test_file = 'ssa___' + d['name'].lower().replace(" ", "_") + '.test.yml'
121+
for file in glob.glob('tests/*/*'):
122+
if test_file == file.split("/")[-1]:
123+
with open(file, 'r') as file:
124+
test_yaml = yaml.safe_load(file)
125+
d['test'] = test_yaml
126+
116127
with open(manifest_file, 'w') as file:
117128
documents = yaml.dump(d, file, sort_keys=True)
118129

@@ -414,7 +425,6 @@ def add_playbook(detection, playbooks):
414425
if detection['name'] in playbook['tags']['detections']:
415426
detection['how_to_implement'] = detection['how_to_implement'] + preface + playbook['name']
416427
except KeyError:
417-
print("playbook " + playbook['name'] + " has no detections, passing....")
418428
pass
419429
return detection
420430

@@ -664,6 +674,43 @@ def main(REPO_PATH, OUTPUT_PATH, PRODUCT, VERBOSE):
664674
global global_product
665675
global_product = PRODUCT
666676

677+
TEMPLATE_PATH = path.join(REPO_PATH, 'bin/jinja2_templates')
678+
679+
objects = get_objects(REPO_PATH, OUTPUT_PATH, PRODUCT, VERBOSE)
680+
681+
try:
682+
if VERBOSE:
683+
print("generating Mitre lookups")
684+
# generate_mitre_lookup(OUTPUT_PATH)
685+
except Exception as e:
686+
print('Error: ' + str(e))
687+
print("WARNING: Generation of Mitre lookup failed.")
688+
689+
# calculate deprecation totals
690+
deprecated = []
691+
for d in objects['detections']:
692+
if 'deprecated' in d:
693+
deprecated.append(d)
694+
695+
detection_path = ''
696+
lookups_path = ''
697+
lookups_files= ''
698+
use_case_lib_path = ''
699+
macros_path = ''
700+
workbench_panels_objects = ''
701+
702+
if global_product == 'SSA':
703+
detection_path = generate_ssa_yaml(objects["detections"], TEMPLATE_PATH, OUTPUT_PATH)
704+
objects["macros"] = []
705+
else:
706+
detection_path = generate_savedsearches_conf(objects["detections"], objects["deployments"], TEMPLATE_PATH, OUTPUT_PATH)
707+
lookups_path = generate_transforms_conf(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH)
708+
lookups_path = generate_collections_conf(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH)
709+
lookups_files = generate_lookup_files(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH,REPO_PATH)
710+
use_case_lib_path = generate_use_case_library_conf(objects["stories"], objects["detections"], TEMPLATE_PATH, OUTPUT_PATH)
711+
macros_path = generate_macros_conf(objects["macros"], objects["detections"], TEMPLATE_PATH, OUTPUT_PATH)
712+
workbench_panels_objects = generate_workbench_panels(objects["detections"], objects["stories"], TEMPLATE_PATH, OUTPUT_PATH)
713+
667714
if global_product == 'API':
668715
json_types = []
669716
# List of all YAML types to search in repo
@@ -673,63 +720,25 @@ def main(REPO_PATH, OUTPUT_PATH, PRODUCT, VERBOSE):
673720
if VERBOSE: print("JSON output directory: " + output_dir)
674721
# remove any pre-existing output directories
675722
shutil.rmtree(output_dir, ignore_errors=True)
676-
if VERBOSE: print("Remove pre-existing JSON directory")
723+
if VERBOSE: print("remove pre-existing JSON directory")
677724
# create output directory
678725
os.mkdir(output_dir)
679-
if VERBOSE: print("Created output directory")
726+
if VERBOSE: print("created output directory")
680727
# Generate all YAML types
681728
for yt in yml_types:
682729
processor = Yaml2Json(yt, REPO_PATH)
683730
with open(os.path.join(output_dir, yt + '.json'), 'w') as json_out:
684731
# write out YAML type
685732
json.dump(processor.list_objects(yt), json_out)
686-
if VERBOSE: print("Writing %s JSON" % yt)
687-
688-
else:
689-
TEMPLATE_PATH = path.join(REPO_PATH, 'bin/jinja2_templates')
690-
691-
objects = get_objects(REPO_PATH, OUTPUT_PATH, PRODUCT, VERBOSE)
692-
693-
try:
694-
if VERBOSE:
695-
print("generating Mitre lookups")
696-
# generate_mitre_lookup(OUTPUT_PATH)
697-
except Exception as e:
698-
print('Error: ' + str(e))
699-
print("WARNING: Generation of Mitre lookup failed.")
700-
701-
# calculate deprecation totals
702-
deprecated = []
703-
for d in objects['detections']:
704-
if 'deprecated' in d:
705-
deprecated.append(d)
706-
707-
detection_path = ''
708-
lookups_path = ''
709-
lookups_files= ''
710-
use_case_lib_path = ''
711-
macros_path = ''
712-
workbench_panels_objects = ''
713-
714-
if global_product == 'SSA':
715-
detection_path = generate_ssa_yaml(objects["detections"], TEMPLATE_PATH, OUTPUT_PATH)
716-
objects["macros"] = []
717-
else:
718-
detection_path = generate_savedsearches_conf(objects["detections"], objects["deployments"], TEMPLATE_PATH, OUTPUT_PATH)
719-
lookups_path = generate_transforms_conf(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH)
720-
lookups_path = generate_collections_conf(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH)
721-
lookups_files = generate_lookup_files(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH,REPO_PATH)
722-
use_case_lib_path = generate_use_case_library_conf(objects["stories"], objects["detections"], TEMPLATE_PATH, OUTPUT_PATH)
723-
macros_path = generate_macros_conf(objects["macros"], objects["detections"], TEMPLATE_PATH, OUTPUT_PATH)
724-
workbench_panels_objects = generate_workbench_panels(objects["detections"], objects["stories"], TEMPLATE_PATH, OUTPUT_PATH)
725-
726-
if VERBOSE:
727-
print("{0} stories have been successfully written to {1}".format(len(objects["stories"]), use_case_lib_path))
728-
print("{0} detections have been successfully written to {1}".format(len(objects["detections"]), detection_path))
729-
print("{0} detections have been marked deprecated on {1}".format(len(deprecated), detection_path))
730-
print("{0} macros have been successfully written to {1}".format(len(objects["macros"]), macros_path))
731-
print("{0} workbench panels have been successfully written to {1}, {2} and {3}".format(len(workbench_panels_objects), OUTPUT_PATH + "/default/es_investigations.conf", OUTPUT_PATH + "/default/workflow_actions.conf", OUTPUT_PATH + "/default/data/ui/panels/*"))
732-
print("security content generation completed..")
733+
if VERBOSE: print("writing {0} JSON".format(yt))
734+
735+
if VERBOSE:
736+
print("{0} stories have been successfully written to {1}".format(len(objects["stories"]), use_case_lib_path))
737+
print("{0} detections have been successfully written to {1}".format(len(objects["detections"]), detection_path))
738+
print("{0} detections have been marked deprecated on {1}".format(len(deprecated), detection_path))
739+
print("{0} macros have been successfully written to {1}".format(len(objects["macros"]), macros_path))
740+
print("{0} workbench panels have been successfully written to {1}, {2} and {3}".format(len(workbench_panels_objects), OUTPUT_PATH + "/default/es_investigations.conf", OUTPUT_PATH + "/default/workflow_actions.conf", OUTPUT_PATH + "/default/data/ui/panels/*"))
741+
print("security content generation completed..")
733742

734743

735744
if __name__ == "__main__":

‎bin/jinja2_templates/detection.j2‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ tags:
4949
{% for observable in observables -%}
5050
- {{observable}}
5151
{% endfor -%}
52+
nist:
53+
-
54+
cis20:
55+
-

‎bin/jinja2_templates/doc_playbooks.j2‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tags:
3939
{{ playbook.how_to_implement}}
4040

4141
#### Playbooks
42-
![](https://raw.githubusercontent.com/splunk/security_content/develop/playbooks/{{ playbook.name | lower | replace(" ", "_")}}.png)
42+
![](https://raw.githubusercontent.com/splunk/security_content/develop/playbooks/{{ playbook.playbook | lower | replace(" ", "_")}}.png)
4343

4444
#### Required field
4545
{% for field in playbook.tags.playbook_fields -%}
@@ -54,4 +54,4 @@ tags:
5454
{% endif %}
5555

5656

57-
[*source*](https://github.com/splunk/security_content/tree/develop/playbooks/{{ playbook.name | lower | replace (" ", "_") }}.yml) \| *version*: **{{playbook.version}}**
57+
[*source*](https://github.com/splunk/security_content/tree/develop/playbooks/{{ playbook.playbook | lower | replace (" ", "_") }}.yml) \| *version*: **{{playbook.version}}**

0 commit comments

Comments
 (0)