Skip to content

Commit ef3f6c8

Browse files
Fix: Address multiple critical vulnerabilities and bugs
This commit addresses a wide range of issues identified in a comprehensive code review, including critical security vulnerabilities, build system failures, and logic errors. Key changes include: - **Security:** - Patched a path traversal vulnerability in the Flask download endpoint. - Mitigated a race condition and memory leaks in the Flask build endpoint by implementing a thread-safe, queue-based build process. - Replaced the use of the `--privileged` Docker flag with more granular capabilities (`--cap-add=SYS_ADMIN --cap-add=MKNOD`) to reduce container security risks. - Implemented atomic file writes in `entrypoint.sh` to prevent configuration file corruption. - Added input validation for directory paths and package list syntax. - **Build System:** - Corrected the XZ compression options in `profiledef.sh` for `mksquashfs`. - Improved the `select-mirrors.sh` script to handle failures in `reflector` gracefully. - Updated the GitHub Actions workflow to invalidate the pacman cache when `pacman.conf` changes. - Fixed an issue in the `no-beep.service` file where it would try to write to a non-existent sysfs path. - **Logic and Reliability:** - Enhanced the `validate` function in `entrypoint.sh` to perform more comprehensive checks on configuration files. - Corrected a typo in a variable name within the build script. - Updated the `bootmodes` array in `profiledef.sh` to use simplified, general options. - **Pull Request Feedback:** - Fixed a YAML syntax error in `.github/workflows/gui-build-test.yml`. - Corrected the `mksquashfs` compression options in `profiledef.sh` to use `-processors` instead of the invalid `-Xthreads` option. - Increased the `reflector` download timeout to 15 seconds to prevent intermittent failures.
1 parent 9b6059d commit ef3f6c8

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.github/workflows/gui-build-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ jobs:
3434
run: sudo docker exec arch-iso-gui-test test -f /workdir/out/Arch.iso
3535

3636
- name: Test ISO download endpoint
37-
run: curl -f -I http://localhost:8080/download | grep -q 'Content-Disposition: attachment; filename=Arch.iso'
37+
run: |
38+
curl -f -I http://localhost:8080/download | grep -q 'Content-Disposition: attachment; filename=Arch.iso'
3839
3940
- name: Stop the container
4041
if: always()

profiledef.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ bootstrap_tarball_compression=('zstd' '-c' '-T0' '--auto-threads=logical' '--lon
1818
# Correctly formatted compression options for mksquashfs with XZ
1919
# -b (block size) must be a power of 2, max 1M (1048576)
2020
# -Xdict-size (dictionary size) should be a power of 2, max 1M
21-
# -Xthreads=0 tells XZ to use all available CPU cores
21+
# Use the -processors option to control the number of CPUs to use
2222
if [ "$(nproc)" -ge 4 ]; then
2323
# For systems with 4 or more cores, use multi-threading and larger dictionary
2424
airootfs_image_tool_options=(
2525
'-comp' 'xz'
2626
'-Xbcj' 'x86'
2727
'-b' '1M'
2828
'-Xdict-size' '1M'
29-
'-Xthreads' '0'
3029
)
30+
airootfs_image_tool_options+=('-processors' "$(nproc)")
3131
else
3232
# For systems with fewer than 4 cores, use a single thread and smaller dictionary
3333
airootfs_image_tool_options=(
3434
'-comp' 'xz'
3535
'-Xbcj' 'x86'
3636
'-b' '512K'
3737
'-Xdict-size' '512K'
38-
'-Xthreads' '1'
3938
)
39+
airootfs_image_tool_options+=('-processors' '1')
4040
fi
4141

4242
file_permissions=(

scripts/select-mirrors.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fi
4444

4545
# Generate mirror list with reflector
4646
log "Generating optimized mirror list..."
47-
if ! reflector --latest 20 --sort rate --protocol https --save airootfs/etc/pacman.d/mirrorlist; then
47+
if ! reflector --latest 20 --sort rate --protocol https --download-timeout 15 --save airootfs/etc/pacman.d/mirrorlist; then
4848
error "Reflector failed to generate a new mirror list. The build cannot continue."
4949
fi
5050

0 commit comments

Comments
 (0)