Enhance UFW error handling and simplify documentation#34
Merged
Conversation
- Enable strict Bash error handling - Add diagnostic ERR trap output - Move UFW status check after confirmation prompt - Create gzip-compressed UFW backup archives - Avoid SIGPIPE failures when confirming UFW rule deletion - Update v1.0.3 changelog
Up to standards ✅🟢 Issues
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the ufw-cloudflare.bash script by enabling strict Bash error handling, adding an ERR diagnostic trap, and simplifying/clarifying the rule modification flow and documentation so failures are easier to debug and recover from.
Changes:
- Enable
set -euo pipefailand add anERRtrap to surface failing commands/line numbers. - Rework backup/restore flow using a
modifications_in_progressboolean and gzip-compressed tar archives. - Adjust rule deletion/wait logic and reuse the Cloudflare comment constant for rule discovery.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| hardening/UFW Cloudflare/ufw-cloudflare.bash | Adds strict mode + ERR trap, revises backup/restore and rule update flow for Cloudflare-marked UFW rules. |
| hardening/UFW Cloudflare/CHANGELOG.md | Documents v1.0.3 changes and minor formatting/consistency updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Hunter T. <strangeranger@hthompson.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and fixes to the
ufw-cloudflare.bashscript, focusing on error handling, script robustness, and user experience. The most significant changes include stricter Bash error handling, a new diagnostic error trap, improved backup procedures, and more reliable rule modification logic.Error handling and robustness:
set -euo pipefailto ensure the script exits on errors and undefined variables.ERRtrap (on_err) that reports the failing command and line number before exiting, making debugging easier.Backup and restoration improvements:
Rule modification logic and user experience:
yes | ufw delete) is replaced with a singleyresponse to avoidSIGPIPEfailures underpipefail.Other improvements:
v1.0.3and the changelog is updated to reflect all recent changes. [1] [2]