From 48ac6719b12e081defb8720f684a62533a78cd85 Mon Sep 17 00:00:00 2001 From: Zhongning Li <60045212+tomli380576@users.noreply.github.com> Date: Sat, 15 Aug 2026 23:55:56 +0800 Subject: [PATCH 1/6] feat: allow snap set jira url --- README.md | 11 +++++++++++ snap/hooks/configure | 16 ++++++++++++++++ snap/local/scripts/env_wrapper.sh | 8 ++++++-- snap/snapcraft.yaml | 5 +++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 snap/hooks/configure diff --git a/README.md b/README.md index eeeff09d..f5089730 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,17 @@ Run the app with `sudo bugit.bugit-v2 jira`, `sudo bugit.bugit-v2 lp`, or `sudo To uninstall, `sudo snap remove bugit` +### Jira Server Configuration + +The Jira server URL can be changed after install: + +```sh +sudo snap set bugit jira-server= +``` + +Run `sudo snap unset bugit jira-server` to revert to the default +(`https://warthogs.atlassian.net`). + ## How do I copy and paste? This varies across different terminal emulators so I'll use gnome-terminal as the example here since it comes with ubuntu by default (and by extension ptyxis that comes with 25.10). diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100755 index 00000000..02533fd2 --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Allows the Jira server URL to be changed at runtime with: +# sudo snap set bugit jira-server= +# Unsetting it (snap unset bugit jira-server) reverts to the default +# https://warthogs.atlassian.net, see snap/local/scripts/env_wrapper.sh + +set -e + +JIRA_SERVER="$(snapctl get jira-server)" + +if [ -n "$JIRA_SERVER" ]; then + echo "$JIRA_SERVER" > "$SNAP_DATA/jira-server-url" +else + rm -f "$SNAP_DATA/jira-server-url" +fi diff --git a/snap/local/scripts/env_wrapper.sh b/snap/local/scripts/env_wrapper.sh index 5b6566ac..a3637137 100755 --- a/snap/local/scripts/env_wrapper.sh +++ b/snap/local/scripts/env_wrapper.sh @@ -22,8 +22,12 @@ case "$SNAP_ARCH" in ;; esac -# PERL_VERSION=$(perl -e '$^V=~/^v(\d+\.\d+)/;print $1') -# export PERL5LIB="$PERL5LIB:$SNAP/usr/lib/$ARCH/perl/$PERL_VERSION:$SNAP/usr/lib/$ARCH/perl5/$PERL_VERSION:$SNAP/usr/share/perl/$PERL_VERSION:$SNAP/usr/share/perl5" + +# lets 'snap set bugit jira-server=' override the default +# JIRA_SERVER, see snap/hooks/configure +if [ -f "$SNAP_DATA/jira-server-url" ]; then + export JIRA_SERVER="$(cat "$SNAP_DATA/jira-server-url")" +fi # https://github.com/snapcrafters/get-iplayer/blob/candidate/snap/local/scripts/launcher exec "$@" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 3f046f80..838b6e4a 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -41,6 +41,9 @@ environment: # only used for launchpad BUGIT_APP_NAME: bugit-v2 # change this to the sandbox url for debug mode + # can be overridden after install with: + # sudo snap set bugit jira-server= + # see snap/hooks/configure and snap/local/scripts/env_wrapper.sh JIRA_SERVER: https://warthogs.atlassian.net # optional, lets apt installed python apps find their libraries PYTHONPATH: "$PYTHONPATH:$SNAP/usr/lib/python3/dist-packages" @@ -66,6 +69,8 @@ apps: completer: src/bugit_v2/bugit-completer.sh submit: + command-chain: + - env_wrapper.sh command: bin/python3 $SNAP/src/bugit_v2/apps/submit_local_archive.py dump-standard-info: From a87383da054714ae2d70cb8cb6fe11de230d1aaa Mon Sep 17 00:00:00 2001 From: Zhongning Li <60045212+tomli380576@users.noreply.github.com> Date: Sat, 15 Aug 2026 23:57:39 +0800 Subject: [PATCH 2/6] fix: invalidate credentials --- snap/hooks/configure | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index 02533fd2..362938d2 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -4,13 +4,30 @@ # sudo snap set bugit jira-server= # Unsetting it (snap unset bugit jira-server) reverts to the default # https://warthogs.atlassian.net, see snap/local/scripts/env_wrapper.sh +# +# Also invalidates any cached Jira credentials under /tmp when the +# server changes, since those credentials are tied to a specific server. set -e +CACHE_FILE="$SNAP_DATA/jira-server-url" + +OLD_JIRA_SERVER="" +if [ -f "$CACHE_FILE" ]; then + OLD_JIRA_SERVER="$(cat "$CACHE_FILE")" +fi + JIRA_SERVER="$(snapctl get jira-server)" if [ -n "$JIRA_SERVER" ]; then - echo "$JIRA_SERVER" > "$SNAP_DATA/jira-server-url" + echo "$JIRA_SERVER" > "$CACHE_FILE" else - rm -f "$SNAP_DATA/jira-server-url" + rm -f "$CACHE_FILE" +fi + +# the cached basic-auth credentials (see JiraSubmitter.name in +# jira_submitter.py) belong to a specific Jira server, so drop them +# whenever the server changes to force re-authentication +if [ "$JIRA_SERVER" != "$OLD_JIRA_SERVER" ]; then + rm -f /tmp/jira_submitter-credentials.json fi From 85edf1111f39dc57b61e959cea3959f15ff7aad0 Mon Sep 17 00:00:00 2001 From: Zhongning Li <60045212+tomli380576@users.noreply.github.com> Date: Sat, 15 Aug 2026 23:58:31 +0800 Subject: [PATCH 3/6] style: rename --- snap/hooks/configure | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index 362938d2..b2565140 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -10,19 +10,19 @@ set -e -CACHE_FILE="$SNAP_DATA/jira-server-url" +URL_FILE="$SNAP_DATA/jira-server-url" OLD_JIRA_SERVER="" -if [ -f "$CACHE_FILE" ]; then - OLD_JIRA_SERVER="$(cat "$CACHE_FILE")" +if [ -f "$URL_FILE" ]; then + OLD_JIRA_SERVER="$(cat "$URL_FILE")" fi JIRA_SERVER="$(snapctl get jira-server)" if [ -n "$JIRA_SERVER" ]; then - echo "$JIRA_SERVER" > "$CACHE_FILE" + echo "$JIRA_SERVER" > "$URL_FILE" else - rm -f "$CACHE_FILE" + rm -f "$URL_FILE" fi # the cached basic-auth credentials (see JiraSubmitter.name in From ba4ab95ddd61fdf88d4a47540734fddeba378c51 Mon Sep 17 00:00:00 2001 From: Zhongning Li <60045212+tomli380576@users.noreply.github.com> Date: Sun, 16 Aug 2026 00:01:39 +0800 Subject: [PATCH 4/6] fix: check for http urls --- snap/hooks/configure | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/snap/hooks/configure b/snap/hooks/configure index b2565140..d6a32627 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -20,6 +20,15 @@ fi JIRA_SERVER="$(snapctl get jira-server)" if [ -n "$JIRA_SERVER" ]; then + # only a lightweight sanity check: must be an http(s) URL with a host, + # not a full validation that it's a real/reachable Jira instance + case "$JIRA_SERVER" in + http://?*|https://?*) ;; + *) + echo "jira-server must be a valid URL, e.g. https://your-instance.atlassian.net (got: '$JIRA_SERVER')" >&2 + exit 1 + ;; + esac echo "$JIRA_SERVER" > "$URL_FILE" else rm -f "$URL_FILE" From 7263fefddc47752d46d7e0b6b8eb70f89ea42fa5 Mon Sep 17 00:00:00 2001 From: Zhongning Li <60045212+tomli380576@users.noreply.github.com> Date: Sun, 16 Aug 2026 00:11:29 +0800 Subject: [PATCH 5/6] doc: tell user this is possible at the auth screen --- src/bugit_v2/bug_report_submitters/jira_submitter.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bugit_v2/bug_report_submitters/jira_submitter.py b/src/bugit_v2/bug_report_submitters/jira_submitter.py index 83257230..4295a6c9 100644 --- a/src/bugit_v2/bug_report_submitters/jira_submitter.py +++ b/src/bugit_v2/bug_report_submitters/jira_submitter.py @@ -76,6 +76,14 @@ class JiraAuthModal(ModalScreen[tuple[JiraBasicAuth, bool] | None]): def compose(self) -> ComposeResult: with VerticalGroup(id="top_level_container"): yield Label(f"[b][$primary]Jira Authentication for {JIRA_SERVER_ADDRESS}") + if os.getenv("SNAP"): + # only relevant/actionable when running as a snap, so this + # is hidden for the pipx/source install where JIRA_SERVER + # is just a regular env var + yield Label( + "- Wrong server? Run " + + "[b]sudo snap set bugit jira-server=[/] to change it" + ) yield Input(placeholder="your.email@jira.com", id="email") yield Input( placeholder="A token can be created at the link below if you don't already have one", From 7163f43b912acb00001dcce9e910c67c49473738 Mon Sep 17 00:00:00 2001 From: Zhongning Li <60045212+tomli380576@users.noreply.github.com> Date: Sun, 16 Aug 2026 01:38:25 +0800 Subject: [PATCH 6/6] fix: stricter check --- snap/hooks/configure | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index d6a32627..0e7dac70 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -20,15 +20,13 @@ fi JIRA_SERVER="$(snapctl get jira-server)" if [ -n "$JIRA_SERVER" ]; then - # only a lightweight sanity check: must be an http(s) URL with a host, - # not a full validation that it's a real/reachable Jira instance - case "$JIRA_SERVER" in - http://?*|https://?*) ;; - *) - echo "jira-server must be a valid URL, e.g. https://your-instance.atlassian.net (got: '$JIRA_SERVER')" >&2 - exit 1 - ;; - esac + # only a lightweight sanity check: must be an http(s) URL with a host + # made up of valid URL characters (no whitespace or other invalid + # chars), not a full validation that it's a real/reachable Jira instance + if ! printf '%s' "$JIRA_SERVER" | grep -Eq '^https?://[A-Za-z0-9._~:/?#@!$&()*+,;=%-]+$'; then + echo "jira-server must be a valid URL with no whitespace or invalid characters, e.g. https://your-instance.atlassian.net (got: '$JIRA_SERVER')" >&2 + exit 1 + fi echo "$JIRA_SERVER" > "$URL_FILE" else rm -f "$URL_FILE"