Skip to content

Commit 971007f

Browse files
committed
Rebrand, move to GitHub and related changes
- Change name to 'libloadguard' as part of forking - Add GitHub CI, update README and remove unrelated files - Move code files to proper subdirectories and split Meson build files - Add pyproject.toml to create devenv with uv for Python script - Format, lint with ruff and type check with mypy - Add pytest tests for the Python script - Merge all C test files into one and remove test data as it is created in-place - Expose internal header for tests - Add integration tests for LD_AUDIT hook - Add uncrustify to format C code - Add hardening compile flags - Build with ASAN and -Werror in CI - Enable build for x86_64 and aarch64 - Enable Clang build - Format meson files properly - Add pre-commit config to run all build, tests, lints formats etc. - Add type hints to Python script - Install Python script only if Python requirements are met in Meson - Populate gitignore - Change default value of config file to /app/etc - Bump version to 26.05.0 - Update old copyright headers - Add shellcheck - Add Flatpak manifest and test with it in CI - Historical commits are merged per-commit author since most changes are not relevant right now
1 parent 7b93f8b commit 971007f

39 files changed

Lines changed: 3034 additions & 546 deletions

.github/dependencies.apt.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meson
2+
ninja-build
3+
python3-jsonschema
4+
python3-yaml

.github/workflows/check.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: main
6+
paths-ignore:
7+
- '.gitignore'
8+
- 'LICENSE'
9+
- 'README'
10+
- '.pre-commit-config.yaml'
11+
pull_request:
12+
branches: main
13+
paths-ignore:
14+
- '.gitignore'
15+
- 'LICENSE'
16+
- 'README'
17+
- '.pre-commit-config.yaml'
18+
workflow_dispatch:
19+
20+
jobs:
21+
lint:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
timeout-minutes: 10
26+
steps:
27+
# 6.0.2
28+
- name: Checkout repository
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
30+
with:
31+
persist-credentials: false
32+
33+
- name: Install uv
34+
# 7.2.0
35+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b
36+
with:
37+
version: "0.9.21"
38+
enable-cache: true
39+
save-cache: ${{ github.ref == 'refs/heads/main' }}
40+
cache-dependency-glob: |
41+
**/uv.lock
42+
**/pyproject.toml
43+
44+
- name: Install python dependencies
45+
run: uv sync --all-extras --all-groups --frozen
46+
47+
- name: Check Python code formatting
48+
run: uv run ruff format --check
49+
50+
- name: Check Python code lint
51+
run: uv run ruff check --output-format=github
52+
53+
- name: Check Python code types
54+
run: uv run mypy .
55+
56+
- name: Run tests
57+
run: uv run pytest
58+
59+
flatpak:
60+
strategy:
61+
matrix:
62+
os: ['ubuntu-24.04', 'ubuntu-24.04-arm']
63+
runs-on: ${{ matrix.os }}
64+
permissions:
65+
contents: read
66+
timeout-minutes: 30
67+
steps:
68+
- name: Install dependencies
69+
run: |
70+
sudo apt-get update
71+
sudo apt-get install -y flatpak flatpak-builder
72+
73+
# 6.0.2
74+
- name: Checkout repository
75+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
76+
with:
77+
persist-credentials: false
78+
79+
- uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae
80+
with:
81+
path: ${{ github.workspace }}/cache/.flatpak-builder
82+
key: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-${{ hashFiles('data/io.github.bbhtt.libloadguard.json') }}
83+
restore-keys: |
84+
${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-
85+
86+
- name: Build and run test
87+
run: |
88+
./tests/run_block_test.sh
89+
90+
# 5.0.5
91+
- uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae
92+
if: github.ref == 'refs/heads/main'
93+
with:
94+
path: ${{ github.workspace }}/cache/.flatpak-builder
95+
key: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-${{ hashFiles('data/io.github.bbhtt.libloadguard.json') }}
96+
97+
build:
98+
strategy:
99+
matrix:
100+
os: ['ubuntu-24.04', 'ubuntu-24.04-arm']
101+
compiler: ['gcc', 'clang']
102+
runs-on: ${{ matrix.os }}
103+
container:
104+
image: ubuntu:26.04
105+
options: --privileged
106+
permissions:
107+
contents: read
108+
timeout-minutes: 20
109+
env:
110+
CC: ${{ matrix.compiler }}
111+
BUILDDIR: builddir
112+
CONFIG_OPTS: -Dtests=true
113+
MESON_TEST_TIMEOUT_MULTIPLIER: 2
114+
DEBIAN_FRONTEND: noninteractive
115+
steps:
116+
- name: Install dependencies
117+
run: apt-get update && apt-get install -y git findutils
118+
119+
- name: Set git safe directory
120+
run: git config --global safe.directory "*"
121+
122+
# 6.0.2
123+
- name: Checkout repository
124+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
125+
with:
126+
persist-credentials: false
127+
128+
- name: Install build dependencies
129+
run: |
130+
apt-get install -y ${{ matrix.compiler }} uncrustify shellcheck \
131+
$(xargs < .github/dependencies.apt.txt)
132+
133+
- name: Run shellcheck
134+
run: ./shellcheck.sh
135+
136+
- name: Run uncrustify
137+
run: ./uncrustify.sh && git diff --exit-code
138+
139+
- name: Configure with meson
140+
run: |
141+
if [ "${{ matrix.compiler }}" = "gcc" ]; then
142+
SANITIZE_OPTS="-Db_sanitize=address,undefined"
143+
else
144+
SANITIZE_OPTS=""
145+
fi
146+
147+
meson setup --wrap-mode nodownload ${CONFIG_OPTS} \
148+
-Dwerror=true ${SANITIZE_OPTS} ${BUILDDIR} .
149+
150+
- name: Build with meson
151+
run: meson compile -C ${BUILDDIR}
152+
153+
- name: Run tests with Meson
154+
env:
155+
ASAN_OPTIONS: "detect_leaks=1:fast_unwind_on_malloc=0:malloc_context_size=20:symbolize=1"
156+
UBSAN_OPTIONS: "print_stacktrace=1"
157+
run: |
158+
export LSAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/tests/lsan.supp"
159+
meson test -C ${BUILDDIR} --verbose --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER}
160+
161+
- name: Upload test logs
162+
# 7.0.0
163+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
164+
if: failure() || cancelled()
165+
with:
166+
name: test logs
167+
path: |
168+
builddir/meson-logs/testlog.txt
169+
installed-test-logs/
170+
171+
- name: Create dist tarball
172+
run: |
173+
meson setup --wrap-mode nodownload --reconfigure ${CONFIG_OPTS} ${BUILDDIR}_dist .
174+
meson dist --include-subprojects -C ${BUILDDIR}_dist

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
builddir/
2+
.flatpak-builder/
3+
.flatpak-builder-state/
4+
repo/
5+
build/
6+
.flatpak-test/
7+
8+
__pycache__/
9+
.venv/
10+
venv/
11+
.pytest_cache/
12+
.mypy_cache/
13+
.ruff_cache/

