Skip to content

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 23 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cc8950f
add trivy image scanning
sjpb Jul 18, 2024
327fbfe
bump fatimage workflow to ubuntu 22.04
sjpb Jul 18, 2024
82b88c1
make setup script work in CI TODO: FIXME
sjpb Jul 18, 2024
e0a00d8
fix libguestfs install
sjpb Jul 18, 2024
6f8b72d
run only 1x build per matrix entry, & only builds required
sjpb Jul 18, 2024
0a44b23
fix packer README
sjpb Jul 18, 2024
edbf17d
fix image download
sjpb Jul 19, 2024
38a5800
Use shorter names for CI clusters (#415)
sjpb Jul 23, 2024
406af42
install ood apps in fatimage
bertiethorpe Jul 19, 2024
2ee66da
add ood jupyter install to fatimage
bertiethorpe Jul 22, 2024
dd2a7ac
jupyter_compute ood into fatimage
bertiethorpe Jul 22, 2024
c659739
bump fatimage
bertiethorpe Jul 23, 2024
83d2c79
allow items in compute mapping to have different keys e.g. only speci…
sjpb Jul 23, 2024
81c8ca2
Support ansible-init for remote collections (#411)
sjpb Aug 7, 2024
be69b8a
avoid python-openstackclient v7 due to rebuild bug (#420)
sjpb Aug 7, 2024
deec81c
Update hpctests to obey UCX_NET_DEVICES when RoCE devices present (#421)
bertiethorpe Aug 7, 2024
526b758
Merge branch 'main' into feat/image-scan
bertiethorpe Aug 9, 2024
813bf0e
delete trivy scanned vulnerabilities
bertiethorpe Aug 9, 2024
1b370a3
update grafana
bertiethorpe Aug 13, 2024
1ce39e9
bump image
bertiethorpe Aug 13, 2024
bdccb0a
Update environments/.stackhpc/hooks/post.yml
bertiethorpe Aug 13, 2024
73a4e5e
Update setup-env.sh
bertiethorpe Aug 14, 2024
f4d4cd9
Merge branch 'main' into feat/image-scan
bertiethorpe Aug 14, 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
84 changes: 64 additions & 20 deletions .github/workflows/fatimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
14 changes: 14 additions & 0 deletions environments/.stackhpc/hooks/post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- hosts: openondemand
become: yes
gather_facts: false
tasks:
- name: Delete ondemand files causing Trivy scan false-positives
# Raised at https://github.com/OSC/ondemand/security/advisories/GHSA-f7j8-ppqm-m5vw
# All declared not to be an issue by Open Ondemand as relevant packages not installed
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
6 changes: 3 additions & 3 deletions environments/.stackhpc/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ variable "cluster_image" {
description = "single image for all cluster nodes, keyed by os_version - a convenience for CI"
type = map(string)
default = {
# https://github.com/stackhpc/ansible-slurm-appliance/pull/411
RL8: "openhpc-RL8-240725-1710-325c7b47"
RL9: "openhpc-ofed-RL9-240725-1710-325c7b47"
# https://github.com/stackhpc/ansible-slurm-appliance/pull/413
RL8: "openhpc-RL8-240813-1317-1b370a36"
RL9: "openhpc-ofed-RL9-240813-1317-1b370a36"
}
}

Expand Down
2 changes: 1 addition & 1 deletion environments/common/inventory/group_vars/all/grafana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# See: https://github.com/cloudalchemy/ansible-grafana
# for variable definitions.
grafana_version: '9.0.3'
grafana_version: '9.5.21'

# need to copy some role defaults here so we can use in inventory:
grafana_port: 3000
Expand Down
Loading