Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
52c8023
Added support for enumerating all of the different actions
pyth0n1c Apr 29, 2022
3c5a342
Better support in contentctl and content_changer for updating yml fil…
pyth0n1c Apr 29, 2022
710b582
Added an option for all, meaning that all of the transforms \(besides…
pyth0n1c Apr 29, 2022
f81a103
Added the majority of support for offline and cached mode for content…
pyth0n1c Apr 29, 2022
31149c3
More changes to defaults and argument parsing to support offline and …
pyth0n1c Apr 30, 2022
03035d1
Enhancement to use threaded detection construction, which really spee…
pyth0n1c May 2, 2022
578e6bb
Updated a very large number of detections whose references were retur…
pyth0n1c May 3, 2022
646afbf
A number of small updates to support resolving and verifying all of t…
pyth0n1c May 3, 2022
900bd9e
Updated a large number of the links in other detections. Also, adjus…
pyth0n1c May 3, 2022
bc7a22a
Fixed reference links in two more detection YMLs
pyth0n1c May 3, 2022
ee8c0b9
Fixed the remaining broken or outdated references. The remaining ref…
pyth0n1c May 3, 2022
0957d0d
Updates to the detection ref validator. Still needs a few tweaks.
pyth0n1c May 3, 2022
c0dc854
Added a class for validating links. This class performs its own type…
pyth0n1c May 4, 2022
5479818
Saving changes made to support URL verification which is working - bu…
pyth0n1c May 4, 2022
b60db04
Added link validator code to baselines, detections,
pyth0n1c May 4, 2022
d814d4d
Added link validation to playbooks and
pyth0n1c May 5, 2022
c1ab5a4
Added check_references passthrough
pyth0n1c May 5, 2022
67a0ed2
Removed some un needed prints from Link Validator. Added progress in…
pyth0n1c May 10, 2022
6e6c7f5
More finishing touches on link validation. Now, failures are printed…
pyth0n1c May 10, 2022
cdb66ae
More optimizations in content_ctl. No longer generate ba_factory or f…
pyth0n1c May 10, 2022
e7580fa
Added caching of the results of link-verification to the --cached_and…
pyth0n1c May 11, 2022
bf27f47
Moved from using a pickled dictionary, loaded and written manually, t…
pyth0n1c May 11, 2022
fa9179f
Added the shelve/shelf functionality to the CVE Enrichment Cache as w…
pyth0n1c May 11, 2022
926317f
Updated status print information around the
pyth0n1c May 13, 2022
38d32c3
Branch was auto-updated.
pyth0n1c May 16, 2022
1a2d046
Branch was auto-updated.
pyth0n1c May 16, 2022
dd922ba
Branch was auto-updated.
pyth0n1c May 16, 2022
2557d21
Branch was auto-updated.
pyth0n1c May 16, 2022
dc67162
Branch was auto-updated.
pyth0n1c May 16, 2022
0591cf4
Branch was auto-updated.
pyth0n1c May 16, 2022
76c039f
Branch was auto-updated.
pyth0n1c May 17, 2022
3621262
Branch was auto-updated.
pyth0n1c May 17, 2022
f47a96e
Branch was auto-updated.
pyth0n1c May 18, 2022
b9f95d6
Branch was auto-updated.
pyth0n1c May 18, 2022
c16ccc1
Branch was auto-updated.
pyth0n1c May 20, 2022
36ca496
Branch was auto-updated.
pyth0n1c May 20, 2022
f75eee1
Branch was auto-updated.
pyth0n1c May 23, 2022
93b8f5c
Branch was auto-updated.
pyth0n1c May 23, 2022
31db06e
Branch was auto-updated.
pyth0n1c May 23, 2022
79289e9
Branch was auto-updated.
pyth0n1c May 23, 2022
a74ebee
Added the --skip_enrichment option to the
pyth0n1c Jun 22, 2022
130f5e3
Simplified the build-and-validate
pyth0n1c Jun 22, 2022
4f6d30d
Fixes to needs dependencies
pyth0n1c Jun 22, 2022
d858cd6
included the --skip_enrichment flag
pyth0n1c Jun 22, 2022
82af76d
Added ability to add or remove
pyth0n1c Jun 23, 2022
b7955f8
Typo naming new variable
pyth0n1c Jun 23, 2022
a133549
Fixing a call to content_ctl
pyth0n1c Jun 23, 2022
d40ca09
Merged develop into content_changer_improvements to resolve merge con…
pyth0n1c Jun 23, 2022
4931458
Updated one broken reference link.
pyth0n1c Jun 23, 2022
0181c9f
Update the docker detection testing code
pyth0n1c Jun 23, 2022
050491a
Forgot to include a print statement, causing
pyth0n1c Jun 23, 2022
e818a0d
Fixing print statement that was
pyth0n1c Jun 23, 2022
f5ec4b0
Branch was auto-updated.
pyth0n1c Jun 24, 2022
f75b406
Suppress output of contentctl in CI/CD
pyth0n1c Jun 28, 2022
27417d7
Suppress more output for
pyth0n1c Jun 28, 2022
a11c62e
Branch was auto-updated.
pyth0n1c Jun 28, 2022
ea26b98
Branch was auto-updated.
pyth0n1c Jun 28, 2022
6cfa201
Remove ambiguity from the git checkout
pyth0n1c Jun 28, 2022
83bbfce
Branch was auto-updated.
pyth0n1c Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 59 additions & 130 deletions .github/workflows/build-and-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,29 @@ jobs:
exit 0
fi

validate-content:
validate-and-build:
#Note that the CircleCI job used a Container. The way to do this with Github Actions
#is to first start up a Virtual Machine, then we can by following:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainer
runs-on: ubuntu-latest
needs: [validate-tag-if-present]
steps:

- name: Configure Enrichment and Tag
id: vars
run: |
if [ $(echo ${GITHUB_REF} | grep "^refs/tags/*") ]; then
#failed to find the refs/tags/ beginning, grab and set the tag
echo "Release is TAGGED!"
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
echo "::set-output name=skip_enrichment_var::"
else
#Not a tagged relese
echo "Release is NOT TAGGED!"
echo "::set-output name=tag::"
echo "::set-output name=skip_enrichment_var::--skip_enrichment"
fi

#Previous config chose which branch/tag to operate on.
#I think Github is smart enough to choose based on whether it's a pull request or push + other info?
- name: Check out the repository code
Expand All @@ -62,115 +78,60 @@ jobs:
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified


#TODO: CircleCI restore_cache equivalent

#don't need to install python3 or python3-dev since it was handled by the action above?
#Also, no support for YAML anchors/aliases in Github Actions...
- name: Install System Packages
run: |
sudo apt update -qq
sudo apt install jq -qq
#TODO: CircleCI save_cache equivalent


- name: Install Python Dependencies
run: |
#Get the virtualenv set up
rm -rf venv
python3 -m venv --clear venv
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install wheel
python3 -m pip install -q -r requirements.txt
python -m venv --clear .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install wheel
python -m pip install -q -r requirements.txt

- name: run validate
- name: content_ctl validate
run: |
source venv/bin/activate
python3 contentctl.py -p . validate -pr ESCU
python3 contentctl.py -p . validate -pr SSA


# - name: Get CTI Repo for Mitre context
# uses: actions/checkout@v2
# with:
# repository: mitre/cti #check out https://github.com/mitre/cti.git, defaults to HEAD
# path: "cti/"
source .venv/bin/activate
python contentctl.py -p . ${{ steps.vars.outputs.skip_enrichment_var }} validate -pr ESCU > /dev/null
python contentctl.py -p . ${{ steps.vars.outputs.skip_enrichment_var }} validate -pr SSA > /dev/null


#Now generate the documentation (uses Node)
- uses: actions/setup-node@v2
with:
node-version: '14' #can easily be changed to a different version

- name: Generate documentation
- name: contentctl docgen
run: |
ls -lah
#Enter the virtualenv and run the docgen
source venv/bin/activate
python3 contentctl.py -p . docgen -o docs
source .venv/bin/activate
python contentctl.py -p . --skip_enrichment docgen -o docs
#Now generate the spec docs
npm install -g @adobe/jsonschema2md
jsonschema2md -d spec -o docs/spec -f yaml -e spec.json -x -
#Clean up extra properties on docs
rm -rf docs/spec/*-*.md
echo "****** BRANCH INFORMATION ******"
git branch
git branch --show-current

build-sources:
runs-on: ubuntu-latest
needs: validate-content
steps:
- name: Checkout Repo
uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.9' #Available versions here - https://github.com/actions/python-versions/releases easy to change/make a matrix/use pypy
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified

- name: Install System Packages
run: |
sudo apt update -qq
sudo apt install jq -qq

- name: Install Python Dependencies
- name: contentctl generate
run: |
#Get the virtualenv set up
rm -rf venv
python3 -m venv --clear venv
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install wheel
python3 -m pip install -q -r requirements.txt

- name: Run Generate
run: |
source venv/bin/activate
source .venv/bin/activate
rm -rf dist/escu/default/data/ui/panels/*.xml
python3 contentctl.py --path . generate --product ESCU --output dist/escu
python3 contentctl.py --path . generate --product SSA --output dist/ssa
python contentctl.py --path . ${{ steps.vars.outputs.skip_enrichment_var }} generate --product ESCU --output dist/escu > /dev/null
python contentctl.py --path . ${{ steps.vars.outputs.skip_enrichment_var }} generate --product SSA --output dist/ssa > /dev/null

- name: Copy lookups .mlmodel files
run: |
cd lookups
count=`ls -1 *.mlmodel 2>/dev/null | wc -l`
if [ $count != 0 ]
then cp -rv *.mlmodel ../dist/escu/lookups
else echo "No mlmodel files to copy"
fi

#Tag is '' for non-tagged push and the tag name for a tagged release
- name: Set tag
id: vars
run: |
if [ $(echo ${GITHUB_REF} | grep "^refs/tags/*") ]; then
#failed to find the refs/tags/ beginning, grab and set the tag
echo "Release is TAGGED!"
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
else
#Not a tagged relese
echo "Release is NOT TAGGED!"
echo "::set-output name=tag::"
then
cp -rv *.mlmodel ../dist/escu/lookups
else
echo "No mlmodel files to copy"
fi

- name: Update Version and Build number
Expand All @@ -188,57 +149,24 @@ jobs:
sed -i "s/^version = .*$/version = $CONTENT_VERSION/g" dist/escu/default/app.conf
sed -i "s/\"version\": .*$/\"version\": \"$CONTENT_VERSION\"/g" dist/escu/app.manifest
sed -i "s/version = .*$/version = $CONTENT_VERSION/g" dist/escu/default/content-version.conf
tar -czf content-pack-build-escu.tar.gz dist/escu/*
mkdir build
tar -czf build/content-pack-build-escu.tar.gz dist/escu/*
# update build number and version for ssa
tar -czf content-pack-build-ssa.tar.gz dist/ssa/*

- name: Persist to Workspace
uses: actions/upload-artifact@v2
with:
name: content-pack-build
path: |
content-pack-build-escu.tar.gz
content-pack-build-ssa.tar.gz

build-package:
runs-on: ubuntu-latest
needs: [validate-content, build-sources]

steps:
- uses: actions/download-artifact@v2
with:
name: content-pack-build
path: build/

#This explicitly uses a different version of python (2.7)
- uses: actions/setup-python@v2
with:
python-version: '2.7' #Available versions here - https://github.com/actions/python-versions/releases easy to change/make a matrix/use pypy
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified

- name: Get virtualenv for Python 2.7
run: |
sudo apt install virtualenv
tar -czf build/content-pack-build-ssa.tar.gz dist/ssa/*

- name: Grab Splunk Packaging Toolkit
- name: Download and Install Splunk Packaging Toolkit
run : |
curl -Ls https://download.splunk.com/misc/packaging-toolkit/splunk-packaging-toolkit-0.9.0.tar.gz -o splunk-packaging-toolkit-latest.tar.gz
source .venv/bin/activate
curl -Ls https://download.splunk.com/misc/packaging-toolkit/splunk-packaging-toolkit-1.0.1.tar.gz -o splunk-packaging-toolkit-latest.tar.gz
mkdir slim-latest
tar -zxf splunk-packaging-toolkit-latest.tar.gz -C slim-latest --strip-components=1

- name: Install Splunk Packaging Toolkit (slim)
run: |
cd slim-latest
virtualenv --python=/usr/bin/python2.7 --clear venv
source venv/bin/activate
python2 -m pip install --upgrade pip
python2 -m pip install wheel
python2 -m pip install semantic_version
python2 -m pip install .
python -m pip install .
cd ..

- name: Create a .spl for this Build Using Slim
- name: Build ESCU
run: |
source slim-latest/venv/bin/activate
source .venv/bin/activate
cd build
tar -zxf content-pack-build-escu.tar.gz
tar -zxf content-pack-build-ssa.tar.gz
Expand All @@ -253,7 +181,8 @@ jobs:
tar -zcf upload/SSA_Content-NO_SLIM.tar.gz SSA_Content
cp upload/SSA_Content-*.tar.gz SSA_Content-latest.tar.gz
sha256sum SSA_Content-latest.tar.gz >> checksum.txt



- name: store_artifacts
uses: actions/upload-artifact@v2
with:
Expand All @@ -269,13 +198,13 @@ jobs:
build/DA-ESS-ContentUpdate-latest.tar.gz
build/SSA_Content-latest.tar.gz
build/checksum.txt



#Everything below this line should ONLY run on a tag and nothing else
#We still want all of the above checks to run and pass before running these
run-appinspect:
runs-on: ubuntu-latest
needs: [validate-content, build-sources, build-package]
needs: [validate-and-build]
#Only run when tagged
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand Down Expand Up @@ -331,7 +260,7 @@ jobs:

create-report:
runs-on: ubuntu-latest
needs: [validate-content, build-sources, build-package, run-appinspect]
needs: [validate-and-build, run-appinspect]
#Only run when tagged
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand Down Expand Up @@ -379,7 +308,7 @@ jobs:

update-sources-github:
runs-on: ubuntu-latest
needs: [validate-content, build-sources, build-package, run-appinspect, create-report]
needs: [validate-and-build, run-appinspect, create-report]
#Only run when tagged
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand Down Expand Up @@ -424,12 +353,12 @@ jobs:
- name: Run doc-gen
run: |
source venv/bin/activate
python3 contentctl.py -p . docgen -o docs
python3 contentctl.py -p . docgen -o docs > /dev/null

- name: Run reporting
run: |
source venv/bin/activate
python3 contentctl.py -p . reporting
python3 contentctl.py -p . reporting > /dev/null

- name: Update github with new docs and package bits
run: |
Expand All @@ -453,7 +382,7 @@ jobs:
#Github-maintained release action is in archived state: https://github.com/actions/create-release
#They recommend several and we use the following with the most stars: https://github.com/softprops/action-gh-release
runs-on: ubuntu-latest
needs: [validate-content, build-sources, build-package, run-appinspect, create-report, update-sources-github]
needs: [validate-and-build, run-appinspect, create-report]
#Only run when tagged
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand Down Expand Up @@ -493,7 +422,7 @@ jobs:

attack-range-update:
runs-on: ubuntu-latest
needs: [validate-content, build-sources, build-package, run-appinspect, create-report, update-sources-github, publish-github-release]
needs: [validate-and-build, run-appinspect, create-report]
#Only run when tagged
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand All @@ -519,7 +448,7 @@ jobs:

master-api-update:
runs-on: ubuntu-latest
needs: [validate-content, build-sources, build-package, run-appinspect, create-report, update-sources-github, publish-github-release, attack-range-update]
needs: [validate-and-build, run-appinspect, create-report]
#Only run when tagged
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def __init__(self, output_dto: BAFactoryOutputDto) -> None:

def execute(self, input_dto: BAFactoryInputDto) -> None:
self.input_dto = input_dto

print("Creating Security Content - SSA. This may take some time...")
self.createSecurityContent(SecurityContentType.unit_tests)
self.createSecurityContent(SecurityContentType.detections)




Expand All @@ -48,15 +49,24 @@ def createSecurityContent(self, type: SecurityContentType) -> list:

validation_error_found = False

for file in files:
files_with_ssa = [f for f in files if 'ssa___' in f]
for index,file in enumerate(files_with_ssa):

#Index + 1 because we are zero indexed, not 1 indexed. This ensures
# that printouts end at 100%, not some other number
progress_percent = ((index+1)/len(files_with_ssa)) * 100

if 'ssa__' in file:
progress_percent = ((index+1)/len(files_with_ssa)) * 100
try:
if type == SecurityContentType.detections:
print(f"\r{'Detections Progress'.rjust(23)}: [{progress_percent:3.0f}%]...", end="", flush=True)
self.input_dto.director.constructDetection(self.input_dto.detection_builder, file, [], [], [], self.output_dto.tests, {}, [], [])
detection = self.input_dto.detection_builder.getObject()
if not detection.deprecated and not detection.experimental:
self.output_dto.detections.append(detection)
elif type == SecurityContentType.unit_tests:
print(f"\r{'Unit Tests Progress'.rjust(23)}: [{progress_percent:3.0f}%]...", end="", flush=True)
self.input_dto.director.constructTest(self.input_dto.basic_builder, file)
test = self.input_dto.basic_builder.getObject()
self.output_dto.tests.append(test)
Expand All @@ -65,6 +75,7 @@ def createSecurityContent(self, type: SecurityContentType) -> list:
print('\nValidation Error for file ' + file)
print(e)
validation_error_found = True
print("Done!")

if validation_error_found:
sys.exit(1)
Loading