Skip to content

Commit 7441566

Browse files
authored
Merge pull request #1846 from session-foundation/fix-enforce-static-builds-node
fix: enforce static builds for libsession-util-nodejs
2 parents 68d3b18 + 1e699c2 commit 7441566

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

.github/workflows/build-binaries.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ jobs:
167167
if: ${{ matrix.is_qa == true }}
168168
uses: ./actions/sed_for_qa
169169

170+
- name: Custom build for QA if needed
171+
uses: ./actions/enforce_static_builds
172+
170173
- name: Build
171174
run: pnpm run build
172175

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Enforce static builds link only to system libs'
2+
description: 'Enforce that the libsession-util-nodejs.node is only linking to system libraries'
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Check static library linkage
8+
shell: bash
9+
run: |
10+
if [ "$RUNNER_OS" == "Windows" ]; then
11+
echo "Skipping library check on Windows"
12+
exit 0
13+
fi
14+
15+
if ! find . -name 'libsession_util_nodejs.node' | grep -q .; then
16+
echo -e "\n\n\n\n\e[31;1mNo libsession_util_nodejs.node file found\e[0m\n\n\n"
17+
exit 1
18+
fi
19+
20+
echo "Found files:"
21+
find . -name 'libsession_util_nodejs.node' | while IFS= read -r f; do
22+
echo " $f"
23+
done
24+
25+
bad=
26+
27+
while IFS= read -r node_file; do
28+
if [ "$RUNNER_OS" == "macOS" ]; then
29+
if otool -L "$node_file" | \
30+
grep -Ev '^.*\.node:|^\t(/usr/lib/lib(System\.|c\+\+|objc))|/System/Library/Frameworks/(CoreFoundation|NetworkExtension|Foundation|Network)\.framework'; then
31+
bad=1
32+
fi
33+
elif [ "$RUNNER_OS" == "Linux" ]; then
34+
if ldd "$node_file" | grep -Ev '(linux-vdso|ld-linux-(x86-64|armhf|aarch64)|lib(pthread|dl|rt|stdc\+\+|gcc_s|c|m))\.so'; then
35+
bad=1
36+
fi
37+
else
38+
echo -e "\n\n\n\n\e[31;1mDon't know how to check linked libs on $RUNNER_OS\e[0m\n\n\n"
39+
exit 1
40+
fi
41+
done < <(find . -name 'libsession_util_nodejs.node')
42+
43+
if [ -n "$bad" ]; then
44+
echo -e "\n\n\n\n\e[31;1mlibsession-util-nodejs links to unexpected libraries\e[0m\n\n\n"
45+
exit 1
46+
fi
47+
48+
echo -e "\n\n\n\n\e[32;1mNo unexpected linked libraries found\e[0m\n\n\n"

0 commit comments

Comments
 (0)