Skip to content

Commit 73c7ac9

Browse files
committed
Add the workflow updates
1 parent 29616ca commit 73c7ac9

5 files changed

Lines changed: 92 additions & 60 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: contentctl-ng-install-tool
2+
description: Set up Python and install contentctl-ng from requirements.txt.
3+
inputs:
4+
python-version:
5+
description: Python version used for setup.
6+
required: false
7+
default: '3.14'
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Set up Python
13+
uses: actions/setup-python@v6
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
architecture: x64
17+
18+
- name: Install contentctl-ng
19+
shell: bash
20+
run: |
21+
echo "- Build Tool Version - $(cat requirements.txt)"
22+
pip install -r requirements.txt

.github/workflows/appinspect.yml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
1+
# This workflow performs a simple build action.
2+
# It is intentionally separate from the build
3+
# workflow to provide granular feedback and insight
4+
# into when a build passes but an appinspect fails.
15
name: appinspect
6+
27
on:
38
pull_request:
49
types: [opened, reopened, synchronize]
10+
511
jobs:
612
appinspect:
713
runs-on: ubuntu-latest
814
steps:
9-
- name: Check out repository (PR)
10-
if: ${{ github.event_name == 'pull_request' }}
15+
- name: Check out the repository code
1116
uses: actions/checkout@v6
12-
with:
13-
ref: refs/pull/${{ github.event.pull_request.number }}/merge
14-
15-
- uses: actions/setup-python@v6
16-
with:
17-
python-version: '3.11'
18-
architecture: 'x64'
1917

