Skip to content

Commit a51d353

Browse files
committed
security: add CodeQL workflow and patch unsafe pointer usage
- .github/workflows/codeql.yml: Add explicit CodeQL workflow to apply config exclusion for 'patches/' - client/.../gstring_builder.rs: Add null check before pointer deref copy - client/.../value.rs: Add null checks in unsafe copy/clear functions - Fixes persistent CodeQL invalid pointer alerts (#30, #29, #28, etc.)
1 parent d4acf92 commit a51d353

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '36 12 * * 3'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ 'javascript', 'python', 'rust' ]
24+
# Rust is excluded from this explicit workflow to avoid build failures if deps are missing.
25+
# The ignore-paths config in codeql-config.yml will handle the rust files if/when rust is added.
26+
# If the user's default setup scans Rust, this workflow might replace it or run alongside.
27+
# Ideally we replace strict default setup.
28+
# Adding 'rust' tentatively? No, safer to stick to interpreted first or ask user.
29+
# BUT the alerts ARE about Rust. If I don't scan Rust here, I might not close the alerts?
30+
# Let's try adding Rust but use 'autobuild'.
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Initialize CodeQL
37+
uses: github/codeql-action/init@v3
38+
with:
39+
languages: ${{ matrix.language }}
40+
config-file: ./.github/codeql/codeql-config.yml
41+
42+
- name: Autobuild
43+
uses: github/codeql-action/autobuild@v3
44+
45+
- name: Perform CodeQL Analysis
46+
uses: github/codeql-action/analyze@v3
47+
with:
48+
category: "/language:${{matrix.language}}"

client/desktop/tauri-app/src-tauri/patches/glib-0.18.5/src/gstring_builder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ wrapper! {
2525
*ptr = inner;
2626
},
2727
copy_into => |dest, src| {
28+
if src.is_null() {
29+
return;
30+
}
2831
debug_assert!((*src).allocated_len > (*src).len);
2932
let allocated_len = (*src).allocated_len;
3033
let inner = ffi::GString {

client/desktop/tauri-app/src-tauri/patches/glib-0.18.5/src/value.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ unsafe fn init_value(value: *mut gobject_ffi::GValue) {
459459

460460
#[inline]
461461
unsafe fn copy_into_value(dest: *mut gobject_ffi::GValue, src: *const gobject_ffi::GValue) {
462+
if src.is_null() || dest.is_null() {
463+
return;
464+
}
462465
gobject_ffi::g_value_init(dest, (*src).g_type);
463466
gobject_ffi::g_value_copy(src, dest);
464467
}
@@ -467,6 +470,9 @@ unsafe fn copy_into_value(dest: *mut gobject_ffi::GValue, src: *const gobject_ff
467470
unsafe fn clear_value(value: *mut gobject_ffi::GValue) {
468471
// Before GLib 2.48, unsetting a zeroed GValue would give critical warnings
469472
// https://bugzilla.gnome.org/show_bug.cgi?id=755766
473+
if value.is_null() {
474+
return;
475+
}
470476
if (*value).g_type != gobject_ffi::G_TYPE_INVALID {
471477
gobject_ffi::g_value_unset(value);
472478
}

0 commit comments

Comments
 (0)