Skip to content

Adding Bundle Feature #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f812279
fix template issue
jsinglet Jan 19, 2024
26659f2
code for enabling and disabling and checking on status of custom bundles
jsinglet Jan 19, 2024
fe11c79
work to enable codeql version mgmt
jsinglet Jan 24, 2024
b2c3198
installations working for standard codeql installations
jsinglet Jan 29, 2024
f23ce79
work
jsinglet Feb 2, 2024
d1d8450
integrated CodeQL command into tool.
jsinglet Feb 6, 2024
cbf3106
testing installation of new codeql
jsinglet Feb 6, 2024
b057a95
export paths
jsinglet Feb 6, 2024
9dfc9e7
env vars
jsinglet Feb 8, 2024
005c0a3
checking paths
jsinglet Feb 8, 2024
ca1c773
logging
jsinglet Feb 8, 2024
c28d198
retarget
jsinglet Feb 8, 2024
9029e08
retarget
jsinglet Feb 8, 2024
9641105
explicit writing to env
jsinglet Feb 8, 2024
b91243c
newines
jsinglet Feb 8, 2024
595350a
packs
jsinglet Feb 8, 2024
7615bca
Merge pull request #17 from advanced-security/jsinglet/bundle-feature…
jsinglet Feb 8, 2024
cc4cf7a
CodeQL should no longer have a seperate action
jsinglet Feb 9, 2024
d6ac6f6
update workflow
jsinglet Feb 9, 2024
d51d472
spacing
jsinglet Feb 9, 2024
9de8779
spacing
jsinglet Feb 9, 2024
7fe2b9a
template fixes
jsinglet Feb 9, 2024
2f5b24c
update query vailidation
jsinglet Feb 9, 2024
c3e4ed2
update template
jsinglet Feb 9, 2024
df69138
fix path binary
jsinglet Feb 9, 2024
574cee0
don't target every branch
jsinglet Feb 9, 2024
ee0d8b8
linux specific test case
jsinglet Feb 9, 2024
8d43622
spacing
jsinglet Feb 9, 2024
ff30e7c
bundle integration
jsinglet Feb 20, 2024
ed85696
bundle integration; quick bundles as well as correct processing from …
jsinglet Feb 21, 2024
e062bea
adding two new workflows for testing bundles
jsinglet Feb 21, 2024
76862fa
update local install action so that the binary tools get created
jsinglet Feb 21, 2024
84e02c8
adding custom bundle flag
jsinglet Feb 21, 2024
d883c1c
adding bundle tests
jsinglet Feb 22, 2024
ecfd03a
integration tests
jsinglet Feb 22, 2024
e1b4f1b
syntax
jsinglet Feb 22, 2024
ddb64c3
version 4
jsinglet Feb 22, 2024
42291ff
adding builder
jsinglet Feb 22, 2024
15b304f
bits to make sarif comparison work
jsinglet Feb 22, 2024
8f1cb72
adding expected
jsinglet Feb 22, 2024
8d6c207
diffing
jsinglet Feb 23, 2024
4cc2367
work
jsinglet Feb 23, 2024
5381b83
adding SARIF compare tool
jsinglet Feb 29, 2024
1d626b8
update workflow
jsinglet Feb 29, 2024
48cfab6
add bundle to flow
jsinglet Mar 1, 2024
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
5 changes: 1 addition & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
Expand All @@ -11,7 +10,6 @@
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
Expand All @@ -34,7 +32,6 @@
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
Expand All @@ -43,7 +40,6 @@
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
Expand All @@ -61,3 +57,4 @@
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
codeql_bundle.exe filter=lfs diff=lfs merge=lfs -text
25 changes: 24 additions & 1 deletion .github/actions/install-qlt-local/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,36 @@ runs:
# repair permissions
chmod +x ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/qlt
chmod +r -R ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64


- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Build CodeQL Bundle Tool for Packaging
shell: pwsh
run: |
# need this for the bundling to work.
pip install poetry
pip install -U pyinstaller

# run the packaging
./scripts/build_codeql_bundle_dist.ps1 -Version 0.2.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/tools/
env:
GH_TOKEN: ${{ github.token }}

- name: Build Bundle Archive
shell: bash
run: |
echo "Current Directory $(pwd)"

# create bundle
ARCHIVE="$(pwd)/qlt-linux-x86_64.zip"
pushd ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64
zip -r $ARCHIVE .
popd



- name: Move Artifacts
shell: pwsh
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/install-qlt/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ runs:
ADD_TO_PATH: ${{ inputs.add-to-path }}
QLT_VERSION: ${{ inputs.qlt-version }}
QLT_HOME: ${{ inputs.qlt-home }}
GITHUB_TOKEN: ${{ github.token }}

shell: bash
run: |
echo -e "\e[0;32m[QLT]\e[0m Determining QLT release for $RUNNER_OS"
Expand Down
108 changes: 108 additions & 0 deletions .github/workflows/internal-pr-bundle-integration-test-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: ⚙️ Integration Test Bundle on PR (CPP)

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install QLT
id: install-qlt
uses: ./.github/actions/install-qlt-local
with:
qlt-version: 'latest'
add-to-path: true

- name: Validate QLT Installation
shell: bash
run: |
echo -e "Checking QLT Version:"
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
qlt version

- name: Create Bundle (compiled)
shell: bash
run: |
if ! qlt codeql run install --base example/ --custom-bundle ; then
echo "Failed to generate bundle."
exit 1
fi