20-
- name: Install Python Dependencies and ContentCTL and Atomic Red Team
18+
- name: Install contentctl-ng
19+
uses: ./.github/actions/contentctl-ng-install-tool
20+
21+
- name: Run a contentctl-ng build
2122
run: |
22-
echo "- Contentctl version - $(cat requirements.txt)"
23-
pip install -r requirements.txt
24-
git clone --depth=1 --single-branch --branch=master https://github.com/redcanaryco/atomic-red-team.git external_repos/atomic-red-team
25-
git clone --depth=1 --single-branch --branch="master" https://github.com/mitre-attack/attack-stix-data external_repos/cti
23+
contentctl-ng build
2624
27-
- name: Running appinspect with enrichments
25+
- name: Run appinspect with enrichments
2826
env:
2927
APPINSPECTUSERNAME: "${{ secrets.APPINSPECTUSERNAME }}"
3028
APPINSPECTPASSWORD: "${{ secrets.APPINSPECTPASSWORD }}"
3129
run: |
32-
echo $APPINSPECTUSERNAME
33-
contentctl inspect --splunk-api-username "$APPINSPECTUSERNAME" --splunk-api-password "$APPINSPECTPASSWORD" --enrichments --enable-metadata-validation --suppress-missing-content-exceptions --enforce-deprecation-mapping-requirement
34-
echo "done appinspect"
30+
# Download the most recent Release in order to enforce metadata validation
31+
# --location flag required to follow redirects from the "latest" URL
32+
curl --location -o DA-ESS-ContentUpdate-latest.tar.gz https://github.com/splunk/security_content/releases/latest/download/DA-ESS-ContentUpdate-latest.tar.gz
33+
34+
# Inspect, using the release we downloaded above
35+
# Also, we intentionally ignore missing content exceptions - private content is
36+
# not expected to be present when running this check in GitHub
37+
contentctl-ng inspect --splunkbase-username "$APPINSPECTUSERNAME" --splunkbase-password "$APPINSPECTPASSWORD" --old-app-path DA-ESS-ContentUpdate-latest.tar.gz --ignore-missing-content-exceptions
3538
mkdir -p artifacts/app_inspect_report
3639
cp -r dist/*.html artifacts/app_inspect_report
3740
cp -r dist/*.tar.gz artifacts/
3841
42+
# Store inspect artifacts
3943
- name: store_artifacts
44+
if: always()
4045
uses: actions/upload-artifact@v7
4146
with:
42-
name: content-latest
47+
name: appinspect_results
4348
path: |
44-
artifacts/DA-ESS-ContentUpdate-latest.tar.gz
45-
artifacts/app_inspect_report
49+
dist/*.html
50+
dist/*.tar.gz
51+

.github/workflows/build.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1+
# This workflow performs a simple build action.
2+
# It is intentionally separate from the appinspect
3+
# workflow to provide granular feedback and insight
4+
# into when a build passes but an appinspect fails.
15
name: build
6+
27
on:
38
pull_request:
49
types: [opened, reopened, synchronize]
510
push:
611
branches:
712
- develop
13+
14+
815
jobs:
916
build:
1017
runs-on: ubuntu-latest
1118
steps:
1219
- name: Check out the repository code
1320
uses: actions/checkout@v6
1421

15-
- uses: actions/setup-python@v6
16-
with:
17-
python-version: '3.11'
18-
architecture: 'x64'
22+
- name: Install contentctl-ng tool
23+
uses: ./.github/actions/contentctl-ng-install-tool
1924

20-
- name: Install Python Dependencies and ContentCTL and Atomic Red Team
25+
- name: Run a contentctl-ng build
2126
run: |
22-
echo "- Contentctl version - $(cat requirements.txt)"
23-
pip install -r requirements.txt
24-
git clone --depth=1 --single-branch --branch=master https://github.com/redcanaryco/atomic-red-team.git external_repos/atomic-red-team
25-
git clone --depth=1 --single-branch --branch="master" https://github.com/mitre-attack/attack-stix-data external_repos/cti
26-
27-
- name: Running build with enrichments
28-
run: |
29-
contentctl build --enrichments --enforce_deprecation_mapping_requirement
30-
mkdir artifacts
31-
mv dist/DA-ESS-ContentUpdate-latest.tar.gz artifacts/
32-
27+
contentctl-ng build
28+
29+
# Store build artifact
3330
- name: store_artifacts
31+
if: always()
3432
uses: actions/upload-artifact@v7
3533
with:
3634
name: content-latest
3735
path: |
38-
artifacts/DA-ESS-ContentUpdate-latest.tar.gz
39-
dist/api
36+
dist/*.tar.gz

.github/workflows/unit-testing.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
types: [opened, reopened, synchronize]
55
jobs:
66
unit-testing:
7-
runs-on: ubuntu-latest
7+
runs-on: large-ubuntu-22.04-32core
88
if: "!contains(github.ref, 'refs/tags/')" #don't run on tags - future steps won't run either since they depend on this job
99
steps:
1010
#For fork PRs, always check out security_content and the PR target in security content!
@@ -13,25 +13,12 @@ jobs:
1313
with:
1414
repository: 'splunk/security_content' #this should be the TARGET repo of the PR. we hardcode it for now
1515
ref: ${{ github.base_ref }}
16-
17-
18-
- uses: actions/setup-python@v6
19-
with:
20-
python-version: '3.11' #Available versions here - https://github.com/actions/python-versions/releases easy to change/make a matrix/use pypy
21-
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
22-
23-
- name: Install Python Dependencies and ContentCTL
24-
run: |
25-
python -m pip install --upgrade pip
26-
echo "- Contentctl version - $(cat requirements.txt)"
27-
pip install -r requirements.txt
28-
29-
30-
# Running contentctl test with a few arguments, before running the command make sure you checkout into the current branch of the pull request. This step only performs unit testing on all the changes against the target-branch. In most cases this target branch will be develop
31-
# Make sure we check out the PR, even if it actually lives in a fork
16+
17+
18+
# Check out the PR, even if it lives in a fork.
3219
# Instructions for pulling a PR were taken from:
3320
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
34-
- name: Run ContentCTL test for changes against target branch
21+
- name: Checkout the PR branch and the target to calculate changed files for testing
3522
run: |
3623
3724
echo "Current Branch (Head Ref): ${{ github.head_ref }}"
@@ -41,7 +28,27 @@ jobs:
4128
git fetch origin pull/${{ github.event.pull_request.number }}/head:new_branch_for_testing
4229
#We must specifically get the PR's target branch from security_content, not the one that resides in the fork PR's forked repo
4330
git switch new_branch_for_testing
44-
contentctl test --verbose --disable-tqdm --no-enable-integration-testing --container-settings.num-containers 1 --post-test-behavior never_pause mode:changes --mode.target-branch ${{ github.base_ref }}
31+
32+
33+
- name: Run a contentctl-ng build to ensure that the branch in syntactically correct
34+
uses: ./.github/actions/contentctl-build
35+
36+
- name: Start the test environment
37+
run: |
38+
docker run -d --platform linux/amd64 -p 8088:8088 -p 8089:8089 -p 8000:8000 -e 'SPLUNK_START_ARGS=--accept-license' -e 'SPLUNK_GENERAL_TERMS=--accept-sgt-current-at-splunk-com' -e 'SPLUNK_PASSWORD=Chang3d!' --name splunk splunk/splunk:latest
39+
# Wait some time for this environment to be ready
40+
sleep 180
41+
42+
- name: Run a contentctl-ng install to configure the testing environment
43+
env:
44+
APPINSPECTUSERNAME: "${{ secrets.APPINSPECTUSERNAME }}"
45+
APPINSPECTPASSWORD: "${{ secrets.APPINSPECTPASSWORD }}"
46+
run : |
47+
contentctl-ng install --splunkbase-username "$APPINSPECTUSERNAME" --splunkbase-password "$APPINSPECTPASSWORD"
48+
49+
- name: Test content which has changed between this branch and the target branch
50+
run: |
51+
contentctl-ng test --verbose --post-test-behavior NEVER_PAUSE --mode CHANGED --git-ref ${{ github.base_ref }}
4552
echo "contentctl test - COMPLETED"
4653
4754
# Store test_results/summary.yml and dist/DA-ESS-ContentUpdate-latest.tar.gz to job artifact-test_summary_results.zip
@@ -52,7 +59,7 @@ jobs:
5259
name: test_summary_results
5360
path: |
5461
test_results/summary.yml
55-
dist/DA-ESS-ContentUpdate-latest.tar.gz
62+
dist/*.tar.gz
5663
5764
# Print entire result summary so that the users can view it in the Github Actions logs
5865
- name: Print entire test_results/summary.yml

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
contentctl==5.6.0
1+
contentctl-ng==0.4.0

0 commit comments

Comments
 (0)