Skip to content

Commit e766aa1

Browse files
Crash0v3rrid3claude
andcommitted
fix(scripts): scope quarantine-strip to cli.sh; drop spm.sh strip; chmod 0755 (DEVA11Y-752)
Address PR review (maunilm): - P1: remove the com.apple.quarantine strip from the three spm.sh scripts. The SPM plugin downloads AND execs the binary within a single `swift package plugin scan` invocation, so a shell-level strip before that call cannot cover a cold cache or a CLI version bump — the first run in an MDM environment would still fail. Rather than ship a partial mitigation that reads as full coverage, spm.sh is reverted to main; the plugin-side fix (strip at the download site) / notarization is tracked as a follow-up. - P2b: cli.sh downloads a binary that nothing else verifies and Gatekeeper no longer gates, so tighten its permissions from 0775 (group-writable — the macOS primary group `staff` includes every local user) to 0755. The cli.sh strip is unchanged and remains full coverage: download_binary re-extracts and strips on every invocation, so the strip always lands after the write. Sidecars regenerated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8e23091 commit e766aa1

12 files changed

Lines changed: 9 additions & 54 deletions

File tree

scripts/bash/cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ strip_quarantine() {
192192

193193
download_binary() {
194194
curl -R -z "$BINARY_ZIP_PATH" -L "https://api.browserstack.com/sdk/v1/download_cli?os=${OS}&os_arch=${ARCH}" -o "$BINARY_ZIP_PATH"
195-
bsdtar -xvf "$BINARY_ZIP_PATH" -O > "$BINARY_PATH" && chmod 0775 "$BINARY_PATH" && strip_quarantine
195+
bsdtar -xvf "$BINARY_ZIP_PATH" -O > "$BINARY_PATH" && chmod 0755 "$BINARY_PATH" && strip_quarantine
196196
}
197197

198198
# Self-update is opt-in (DEVA11Y-475): it runs only via the explicit `self-update`

scripts/bash/cli.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
90218e86363718406766c63830bac54f4c390030df0bc702fb95b3f032843545 cli.sh
1+
2dc6f5c62109ff1ae5185c417ea3896e4bb9f326ce91764e87161d1d27f976fb cli.sh

scripts/bash/spm.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,6 @@ EOF
131131
}
132132
trap cleanup EXIT
133133

134-
# macOS Gatekeeper refuses to run binaries carrying the com.apple.quarantine
135-
# attribute unless they are Developer ID signed and notarized. Some managed
136-
# environments (MDM/security tooling) stamp it on network-written files, which
137-
# blocks the SPM plugin's cached CLI with no "Allow Anyway" option. Strip it
138-
# from any cached binary. No-op off macOS / when the cache or attr is absent.
139-
# The plugin runs below under `env -i`, which drops XDG_CACHE_HOME, so it always
140-
# resolves its cache to $HOME/.cache (see Plugins/.../BrowserStackAccessibilityLint.swift).
141-
# Mirror that here rather than the outer shell's XDG_CACHE_HOME, or the strip
142-
# would miss the plugin's real binary when that var is set to a custom path.
143-
if [[ "$(uname -s)" == "Darwin" ]] && command -v xattr >/dev/null 2>&1; then
144-
cli_cache="$HOME/.cache/browserstack/devtools/spm-plugin"
145-
[ -d "$cli_cache" ] && find "$cli_cache" -type f -name 'browserstack-cli' \
146-
-exec xattr -d com.apple.quarantine {} \; 2>/dev/null || true
147-
fi
148-
149134
if [[ -z "$EXTRA_ARGS" ]]; then
150135
EXTRA_ARGS="--include **/*.swift --include **/*.xib --include **/*.storyboard"
151136
fi

scripts/bash/spm.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0559b6ab17f8cceb44a5defe9a88b5dcd54eaa5a72e7a4f7b5fcee1f13be9be1 spm.sh
1+
b520c458bec538505c9ff9ca75a02ec901597fd66b3c2d951b928e58e58e60da spm.sh

