start/sniff-start: refuse to run in Windows-hosted shells

A Windows user could run the bash launchers from WSL or Git Bash / MSYS2 /
MinGW / Cygwin, where the Linux USB assumptions do not hold: WSL cannot reach
the Windows SIMtrace2 device, and those shells have no Linux /sys + /dev/bus/usb
view for the udev pre-flight.  Both launchers now detect a Windows host up
front (WSL via /proc/version, the rest via uname -s) and exit 2 with a pointer
at the matching .bat launcher, which drives the Windows Python/PyUSB stack.
The message goes to stderr; a deliberate WSL/Cygwin flow can still run the
Python module directly (noted in the source comment).

Tests: tests/test_launchers.py runs each script with a fake mingw uname and
asserts exit 2 plus the start.bat/sniff-start.bat pointer, pins the WSL
detection, and checks bash -n syntax (skipped when bash is absent).

Bumps 2.7.14 (version.py, pyproject, PWA_VERSION), SW cache v96, the README
download examples and the release-notes preamble.  561 Python + 80 Node tests.
This commit is contained in:
catarrh committed 2026-11-04 19:30:41 +03:00
1 parent 8a7bfe87d1
commit 5a41de092c
11 files changed
+124 -11

No files matched your search

+4
View File
@@ -13,6 +13,10 @@ The source archive is the same tree a clone would have: unzip it and run
`./start.sh` (Linux/macOS) or `start.bat` (Windows). Direct SIMtrace2 capture
on Linux additionally needs the attached `70-simtrace2-pysniff.rules` udev rule.
The `.sh` launchers are for Linux/macOS only: on Windows use `start.bat` /
`sniff-start.bat` from `cmd.exe` or PowerShell (WSL, Git Bash, MSYS2, MinGW and
Cygwin are refused).
**Runtime zip (no installer)** — `simtrace-analyser-*.zip`
is the runtime tree only (packages, PWA, launchers, docs — no tests, no git):
extract it anywhere and run `start.bat` (Windows) or `./start.sh`
+8 -3
View File
@@ -47,7 +47,7 @@ http://127.0.0.1:8081/.
The wheel includes the UI, so the server serves it by itself:
```sh
pip install ./simtrace_analyser-2.7.13-py3-none-any.whl
pip install ./simtrace_analyser-2.7.14-py3-none-any.whl
simtrace-analyser-server --capture gsmtap
```
@@ -61,7 +61,7 @@ Every artifact is on the
CLI can pick the latest one:
```sh
pip install https://github.com/anttro/simtrace-analyser/releases/download/v2.7.13/simtrace_analyser-2.7.13-py3-none-any.whl
pip install https://github.com/anttro/simtrace-analyser/releases/download/v2.7.14/simtrace_analyser-2.7.14-py3-none-any.whl
# or:
gh release download --pattern '*.whl'
pip install ./simtrace_analyser-*.whl
@@ -69,7 +69,7 @@ pip install ./simtrace_analyser-*.whl
### 2. Zip (no installer)
Download `simtrace-analyser-2.7.13.zip` from the release page and extract it
Download `simtrace-analyser-2.7.14.zip` from the release page and extract it
anywhere: it is the runtime tree (the Python packages, the web UI, the launchers
and the docs — no tests, no git). The archive works on any OS; then run:
@@ -167,6 +167,11 @@ start.bat --capture direct
start.bat --capture disabled
```
On Windows use `start.bat` / `sniff-start.bat` from `cmd.exe` or PowerShell:
the `.sh` launchers refuse to run in WSL (the Linux guest cannot reach the
Windows SIMtrace2 USB device) and in Git Bash / MSYS2 / MinGW / Cygwin (no
Linux `/sys` + `/dev/bus/usb` view for the udev checks).
Options pass through unchanged (`./start.sh --capture direct --port 8080`).
The server logs its capture liveness to stderr (each line timestamped
+8 -3
View File
@@ -47,7 +47,7 @@ http://127.0.0.1:8081/.
Wheel содержит интерфейс внутри пакета, поэтому сервер отдаёт его сам:
```sh
pip install ./simtrace_analyser-2.7.13-py3-none-any.whl
pip install ./simtrace_analyser-2.7.14-py3-none-any.whl
simtrace-analyser-server --capture gsmtap
```
@@ -61,7 +61,7 @@ Fedora), сначала создайте виртуальное окружени
CLI — выбрать последнюю:
```sh
pip install https://github.com/anttro/simtrace-analyser/releases/download/v2.7.13/simtrace_analyser-2.7.13-py3-none-any.whl
pip install https://github.com/anttro/simtrace-analyser/releases/download/v2.7.14/simtrace_analyser-2.7.14-py3-none-any.whl
# или:
gh release download --pattern '*.whl'
pip install ./simtrace_analyser-*.whl
@@ -69,7 +69,7 @@ pip install ./simtrace_analyser-*.whl
### 2. Zip (без установки)
Скачайте `simtrace-analyser-2.7.13.zip` со страницы релиза и распакуйте в любое
Скачайте `simtrace-analyser-2.7.14.zip` со страницы релиза и распакуйте в любое
место: это рабочее дерево (пакеты Python, интерфейс, скрипты запуска и документация —
без тестов и git). Архив подходит для любой ОС. Затем запустите.
@@ -169,6 +169,11 @@ start.bat --capture direct
start.bat --capture disabled
```
В Windows запускайте `start.bat` / `sniff-start.bat` из `cmd.exe` или
PowerShell: `.sh`-скрипты отказываются работать в WSL (гостевая Linux-система
не видит USB-устройство SIMtrace2) и в Git Bash / MSYS2 / MinGW / Cygwin (нет
Linux-представления `/sys` + `/dev/bus/usb` для проверок udev).
Параметры передаются как есть (`./start.sh --capture direct --port 8080`).
Сервер пишет в stderr информацию о жизненном цикле захвата (каждая строка
+1 -1
View File
@@ -3389,7 +3389,7 @@ function onSearchChange() {
}
// ──────────────────── Versioning ────────────────────
const PWA_VERSION = '2.7.13';
const PWA_VERSION = '2.7.14';
const MIN_SERVER_VERSION = '2.3.0';
function parseVersion(v) {
+1 -1
View File
@@ -1,4 +1,4 @@
const CACHE = 'simtrace-analyser-v95';
const CACHE = 'simtrace-analyser-v96';
const PRECACHE = [
'index.html',
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "simtrace-analyser"
version = "2.7.13"
version = "2.7.14"
description = "SIMtrace Analyser — APDU trace analyser for GSMTAP-SIM, SIMtrace2, PCAP/PCAPNG and COMPRION captures (bundles the simtrace2-pysniff utility)"
readme = {file = "README.md", content-type = "text/markdown"}
license = "MIT"
+1 -1
View File
@@ -1,3 +1,3 @@
"""Single source of truth for the SIMtrace Analyser version."""
__version__ = '2.7.13'
__version__ = '2.7.14'
+14
View File
@@ -8,6 +8,20 @@
set -euo pipefail
shopt -s nullglob
# Windows guard: sniff-start.sh is the native Linux/macOS launcher. Under WSL
# the Linux guest cannot reach the Windows SIMtrace2 USB device, and a Git Bash /
# MSYS2 / MinGW / Cygwin shell has no Linux /sys + /dev/bus/usb view for the
# permission pre-flight below. Use sniff-start.bat from cmd.exe or PowerShell,
# which drives the Windows Python/PyUSB stack. A deliberate WSL/Cygwin flow can
# run `python -m simtrace2_pysniff` directly.
if grep -qi microsoft /proc/version 2>/dev/null || \
uname -s 2>/dev/null | grep -qiE 'MINGW|MSYS|CYGWIN'; then
echo "Error: sniff-start.sh is the Linux/macOS helper and cannot run on Windows" >&2
echo "(WSL / MSYS2 / MinGW / Cygwin detected)." >&2
echo "Use sniff-start.bat from a Windows command prompt (cmd.exe / PowerShell) instead." >&2
exit 2
fi
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
GSMTAP="${GSMTAP:-}"
+14
View File
@@ -8,6 +8,20 @@
set -euo pipefail
shopt -s nullglob
# Windows guard: start.sh is the native Linux/macOS launcher. Under WSL the
# Linux guest cannot reach the Windows SIMtrace2 USB device, and a Git Bash /
# MSYS2 / MinGW / Cygwin shell has no Linux /sys + /dev/bus/usb view for the
# udev pre-flight below. Use start.bat from cmd.exe or PowerShell, which drives
# the Windows Python/PyUSB stack. A deliberate WSL/Cygwin flow can run
# `python -m simtrace_analyser` directly.
if grep -qi microsoft /proc/version 2>/dev/null || \
uname -s 2>/dev/null | grep -qiE 'MINGW|MSYS|CYGWIN'; then
echo "Error: start.sh is the Linux/macOS helper and cannot run on Windows" >&2
echo "(WSL / MSYS2 / MinGW / Cygwin detected)." >&2
echo "Use start.bat from a Windows command prompt (cmd.exe / PowerShell) instead." >&2
exit 2
fi
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
CAPTURE="${CAPTURE:-gsmtap}"
+71
View File
@@ -0,0 +1,71 @@
"""Tests for the bash launchers' Windows-hosted-shell guard."""
import os
import shutil
import stat
import subprocess
import tempfile
import unittest
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
BASH = shutil.which('bash')
LAUNCHERS = (
('start.sh', 'start.bat'),
('sniff-start.sh', 'sniff-start.bat'),
)
@unittest.skipUnless(BASH, 'bash is not installed')
class TestWindowsGuard(unittest.TestCase):
def _run_as_windows(self, script):
"""Run *script* with a fake `uname -s` naming a mingw host."""
with tempfile.TemporaryDirectory() as tmp:
fake = Path(tmp) / 'uname'
fake.write_text('#!/bin/sh\necho MINGW64_NT-10.0\n')
fake.chmod(0o755)
env = dict(os.environ)
env['PATH'] = tmp + os.pathsep + env.get('PATH', '')
return subprocess.run(
[BASH, str(REPO / script)], cwd=REPO, env=env,
capture_output=True, text=True, timeout=30)
def test_guard_exits_and_names_the_bat_launcher(self):
for script, bat in LAUNCHERS:
with self.subTest(script=script):
res = self._run_as_windows(script)
self.assertEqual(res.returncode, 2, res.stderr)
self.assertIn(
'Error: %s is the Linux/macOS helper and cannot run on '
'Windows' % script, res.stderr)
self.assertIn(
'(WSL / MSYS2 / MinGW / Cygwin detected).', res.stderr)
self.assertIn(
'Use %s from a Windows command prompt (cmd.exe / '
'PowerShell) instead.' % bat, res.stderr)
def test_guard_detects_wsl_and_native_windows_shells(self):
# The mingw/msys/cygwin branch is exercised above; pin the WSL branch
# and the exit code so a refactor cannot drop either detection.
for script, _ in LAUNCHERS:
with self.subTest(script=script):
src = (REPO / script).read_text()
self.assertIn('grep -qi microsoft /proc/version', src)
self.assertIn('MINGW|MSYS|CYGWIN', src)
self.assertIn('exit 2', src)
self.assertLess(src.index('Windows guard'),
src.index('PROJECT_DIR='),
'the guard must run before the launcher setup')
def test_shell_syntax(self):
for script, _ in LAUNCHERS:
with self.subTest(script=script):
res = subprocess.run(
[BASH, '-n', str(REPO / script)],
capture_output=True, text=True)
self.assertEqual(res.returncode, 0, res.stderr)
if __name__ == '__main__':
unittest.main()
+1 -1
View File
@@ -224,7 +224,7 @@ class TestImportEndpoint(unittest.TestCase):
class TestVersion(unittest.TestCase):
def test_package_version(self):
from simtrace2_pysniff import __version__
self.assertEqual(__version__, '2.7.13')
self.assertEqual(__version__, '2.7.14')
def test_status_includes_version(self):
import os