Skip to content

Commit 504e814

Browse files
authored
Merge pull request #13 from advanced-security/jsinglet/bundle-feature
Adding Bundle Feature
2 parents d11abe7 + 48cfab6 commit 504e814

File tree

74 files changed

+4668
-67
lines changed

Some content is hidden

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

74 files changed

+4668
-67
lines changed

.gitattributes

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Set default behavior to automatically normalize line endings.
33
###############################################################################
44
* text=auto
5-
65
###############################################################################
76
# Set default behavior for command prompt diff.
87
#
@@ -11,7 +10,6 @@
1110
# Note: This is only used by command line
1211
###############################################################################
1312
#*.cs diff=csharp
14-
1513
###############################################################################
1614
# Set the merge driver for project and solution files
1715
#
@@ -34,7 +32,6 @@
3432
#*.modelproj merge=binary
3533
#*.sqlproj merge=binary
3634
#*.wwaproj merge=binary
37-
3835
###############################################################################
3936
# behavior for image files
4037
#
@@ -43,7 +40,6 @@
4340
#*.jpg binary
4441
#*.png binary
4542
#*.gif binary
46-
4743
###############################################################################
4844
# diff behavior for common document formats
4945
#
@@ -61,3 +57,4 @@
6157
#*.PDF diff=astextplain
6258
#*.rtf diff=astextplain
6359
#*.RTF diff=astextplain
60+
codeql_bundle.exe filter=lfs diff=lfs merge=lfs -text

.github/actions/install-qlt-local/action.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,36 @@ runs:
4747
# repair permissions
4848
chmod +x ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/qlt
4949
chmod +r -R ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64
50-
50+
51+
- uses: actions/setup-python@v5
52+
with:
53+
python-version: '3.11'
54+
55+
- name: Build CodeQL Bundle Tool for Packaging
56+
shell: pwsh
57+
run: |
58+
# need this for the bundling to work.
59+
pip install poetry
60+
pip install -U pyinstaller
61+
62+
# run the packaging
63+
./scripts/build_codeql_bundle_dist.ps1 -Version 0.2.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/tools/
64+
env:
65+
GH_TOKEN: ${{ github.token }}
66+
67+
- name: Build Bundle Archive
68+
shell: bash
69+
run: |
70+
echo "Current Directory $(pwd)"
71+
5172
# create bundle
5273
ARCHIVE="$(pwd)/qlt-linux-x86_64.zip"
5374
pushd ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64
5475
zip -r $ARCHIVE .
5576
popd
5677
78+
79+
5780
- name: Move Artifacts
5881
shell: pwsh
5982
run: |

