Skip to content

Commit 95eb1ef

Browse files
authored
Merge pull request #2146 from profanity-im/wip
Misc improvements
2 parents c0f96e9 + 4be8ec4 commit 95eb1ef

6 files changed

Lines changed: 163 additions & 3 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: "CodeQL"
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
analyze:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
actions: read
12+
contents: read
13+
security-events: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Initialize CodeQL
20+
uses: github/codeql-action/init@v3
21+
with:
22+
languages: 'c-cpp'
23+
24+
- name: Install system dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y --no-install-recommends \
28+
libcmocka-dev libcurl4-openssl-dev libgcrypt20-dev libglib2.0-dev \
29+
libgpgme-dev libgtk-3-dev libmicrohttpd-dev libncursesw5-dev \
30+
libnotify-dev libotr5-dev libreadline-dev libsignal-protocol-c-dev \
31+
libomemo-c-dev libssl-dev libtool libxss-dev meson ninja-build \
32+
pkg-config python3-dev python-dev-is-python3 libsqlite3-dev \
33+
libgdk-pixbuf-2.0-dev libqrencode-dev libenchant-2-dev \
34+
autoconf autoconf-archive automake cmake expect
35+
36+
- name: Install stabber and libstrophe
37+
run: |
38+
git clone --depth 1 https://github.com/profanity-im/stabber /tmp/stabber
39+
cd /tmp/stabber && ./bootstrap.sh && ./configure --prefix=/usr && make -j$(nproc) && sudo make install
40+
41+
git clone --depth 1 https://github.com/strophe/libstrophe /tmp/libstrophe
42+
cd /tmp/libstrophe && ./bootstrap.sh && ./configure --prefix=/usr && make -j$(nproc) && sudo make install
43+
44+
- name: Build for Analysis
45+
run: |
46+
meson setup build_codeql \
47+
-Dnotifications=enabled \
48+
-Dpython-plugins=enabled \
49+
-Dc-plugins=enabled \
50+
-Dotr=enabled \
51+
-Dpgp=enabled \
52+
-Domemo=enabled \
53+
-Domemo-qrcode=enabled \
54+
-Dicons-and-clipboard=enabled \
55+
-Dgdk-pixbuf=enabled \
56+
-Dxscreensaver=enabled \
57+
-Dspellcheck=enabled \
58+
-Dtests=false
59+
meson compile -C build_codeql
60+
61+
- name: Perform CodeQL Analysis
62+
uses: github/codeql-action/analyze@v3
63+
with:
64+
category: "/language:c-cpp"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-func-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
functional-tests:
15+
runs-on: ubuntu-latest
16+
name: ubuntu | func | signal
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install system dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y --no-install-recommends \
24+
libcmocka-dev libcurl4-openssl-dev libgcrypt20-dev libglib2.0-dev \
25+
libgpgme-dev libgtk-3-dev libmicrohttpd-dev libncursesw5-dev \
26+
libnotify-dev libotr5-dev libreadline-dev libsignal-protocol-c-dev \
27+
libomemo-c-dev libssl-dev libtool libxss-dev meson ninja-build \
28+
pkg-config python3-dev python-dev-is-python3 libsqlite3-dev \
29+
libgdk-pixbuf-2.0-dev libqrencode-dev libenchant-2-dev \
30+
autoconf autoconf-archive automake cmake expect
31+
32+
- name: Install stabber
33+
run: |
34+
git clone --depth 1 https://github.com/profanity-im/stabber /tmp/stabber
35+
cd /tmp/stabber
36+
./bootstrap.sh
37+
./configure --prefix=/usr
38+
make -j$(nproc)
39+
sudo make install
40+
41+
- name: Install libstrophe (master)
42+
run: |
43+
git clone --depth 1 https://github.com/strophe/libstrophe /tmp/libstrophe
44+
cd /tmp/libstrophe
45+
./bootstrap.sh
46+
./configure --prefix=/usr
47+
make -j$(nproc)
48+
sudo make install
49+
50+
- name: Configure and Build
51+
run: |
52+
# Use --buildtype=debugoptimized (-O2) for fast execution.
53+
# Explicitly disable sanitizers to avoid the performance penalty.
54+
meson setup build_run \
55+
--buildtype=debugoptimized \
56+
-Db_sanitize=none \
57+
-Dnotifications=enabled \
58+
-Dpython-plugins=enabled \
59+
-Dc-plugins=enabled \
60+
-Dotr=enabled \
61+
-Dpgp=enabled \
62+
-Domemo=enabled \
63+
-Domemo-qrcode=enabled \
64+
-Dicons-and-clipboard=enabled \
65+
-Dgdk-pixbuf=enabled \
66+
-Dxscreensaver=enabled \
67+
-Dspellcheck=enabled \
68+
-Dtests=true
69+
meson compile -C build_run profanity:executable functionaltests
70+
71+
- name: Verify Profanity Binary
72+
run: |
73+
./build_run/profanity --version
74+
75+
- name: Run Functional Tests
76+
env:
77+
TERM: xterm
78+
LC_ALL: C.UTF-8
79+
run: |
80+
./build_run/functionaltests