.gitlab-ci.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
default_install_hook_types:
2+
- pre-commit
3+
default_stages:
4+
- pre-commit
5+
fail_fast: true
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-added-large-files
13+
args: ['--maxkb=100']
14+
- id: check-shebang-scripts-are-executable
15+
- id: check-executables-have-shebangs
16+
- id: check-symlinks
17+
- id: mixed-line-ending
18+
args: [--fix=lf]
19+
20+
- repo: local
21+
hooks:
22+
- id: uv-lock
23+
name: uv lock
24+
description: Sync uv lock
25+
entry: uv lock --quiet
26+
language: python
27+
pass_filenames: false
28+
- id: ruff-format
29+
name: ruff format
30+
description: Format with ruff
31+
entry: uv run --frozen -q ruff format
32+
language: system
33+
pass_filenames: false
34+
- id: ruff-check
35+
name: ruff
36+
description: Lint with ruff
37+
entry: uv run --frozen -q ruff check --fix --exit-non-zero-on-fix
38+
language: system
39+
pass_filenames: false
40+
- id: mypy-check
41+
name: mypy
42+
description: Check types with mypy
43+
entry: uv run --frozen -q mypy .
44+
language: system
45+
pass_filenames: false
46+
files: \.py$
47+
- id: py-test
48+
name: pytest
49+
description: Run pytest
50+
entry: uv run --frozen -q pytest --ff --exitfirst
51+
language: system
52+
pass_filenames: false
53+
- id: shellcheck
54+
name: shellcheck
55+
language: system
56+
entry: bash -c 'git ls-files "*.sh" "*.bash" | xargs -r shellcheck -S warning'
57+
pass_filenames: false
58+
always_run: true
59+
- id: uncrustify
60+
name: uncrustify
61+
language: system
62+
entry: sh -c 'uncrustify -c uncrustify.cfg --no-backup $(git ls-files "*.c" "*.h") && git diff --exit-code'
63+
pass_filenames: false
64+
always_run: true
65+
- id: meson
66+
name: build and test with meson
67+
language: system
68+
entry: sh -c 'meson setup builddir --reconfigure -Dtests=true && meson compile -C builddir && meson test -C builddir'
69+
pass_filenames: false
70+
always_run: true

.ruff.toml

Lines changed: 0 additions & 23 deletions
This file was deleted.

LICENSE

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ safest to attach them to the start of each source file to most effectively
470470
convey the exclusion of warranty; and each file should have at least the
471471
"copyright" line and a pointer to where the full notice is found.
472472

473-
shared-library-guard
474-
Copyright (C) 2019 freedesktop-sdk
473+
libloadguard
474+
Copyright (C) 2026 bbhtt
475+
Copyright (C) 2019-2026 freedesktop-sdk
475476

476477
This library is free software; you can redistribute it and/or
477478
modify it under the terms of the GNU Lesser General Public

README

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
LD_AUDIT-based runtime shared library path filter to help Flatpak
2+
applications cope with badly behaving programs.
3+
4+
Versioning follows YY.MM.release
5+
6+
Format:
7+
8+
C code is formatted using Uncrustify [1]. `./uncrustify.sh` can be
9+
executed to format them.
10+
11+
Python devlopment environment can be set up using uv [2].
12+
13+
```
14+
uv sync --all-extras --all-groups --frozen
15+
uv run ruff format
16+
uv run ruff check . --fix
17+
```
18+
19+
Build:
20+
21+
```
22+
meson setup --reconfigure builddir -Dtests=true
23+
meson compile -C builddir
24+
```
25+
26+
Test:
27+
28+
```
29+
meson test -C builddir
30+
uv run pytest
31+
./tests/run_block_test.sh
32+
```
33+
34+
[1]: https://github.com/uncrustify/uncrustify
35+
[2]: https://docs.astral.sh/uv/

0 commit comments

Comments
 (0)