scripts/fish/cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ strip_quarantine() {
204204

205205
download_binary() {
206206
curl -R -z "$BINARY_ZIP_PATH" -L "https://api.browserstack.com/sdk/v1/download_cli?os=${OS}&os_arch=${ARCH}" -o "$BINARY_ZIP_PATH"
207-
bsdtar -xvf "$BINARY_ZIP_PATH" -O > "$BINARY_PATH" && chmod 0775 "$BINARY_PATH" && strip_quarantine
207+
bsdtar -xvf "$BINARY_ZIP_PATH" -O > "$BINARY_PATH" && chmod 0755 "$BINARY_PATH" && strip_quarantine
208208
}
209209

210210
# Self-update is opt-in (DEVA11Y-475): it runs only via the explicit `self-update`

scripts/fish/cli.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3e8fe00cebdcb140c4c1f8029c01e96d72cf906e681597317be60bed5e9db2a5 cli.sh
1+
6a83801b611b3550f46c91daeaeaa8233644d8edd0092e4dfd92098d268e63d4 cli.sh

scripts/fish/spm.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,6 @@ EOF
144144
}
145145
trap cleanup EXIT
146146

147-
# macOS Gatekeeper refuses to run binaries carrying the com.apple.quarantine
148-
# attribute unless they are Developer ID signed and notarized. Some managed
149-
# environments (MDM/security tooling) stamp it on network-written files, which
150-
# blocks the SPM plugin's cached CLI with no "Allow Anyway" option. Strip it
151-
# from any cached binary. No-op off macOS / when the cache or attr is absent.
152-
# The plugin runs below under `env -i`, which drops XDG_CACHE_HOME, so it always
153-
# resolves its cache to $HOME/.cache (see Plugins/.../BrowserStackAccessibilityLint.swift).
154-
# Mirror that here rather than the outer shell's XDG_CACHE_HOME, or the strip
155-
# would miss the plugin's real binary when that var is set to a custom path.
156-
if [[ "$(uname -s)" == "Darwin" ]] && command -v xattr >/dev/null 2>&1; then
157-
cli_cache="$HOME/.cache/browserstack/devtools/spm-plugin"
158-
[ -d "$cli_cache" ] && find "$cli_cache" -type f -name 'browserstack-cli' \
159-
-exec xattr -d com.apple.quarantine {} \; 2>/dev/null || true
160-
fi
161-
162147
if [[ -z "$EXTRA_ARGS" ]]; then
163148
EXTRA_ARGS="--include **/*.swift --include **/*.xib --include **/*.storyboard"
164149
fi

scripts/fish/spm.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bfc7fbcf9b3df10c4352bc426566a605a1a14554233ed649899cb045efdb5024 spm.sh
1+
982bbb10bb9bd55428208454a766384fae58c41dacabb1e5b8a74d2366f0d1e7 spm.sh

scripts/zsh/cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ strip_quarantine() {
203203

204204
download_binary() {
205205
curl -R -z "$BINARY_ZIP_PATH" -L "https://api.browserstack.com/sdk/v1/download_cli?os=${OS}&os_arch=${ARCH}" -o "$BINARY_ZIP_PATH"
206-
bsdtar -xvf "$BINARY_ZIP_PATH" -O > "$BINARY_PATH" && chmod 0775 "$BINARY_PATH" && strip_quarantine
206+
bsdtar -xvf "$BINARY_ZIP_PATH" -O > "$BINARY_PATH" && chmod 0755 "$BINARY_PATH" && strip_quarantine
207207
}
208208

209209
# Self-update is opt-in (DEVA11Y-475): it runs only via the explicit `self-update`

scripts/zsh/cli.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
713db299874844d7b2a182250864d9703a21c3a7602240ffc413ad40ee7af8e2 cli.sh
1+
0f6344ba1db459bfa34bde971294215e883649e3107842cb585accf83349c462 cli.sh

0 commit comments

Comments
 (0)