-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(workflow): optimize kernel-tracker.yml (#111)
* fix: attempt at optimizing kernel-tracker.yml * fix: if condition * fix: if condition with cache-hit * fix: if condition change * fix: linux repo * fix: rename step and cache
- Loading branch information
Showing
1 changed file
with
16 additions
and
23 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,46 +17,39 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
path: kunai | ||
|
||
# Define the variable (e.g., from a file or a specific command) | ||
- name: Define Cache Key Variable | ||
- name: Define Variable | ||
run: | | ||
LATEST_LINUX_VERSION=$(git ls-remote --tags https://github.com/torvalds/linux.git | grep -P 'refs/tags/v\d+\.\d+$' | awk '{print$NF}' | awk -F'/' '{print$NF}' | sort -V | tail -1) | ||
echo "cache-key=cache-linux-$LATEST_LINUX_VERSION" >> $GITHUB_ENV | ||
echo "latest-linux-version=$LATEST_LINUX_VERSION" >> $GITHUB_ENV | ||
- name: Cache | ||
id: cache-linux | ||
uses: actions/[email protected] | ||
with: | ||
# A list of files, directories, and wildcard patterns to cache and restore | ||
path: ~/linux/ | ||
path: ./linux/ | ||
# An explicit key for restoring and saving the cache | ||
key: ${{ env.cache-key }} | ||
key: cache-linux-${{ env.latest-linux-version }} | ||
|
||
- name: Clone Kernel | ||
run: | | ||
set -euxo pipefail | ||
if [ ! -d ~/linux ] | ||
then | ||
git clone https://github.com/torvalds/linux.git ~/linux | ||
fi | ||
# run the stuff only if we failed at retrieve from cache | ||
if: steps.cache-linux.outputs.cache-hit != 'true' | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: torvalds/linux | ||
ref: ${{ env.latest-linux-version }} | ||
path: ./linux | ||
|
||
- name: Checkout Latest Kernel | ||
run: | | ||
set -euxo pipefail | ||
cd ~/linux | ||
git checkout master | ||
git pull | ||
# checkout to latest stable version | ||
LATEST_VERSION=$(git tag | grep -P 'v\d+\.\d+$' | sort -V | tail -n 1) | ||
git checkout $LATEST_VERSION | ||
- name: Test Kunai Hooks | ||
run: | | ||
set -euxo pipefail | ||
# we get kernel functions prototypes | ||
grep -oPR --include='*.h' --include='*.c' '^(\w+\s+)+\w+\(' ~/linux | awk '{print$NF}' | tr -d '(' | sort -u > linux.sym | ||
grep -oPR --include='*.h' --include='*.c' '^(\w+\s+)+\w+\(' ./linux | awk '{print$NF}' | tr -d '(' | sort -u > linux.sym | ||
# we get kunai hook points (only kprobes for the moment) | ||
grep -iPR '#\[k(ret)?probe.*\]' kunai-ebpf | grep -oP 'function\s+=\s+"\w+?"' | cut -d '"' -f 2 | sort -u > probes.sym | ||
grep -iPR '#\[k(ret)?probe.*\]' ./kunai/kunai-ebpf | grep -oP 'function\s+=\s+"\w+?"' | cut -d '"' -f 2 | sort -u > probes.sym | ||
# we check that every function hooked in Kunai still exists in the kernel | ||
for p in $(cat probes.sym);do grep -P "^$p$" linux.sym ;done | ||
|