Skip to content

Commit 954b352

Browse files
authored
Merge pull request #41 from SpecterOps/feature/ziprelease
Added ability to export query bundle to zip + create release/download
2 parents a733a23 + 89c00be commit 954b352

16 files changed

Lines changed: 147 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
name: Query syntax validation
1+
name: Generate query bundle and push release
22
on:
3-
pull_request:
4-
branches: [ 'main' ]
5-
63
workflow_dispatch:
7-
8-
permissions:
9-
contents: write
4+
push:
5+
branches:
6+
- main
107

118
jobs:
129
test:
1310
runs-on: ubuntu-latest
1411

1512
steps:
1613
- uses: actions/checkout@v4
17-
with:
18-
ref: ${{ github.head_ref }}
1914
- name: Set up Python 3.10
2015
uses: actions/setup-python@v3
2116
with:
@@ -38,42 +33,46 @@ jobs:
3833
name: test-report
3934
path: test-report.md
4035

41-
build:
36+
37+
release:
4238
runs-on: ubuntu-latest
4339
needs: test
4440
steps:
4541
- uses: actions/checkout@v4
46-
with:
47-
ref: ${{ github.head_ref }}
4842
- name: Set up Python 3.10
4943
uses: actions/setup-python@v3
5044
with:
5145
python-version: "3.10"
46+
5247
- name: Install dependencies
5348
run: |
5449
python -m pip install --upgrade pip
5550
pip install -r requirements.txt
56-
57-
- name: Install dependencies
58-
run: |
59-
python -m pip install --upgrade pip
60-
pip install -r requirements.txt
61-
62-
- name: Convert queries into single json
51+
52+
- name: Convert queries into single zip file
6353
run: |
64-
python utilities/python/convert.py ./queries ./Queries.json
54+
python utilities/python/convert.py ./queries ./Queries.zip --file-format zip
6555
66-
- name: Configure Git
56+
- name: Convert queries into single json file
6757
run: |
68-
git config --global user.name "github-actions[bot]"
69-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
70-
71-
- name: Commit if changed
58+
python utilities/python/convert.py ./queries ./Queries.json
59+
60+
- name: Set metadata
61+
id: release_meta
7262
run: |
73-
git add ./Queries.json
74-
if git diff --staged --quiet; then
75-
echo "No changes to commit"
76-
else
77-
git commit -m "Update combined queries"
78-
git push
79-
fi
63+
release_date="$(date -u +%Y-%m-%d)"
64+
echo "release_date=${release_date}" >> "$GITHUB_OUTPUT"
65+
echo "release_tag=queries-${release_date}" >> "$GITHUB_OUTPUT"
66+
echo "release_name=Queries ${release_date}" >> "$GITHUB_OUTPUT"
67+
68+
- name: Create release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: ${{ steps.release_meta.outputs.release_tag }}
72+
name: ${{ steps.release_meta.outputs.release_name }}
73+
files: |
74+
Queries.zip
75+
Queries.json
76+
body: |
77+
This release contains all queries exported as JSON and bundled in a single file. The compressed .zip file can be uploaded to BloodHound to bulk-import all queries.
78+
draft: true

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Query syntax validation
2+
on:
3+
pull_request:
4+
branches: [ 'main' ]
5+
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python 3.10
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: "3.10"
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install -r requirements.txt
25+
26+
- name: Test queries with pytest
27+
run: |
28+
pytest tests/test_cypher_syntax.py
29+
30+
- name: Add test report to summary
31+
run: cat test-report.md >> $GITHUB_STEP_SUMMARY
32+
33+
- name: Upload test report
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: test-report
37+
path: test-report.md

queries/All Azure VMs with a tied Managed Identity.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ query: |-
99
MATCH p=(:AZVM)-[:AZManagedIdentity]->(n)
1010
RETURN p
1111
revision: 1
12-
resources: -
12+
resources:
1313
acknowledgements: Daniel Scheidt, @theluemmel

queries/All direct Controllers of MS Graph.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ query: |-
1010
WHERE g.displayname = "MICROSOFT GRAPH"
1111
RETURN p
1212
revision: 1
13-
resources: -
13+
resources:
1414
acknowledgements: Daniel Scheidt, @theluemmel

queries/All privileged Azure Service Principals.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ query: |-
1010
WHERE r.displayname =~ '(?i)Global Administrator|User Administrator|Cloud Application Administrator|Authentication Policy Administrator|Exchange Administrator|Helpdesk Administrator|PRIVILEGED AUTHENTICATION ADMINISTRATOR|Domain Name Administrator|Hybrid Identity Administrator|External Identity Provider Administrator|Privileged Role Administrator|Partner Tier2 Support|Application Administrator|Directory Synchronization Accounts'
1111
RETURN p
1212
revision: 1
13-
resources: -
13+
resources:
1414
acknowledgements: Daniel Scheidt, @theluemmel

queries/Disabled Tier Zero High Value principals - AD.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Disabled Tier Zero / High Value principals
1+
name: Disabled Tier Zero / High Value principals (AD)
22
guid: d65a801f-d3ef-4b7e-8030-99ebfd6dad12
33
prebuilt: true
44
platforms: Active Directory

queries/Disabled Tier Zero High Value principals - AZ.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Disabled Tier Zero / High Value principals
1+
name: Disabled Tier Zero / High Value principals (AZ)
22
guid: 860d5c2d-84fe-4c85-80de-e0a9badbd0e7
33
prebuilt: true
44
platforms: Azure

queries/Locations of Owned objects - AD.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Locations of Owned objects
1+
name: Locations of Owned objects (AD)
22
guid: c88bfab4-3da0-4b36-b71d-7b324ebd2243
33
prebuilt: false
44
platforms: Active Directory

queries/Locations of Owned objects - AZ.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Locations of Owned objects
1+
name: Locations of Owned objects (AZ)
22
guid: 350b8b8a-ea4c-44f3-874b-c9316de6c41b
33
prebuilt: false
44
platforms: Azure

queries/Owners of Azure Applications.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ query: |-
99
MATCH p = (n)-[r:AZOwns]->(g:AZApp)
1010
RETURN p
1111
revision: 1
12-
resources: -
12+
resources:
1313
acknowledgements: Daniel Scheidt, @theluemmel

0 commit comments

Comments
 (0)