CONTRIBUTING.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ Functional tests use [stabber](https://github.com/profanity-im/stabber) to simul
237237
**Performance Note:** It is highly recommended to run functional tests **without** sanitizers (**ASan** and **UBSan**). These sanitizers add significant overhead that can cause functional tests to time out or take an excessively long time to complete.
238238

239239
* **Meson:** Ensure `-Db_sanitize=none` is set in your build configuration. You can check your current configuration with `meson configure build_run | grep b_sanitize`.
240-
* **Autotools:** Ensure your `CFLAGS` does not contain `-fsanitize=address` or `-fsanitize=undefined`.
241240

242241
To run functional tests, you need the same dependencies as unit tests (`cmocka`) plus `stabber` and `libutil`.
243242

@@ -288,6 +287,20 @@ scan-build meson setup build_run
288287
scan-build meson compile -C build_run
289288
```
290289

290+
### Runtime Analysis with Sanitizers
291+
Developers and testers should compile and run Profanity with **AddressSanitizer (ASan)** and **UndefinedBehaviorSanitizer (UBSan)** enabled. While static analysis can find potential issues in the source code, sanitizers monitor the application while it is actually running.
292+
293+
By running the application and exercising specific features, you trigger real world code paths that might contain memory leaks, buffer overflows, or undefined behavior that only manifest at runtime.
294+
295+
To build with sanitizers enabled and enable debug logging:
296+
```bash
297+
meson setup build_run -Db_sanitize=address,undefined
298+
meson compile -C build_run
299+
./build_run/profanity -l DEBUG
300+
```
301+
302+
**Performance Note:** Sanitizers add significant overhead.
303+
291304
### Finding typos
292305
We include a `.codespellrc` configuration file for `codespell` in the root directory.
293306
Before committing it might make sense to run `codespell` to see if you made any typos.

scripts/build-configuration-matrix.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fi
9494
if [[ "$ARCH" == linux* ]]; then
9595
echo -e "${YELLOW}--> Running Valgrind check with full features ${BACKEND_OPT} ${EXTRA_ARGS}${NC}"
9696
rm -rf build_valgrind
97-
meson setup build_valgrind ${tests[0]} ${BACKEND_OPT} -Dtests=true -Db_sanitize=address,undefined ${EXTRA_ARGS}
97+
meson setup build_valgrind ${tests[0]} ${BACKEND_OPT} -Dtests=true -Db_sanitize=undefined ${EXTRA_ARGS}
9898
meson compile -C build_valgrind
9999
meson test -C build_valgrind "unit tests" --print-errorlogs --wrap=valgrind || echo "Valgrind issues detected"
100100
rm -rf build_valgrind

src/command/cmd_defs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,7 @@ static const struct cmd_t command_defs[] = {
21422142
"/account set me status dnd",
21432143
"/account set me dnd -1",
21442144
"/account set me clientid \"Profanity 0.42 (Dev)\"",
2145+
"/account set me eval_password \"pass \\\"Test Accounts/my user\\\"\"",
21452146
"/account rename me chattyme",
21462147
"/account clear me pgpkeyid")
21472148
},

src/tools/editor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ launch_editor(gchar* initial_content, void (*callback)(gchar* content, void* dat
128128
return TRUE;
129129
} else if (pid == 0) {
130130
// Child process: Inherits TTY from parent
131-
execvp(editor_argv[0], editor_argv);
131+
if (editor_argv && editor_argv[0]) {
132+
execvp(editor_argv[0], editor_argv);
133+
}
132134
_exit(EXIT_FAILURE);
133135
}
134136

0 commit comments

Comments
 (0)