# ensure bundle runs

if ! qlt query run install-packs --use-bundle --base example/ ; then
echo "Failed to install query packs with tool."
exit 1
fi

- name: Validate Bundle Existence
shell: bash
run: |
echo "Checking Bundle Existence"
ls -l ${{ env.QLT_CODEQL_HOME }}/../out/

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: security-extended
source-root: integration-tests/cpp/src/ # Path containing the example application
tools: ${{ env.QLT_CODEQL_BUNDLE_PATH }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2
with:
working-directory: integration-tests/cpp/src/ # Path containing the example application

- name: Perform CodeQL Analysis
id: analysis
uses: github/codeql-action/analyze@v2

- name: Validate SARIF Location
shell: bash
run: |
# validate we have the actual sarif results
echo "Checking SARIF file location at: ${{ steps.analysis.outputs.sarif-output }}"
ls -l ${{ steps.analysis.outputs.sarif-output }}

- name: Upload SARIF Results
uses: actions/upload-artifact@v2
with:
name: actual.sarif
path: |
${{ steps.analysis.outputs.sarif-output }}/*.sarif
if-no-files-found: error

- name: Upload Bundle Used
uses: actions/upload-artifact@v2
with:
name: codeql-bundle.tar.gz
path: |
${{ env.QLT_CODEQL_BUNDLE_PATH }}
if-no-files-found: error

- name: Validate SARIF Results
shell: bash
run: |
# Compare the expected vs the actual
qlt bundle run validate-integration-tests --expected integration-tests/cpp/expected.sarif --actual ${{ steps.analysis.outputs.sarif-output }}/cpp.sarif
49 changes: 49 additions & 0 deletions .github/workflows/internal-pr-test-bundle-creation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: ⚙️ Test Bundle Creation

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:

jobs:
test-bundle-creation:
name: Test Bundle Creation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install QLT
id: install-qlt
uses: ./.github/actions/install-qlt-local
with:
qlt-version: 'latest'
add-to-path: true

- name: Validate QLT Installation
shell: bash
run: |
echo -e "Checking QLT Version:"
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
qlt version

- name: Create Bundle (compiled)
shell: bash
run: |
if ! qlt codeql run install --base example/ --custom-bundle ; then
echo "Failed to generate bundle."
exit 1
fi

# ensure bundle runs

if ! qlt query run install-packs --use-bundle --base example/ ; then
echo "Failed to install query packs with tool."
exit 1
fi


49 changes: 49 additions & 0 deletions .github/workflows/internal-pr-test-quick-bundle-creation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: ⚙️ Test Bundle Creation (Quick)

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:

jobs:
test-bundle-creation:
name: Test Bundle Creation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install QLT
id: install-qlt
uses: ./.github/actions/install-qlt-local
with:
qlt-version: 'latest'
add-to-path: true

- name: Validate QLT Installation
shell: bash
run: |
echo -e "Checking QLT Version:"
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
qlt version

- name: Create Bundle (quick)
shell: bash
run: |
if ! qlt codeql run install --base example/ --quick-bundle ; then
echo "Failed to generate bundle."
exit 1
fi

# ensure bundle runs

if ! qlt query run install-packs --use-bundle --base example/ ; then
echo "Failed to install query packs with tool."
exit 1
fi


4 changes: 2 additions & 2 deletions .github/workflows/internal-validate-workflow-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: ⚙️ Validate Workflow Files
on:
push:
branches:
- '**'
- 'main'
pull_request:
branches:
- '**'
- 'main'
workflow_dispatch:

jobs:
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/run-codeql-unit-tests-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,20 @@ jobs:

- name: Install CodeQL
id: install-codeql
uses: ./.github/actions/install-codeql
with:
codeql-cli-version: ${{ matrix.codeql_cli }}
codeql-stdlib-version: ${{ matrix.codeql_standard_library }}
add-to-path: true
shell: bash
run: |
echo "Installing CodeQL"
qlt codeql run install --base example/
echo "-----------------------------"
echo "CodeQL Home: $QLT_CODEQL_HOME"
echo "CodeQL Binary: $QLT_CODEQL_PATH"

- name: Verify Versions of Tooling
shell: bash
run: |
echo "CodeQL Home: ${{ steps.install-codeql.outputs.codeql-home }}"
echo -e "Checking CodeQL Version:"
codeql --version

$QLT_CODEQL_PATH --version
echo -e "Checking QLT Version:"
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
qlt version
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/validate-codeql-queries-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,21 @@ jobs:


- name: Install CodeQL
uses: ./.github/actions/install-codeql
with:
codeql-cli-version: ${{ matrix.codeql_cli }}
codeql-stdlib-version: ${{ matrix.codeql_standard_library }}
add-to-path: true
id: install-codeql
shell: bash
run: |
echo "Installing CodeQL"
qlt codeql run install --base example/
echo "-----------------------------"
echo "CodeQL Home: $QLT_CODEQL_HOME"
echo "CodeQL Binary: $QLT_CODEQL_PATH"

- name: Verify Versions of Tooling
shell: bash
run: |
echo "CodeQL Home: ${{ steps.install-codeql.outputs.codeql-home }}"
echo -e "Checking CodeQL Version:"
codeql --version

$QLT_CODEQL_PATH --version
echo -e "Checking QLT Version:"
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
qlt version
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,5 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd
/dist/
Loading