-
Notifications
You must be signed in to change notification settings - Fork 14
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
CI improvements #927
Merged
Merged
CI improvements #927
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
77b8816
Add "--detailed" inspect.sh flag
petrutlucian94 8a987d5
Move Trivy and Tics tests to separate scripts
petrutlucian94 7b194f0
Fix formatting
petrutlucian94 01eecbd
Restore Tics and Trivy workflow logic
petrutlucian94 bba2985
Address PR comments
petrutlucian94 abc4e01
inspect.sh: rename --detailed to --all-namespaces
petrutlucian94 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 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 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 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,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$(realpath $(dirname "$BASH_SOURCE")) | ||
|
||
set -ex | ||
cd "${SCRIPT_DIR}/.." | ||
|
||
sudo apt-get update | ||
sudo apt-get install -y python3-venv | ||
python3 -m venv .venv/tics | ||
source .venv/tics/bin/activate | ||
|
||
# Install python dependencies | ||
pip install -r tests/integration/requirements-test.txt | ||
pip install -r tests/integration/requirements-dev.txt | ||
petrutlucian94 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
cd src/k8s | ||
|
||
# TICS requires us to have the test results in cobertura xml format under the | ||
# directory use below | ||
sudo make go.unit | ||
go install github.com/boumenot/gocover-cobertura@latest | ||
gocover-cobertura < coverage.txt > coverage.xml | ||
mkdir -p .coverage | ||
mv ./coverage.xml ./.coverage/ | ||
|
||
# Install the TICS and staticcheck | ||
go install honnef.co/go/tools/cmd/[email protected] | ||
. <(curl --silent --show-error 'https://canonical.tiobe.com/tiobeweb/TICS/api/public/v1/fapi/installtics/Script?cfg=default&platform=linux&url=https://canonical.tiobe.com/tiobeweb/TICS/') | ||
|
||
# We need to have our project built | ||
# We load the dqlite libs here instead of doing through make because TICS | ||
# will try to build parts of the project itself | ||
sudo add-apt-repository -y ppa:dqlite/dev | ||
sudo apt-get install -y dqlite-tools-v2 libdqlite1.17-dev | ||
sudo make clean | ||
go build -a ./... | ||
|
||
TICSQServer -project k8s-snap -tmpdir /tmp/tics -branchdir $SCRIPT_DIR/.. |
This file contains 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,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$(realpath $(dirname "$BASH_SOURCE")) | ||
|
||
set -ex | ||
cd "${SCRIPT_DIR}/.." | ||
|
||
SNAP_PATH="$1" | ||
if [[ ! -f $SNAP_PATH ]]; then | ||
echo "Usage: $0 <snap_path>" | ||
exit 1 | ||
fi | ||
|
||
# Setup Trivy vulnerability scanner | ||
mkdir -p manual-trivy/sarifs | ||
pushd manual-trivy | ||
VER=$(curl --silent -qI https://github.com/aquasecurity/trivy/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}'); | ||
wget https://github.com/aquasecurity/trivy/releases/download/${VER}/trivy_${VER#v}_Linux-64bit.tar.gz | ||
tar -zxvf ./trivy_${VER#v}_Linux-64bit.tar.gz | ||
popd | ||
|
||
# Run Trivy vulnerability scanner in repo mode | ||
./manual-trivy/trivy fs . \ | ||
--format sarif \ | ||
--db-repository public.ecr.aws/aquasecurity/trivy-db \ | ||
--severity "MEDIUM,HIGH,CRITICAL" \ | ||
--ignore-unfixed \ | ||
> ./manual-trivy/sarifs/trivy-k8s-repo-scan--results.sarif | ||
|
||
for var in $(env | grep -o '^TRIVY_[^=]*'); do | ||
unset "$var" | ||
done | ||
cp "${SNAP_PATH}" ./k8s-test.snap | ||
rm -rf ./squashfs-root | ||
unsquashfs k8s-test.snap | ||
./manual-trivy/trivy rootfs ./squashfs-root/ \ | ||
--format sarif \ | ||
--db-repository public.ecr.aws/aquasecurity/trivy-db \ | ||
> ./manual-trivy/sarifs/snap.sarif |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bash is such a beautiful and simple language.