.github/actions/install-qlt/action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ runs:
3030
ADD_TO_PATH: ${{ inputs.add-to-path }}
3131
QLT_VERSION: ${{ inputs.qlt-version }}
3232
QLT_HOME: ${{ inputs.qlt-home }}
33+
GITHUB_TOKEN: ${{ github.token }}
34+
3335
shell: bash
3436
run: |
3537
echo -e "\e[0;32m[QLT]\e[0m Determining QLT release for $RUNNER_OS"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: ⚙️ Integration Test Bundle on PR (CPP)
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
workflow_dispatch:
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: ubuntu-latest
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ 'cpp' ]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Install QLT
30+
id: install-qlt
31+
uses: ./.github/actions/install-qlt-local
32+
with:
33+
qlt-version: 'latest'
34+
add-to-path: true
35+
36+
- name: Validate QLT Installation
37+
shell: bash
38+
run: |
39+
echo -e "Checking QLT Version:"
40+
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
41+
qlt version
42+
43+
- name: Create Bundle (compiled)
44+
shell: bash
45+
run: |
46+
if ! qlt codeql run install --base example/ --custom-bundle ; then
47+
echo "Failed to generate bundle."
48+
exit 1
49+
fi
50+
51+
# ensure bundle runs
52+
53+
if ! qlt query run install-packs --use-bundle --base example/ ; then
54+
echo "Failed to install query packs with tool."
55+
exit 1
56+
fi
57+
58+
- name: Validate Bundle Existence
59+
shell: bash
60+
run: |
61+
echo "Checking Bundle Existence"
62+
ls -l ${{ env.QLT_CODEQL_HOME }}/../out/
63+
64+
- name: Initialize CodeQL
65+
uses: github/codeql-action/init@v2
66+
with:
67+
languages: ${{ matrix.language }}
68+
queries: security-extended
69+
source-root: integration-tests/cpp/src/ # Path containing the example application
70+
tools: ${{ env.QLT_CODEQL_BUNDLE_PATH }}
71+
72+
- name: Autobuild
73+
uses: github/codeql-action/autobuild@v2
74+
with:
75+
working-directory: integration-tests/cpp/src/ # Path containing the example application
76+
77+
- name: Perform CodeQL Analysis
78+
id: analysis
79+
uses: github/codeql-action/analyze@v2
80+
81+
- name: Validate SARIF Location
82+
shell: bash
83+
run: |
84+
# validate we have the actual sarif results
85+
echo "Checking SARIF file location at: ${{ steps.analysis.outputs.sarif-output }}"
86+
ls -l ${{ steps.analysis.outputs.sarif-output }}
87+
88+
- name: Upload SARIF Results
89+
uses: actions/upload-artifact@v2
90+
with:
91+
name: actual.sarif
92+
path: |
93+
${{ steps.analysis.outputs.sarif-output }}/*.sarif
94+
if-no-files-found: error
95+
96+
- name: Upload Bundle Used
97+
uses: actions/upload-artifact@v2
98+
with:
99+
name: codeql-bundle.tar.gz
100+
path: |
101+
${{ env.QLT_CODEQL_BUNDLE_PATH }}
102+
if-no-files-found: error
103+
104+
- name: Validate SARIF Results
105+
shell: bash
106+
run: |
107+
# Compare the expected vs the actual
108+
qlt bundle run validate-integration-tests --expected integration-tests/cpp/expected.sarif --actual ${{ steps.analysis.outputs.sarif-output }}/cpp.sarif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: ⚙️ Test Bundle Creation
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
workflow_dispatch:
11+
12+
jobs:
13+
test-bundle-creation:
14+
name: Test Bundle Creation
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Install QLT
21+
id: install-qlt
22+
uses: ./.github/actions/install-qlt-local
23+
with:
24+
qlt-version: 'latest'
25+
add-to-path: true
26+
27+
- name: Validate QLT Installation
28+
shell: bash
29+
run: |
30+
echo -e "Checking QLT Version:"
31+
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
32+
qlt version
33+
34+
- name: Create Bundle (compiled)
35+
shell: bash
36+
run: |
37+
if ! qlt codeql run install --base example/ --custom-bundle ; then
38+
echo "Failed to generate bundle."
39+
exit 1
40+
fi
41+
42+
# ensure bundle runs
43+
44+
if ! qlt query run install-packs --use-bundle --base example/ ; then
45+
echo "Failed to install query packs with tool."
46+
exit 1
47+
fi
48+
49+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: ⚙️ Test Bundle Creation (Quick)
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
workflow_dispatch:
11+
12+
jobs:
13+
test-bundle-creation:
14+
name: Test Bundle Creation
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Install QLT
21+
id: install-qlt
22+
uses: ./.github/actions/install-qlt-local
23+
with:
24+
qlt-version: 'latest'
25+
add-to-path: true
26+
27+
- name: Validate QLT Installation
28+
shell: bash
29+
run: |
30+
echo -e "Checking QLT Version:"
31+
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
32+
qlt version
33+
34+
- name: Create Bundle (quick)
35+
shell: bash
36+
run: |
37+
if ! qlt codeql run install --base example/ --quick-bundle ; then
38+
echo "Failed to generate bundle."
39+
exit 1
40+
fi
41+
42+
# ensure bundle runs
43+
44+
if ! qlt query run install-packs --use-bundle --base example/ ; then
45+
echo "Failed to install query packs with tool."
46+
exit 1
47+
fi
48+
49+

.github/workflows/internal-validate-workflow-files.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: ⚙️ Validate Workflow Files
33
on:
44
push:
55
branches:
6-
- '**'
6+
- 'main'
77
pull_request:
88
branches:
9-
- '**'
9+
- 'main'
1010
workflow_dispatch:
1111

1212
jobs:

.github/workflows/run-codeql-unit-tests-cpp.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,20 @@ jobs:
5959

6060
- name: Install CodeQL
6161
id: install-codeql
62-
uses: ./.github/actions/install-codeql
63-
with:
64-
codeql-cli-version: ${{ matrix.codeql_cli }}
65-
codeql-stdlib-version: ${{ matrix.codeql_standard_library }}
66-
add-to-path: true
62+
shell: bash
63+
run: |
64+
echo "Installing CodeQL"
65+
qlt codeql run install --base example/
66+
echo "-----------------------------"
67+
echo "CodeQL Home: $QLT_CODEQL_HOME"
68+
echo "CodeQL Binary: $QLT_CODEQL_PATH"
6769
6870
- name: Verify Versions of Tooling
6971
shell: bash
7072
run: |
71-
echo "CodeQL Home: ${{ steps.install-codeql.outputs.codeql-home }}"
7273
echo -e "Checking CodeQL Version:"
73-
codeql --version
74-
74+
$QLT_CODEQL_PATH --version
75+
7576
echo -e "Checking QLT Version:"
7677
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
7778
qlt version

.github/workflows/validate-codeql-queries-cpp.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,21 @@ jobs:
5858

5959

6060
- name: Install CodeQL
61-
uses: ./.github/actions/install-codeql
62-
with:
63-
codeql-cli-version: ${{ matrix.codeql_cli }}
64-
codeql-stdlib-version: ${{ matrix.codeql_standard_library }}
65-
add-to-path: true
61+
id: install-codeql
62+
shell: bash
63+
run: |
64+
echo "Installing CodeQL"
65+
qlt codeql run install --base example/
66+
echo "-----------------------------"
67+
echo "CodeQL Home: $QLT_CODEQL_HOME"
68+
echo "CodeQL Binary: $QLT_CODEQL_PATH"
6669
6770
- name: Verify Versions of Tooling
6871
shell: bash
6972
run: |
70-
echo "CodeQL Home: ${{ steps.install-codeql.outputs.codeql-home }}"
7173
echo -e "Checking CodeQL Version:"
72-
codeql --version
73-
74+
$QLT_CODEQL_PATH --version
75+
7476
echo -e "Checking QLT Version:"
7577
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
7678
qlt version

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,5 @@ MigrationBackup/
360360
.ionide/
361361

362362
# Fody - auto-generated XML schema
363-
FodyWeavers.xsd
363+
FodyWeavers.xsd
364+
/dist/

0 commit comments

Comments
 (0)