-
Notifications
You must be signed in to change notification settings - Fork 34
Add trivy image scanning #413
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
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
cc8950f
add trivy image scanning
sjpb 327fbfe
bump fatimage workflow to ubuntu 22.04
sjpb 82b88c1
make setup script work in CI TODO: FIXME
sjpb e0a00d8
fix libguestfs install
sjpb 6f8b72d
run only 1x build per matrix entry, & only builds required
sjpb 0a44b23
fix packer README
sjpb edbf17d
fix image download
sjpb 38a5800
Use shorter names for CI clusters (#415)
sjpb 406af42
install ood apps in fatimage
bertiethorpe 2ee66da
add ood jupyter install to fatimage
bertiethorpe dd2a7ac
jupyter_compute ood into fatimage
bertiethorpe c659739
bump fatimage
bertiethorpe 83d2c79
allow items in compute mapping to have different keys e.g. only speci…
sjpb 81c8ca2
Support ansible-init for remote collections (#411)
sjpb be69b8a
avoid python-openstackclient v7 due to rebuild bug (#420)
sjpb deec81c
Update hpctests to obey UCX_NET_DEVICES when RoCE devices present (#421)
bertiethorpe 526b758
Merge branch 'main' into feat/image-scan
bertiethorpe 813bf0e
delete trivy scanned vulnerabilities
bertiethorpe 1b370a3
update grafana
bertiethorpe 1ce39e9
bump image
bertiethorpe bdccb0a
Update environments/.stackhpc/hooks/post.yml
bertiethorpe 73a4e5e
Update setup-env.sh
bertiethorpe f4d4cd9
Merge branch 'main' into feat/image-scan
bertiethorpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,27 +2,26 @@ | |
name: Build fat image | ||
'on': | ||
workflow_dispatch: | ||
inputs: | ||
use_RL8: | ||
required: true | ||
description: Include RL8 image build | ||
type: boolean | ||
default: false | ||
concurrency: | ||
group: ${{ github.ref }}-{{ matrix.os_version }} # to branch/PR + OS | ||
group: ${{ github.ref }}-{{ matrix.os_version }}-{{ matrix.build }} # to branch/PR + OS + build | ||
cancel-in-progress: true | ||
jobs: | ||
openstack: | ||
name: openstack-imagebuild | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
os_version: [RL8, RL9] | ||
rl8_selected: | ||
- ${{ inputs.use_RL8 == true }} # only potentially true for workflow_dispatch | ||
os_version: | ||
- RL8 | ||
- RL9 | ||
build: | ||
- openstack.openhpc | ||
- openstack.openhpc-ofed | ||
exclude: | ||
- os_version: RL8 | ||
rl8_selected: false | ||
build: openstack.openhpc-ofed | ||
- os_version: RL9 | ||
build: openstack.openhpc | ||
env: | ||
ANSIBLE_FORCE_COLOR: True | ||
OS_CLOUD: openstack | ||
|
@@ -63,19 +62,64 @@ jobs: | |
. environments/.stackhpc/activate | ||
cd packer/ | ||
packer init . | ||
PACKER_LOG=1 packer build -on-error=${{ vars.PACKER_ON_ERROR }} -except=openstack.openhpc-extra -var-file=$PKR_VAR_environment_root/${{ vars.CI_CLOUD }}.pkrvars.hcl openstack.pkr.hcl | ||
PACKER_LOG=1 packer build -on-error=${{ vars.PACKER_ON_ERROR }} -only=${{ matrix.build }} -var-file=$PKR_VAR_environment_root/${{ vars.CI_CLOUD }}.pkrvars.hcl openstack.pkr.hcl | ||
env: | ||
PKR_VAR_os_version: ${{ matrix.os_version }} | ||
|
||
- name: Get created image names from manifest | ||
id: manifest | ||
run: | | ||
. venv/bin/activate | ||
for IMAGE_ID in $(jq --raw-output '.builds[].artifact_id' packer/packer-manifest.json) | ||
do | ||
while ! openstack image show -f value -c name $IMAGE_ID; do | ||
sleep 5 | ||
done | ||
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID) | ||
echo $IMAGE_NAME | ||
IMAGE_ID=$(jq --raw-output '.builds[-1].artifact_id' packer/packer-manifest.json) | ||
while ! openstack image show -f value -c name $IMAGE_ID; do | ||
sleep 5 | ||
done | ||
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID) | ||
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT" | ||
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Download image | ||
run: | | ||
. venv/bin/activate | ||
openstack image save --file ${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-name }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: install libguestfs | ||
run: | | ||
sudo apt -y update | ||
sudo apt -y install libguestfs-tools | ||
|
||
- name: mkdir for mount | ||
run: sudo mkdir -p './${{ steps.manifest.outputs.image-name }}' | ||
|
||
- name: mount qcow2 file | ||
run: sudo guestmount -a ${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}' | ||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: fs | ||
scan-ref: "./${{ steps.manifest.outputs.image-name }}" | ||
scanners: "vuln" | ||
format: sarif | ||
output: "${{ steps.manifest.outputs.image-name }}.sarif" | ||
# turn off secret scanning to speed things up | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: "${{ steps.manifest.outputs.image-name }}.sarif" | ||
category: "${{ matrix.os_version }}-${{ matrix.build }}" | ||
|
||
- name: Fail if scan has CRITICAL vulnerabilities | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: fs | ||
scan-ref: "./${{ steps.manifest.outputs.image-name }}" | ||
scanners: "vuln" | ||
format: table | ||
exit-code: '1' | ||
severity: 'CRITICAL' | ||
ignore-unfixed: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- hosts: openondemand | ||
become: yes | ||
gather_facts: false | ||
tasks: | ||
- name: Delete trivy vulnerable files | ||
bertiethorpe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: absent | ||
with_items: | ||
- /opt/ood/ondemand/root/usr/share/gems/3.1/ondemand/3.1.7-1/gems/bootstrap_form-2.7.0/test/dummy/Gemfile.lock | ||
- /opt/ood/ondemand/root/usr/share/gems/3.1/ondemand/3.1.7-1/gems/bootstrap_form-4.5.0/demo/yarn.lock | ||
- /var/www/ood/apps/sys/dashboard/node_modules/data-confirm-modal/Gemfile.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.