Skip to content

Commit d6f5738

Browse files
committed
wifi: fix SSID extraction to match correct field in security output
1 parent 34169d1 commit d6f5738

4 files changed

Lines changed: 79 additions & 9 deletions

File tree

src/import_installed.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,28 @@ fi
6060
check_homebrew_api() {
6161
local app=$1
6262
local type=$2
63-
63+
# Use a short timeout and return 0 only on a successful HTTP 200 response
64+
local url
6465
if [ "$type" = "cask" ]; then
65-
curl -s -f -o /dev/null "https://formulae.brew.sh/api/cask/${app}.json"
66+
url="https://formulae.brew.sh/api/cask/${app}.json"
6667
else
67-
curl -s -f -o /dev/null "https://formulae.brew.sh/api/formula/${app}.json"
68+
url="https://formulae.brew.sh/api/formula/${app}.json"
6869
fi
70+
local http
71+
http=$(curl -sS --max-time 6 -o /dev/null -w "%{http_code}" "$url" 2>/dev/null) || http=""
72+
[ "$http" = "200" ]
6973
}
7074

7175
check_chocolatey_api() {
7276
local app=$1
73-
curl -s -f "https://community.chocolatey.org/api/v2/Packages()?%24filter=tolower(Id)%20eq%20tolower('${app}')" | grep -q "${app}"
77+
local url="https://community.chocolatey.org/api/v2/Packages()?%24filter=tolower(Id)%20eq%20tolower('${app}')&%24select=Id"
78+
local out
79+
out=$(curl -sS --max-time 8 "$url" 2>/dev/null) || out=""
80+
if [ -z "$out" ]; then
81+
return 1
82+
fi
83+
# case-insensitive match of app id in returned XML/JSON
84+
echo "$out" | tr '[:upper:]' '[:lower:]' | grep -q "$(echo "$app" | tr '[:upper:]' '[:lower:]')"
7485
}
7586

7687
# Detect operating system

src/packages.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,38 @@ cask|font-inconsolata-nerd-font|-|Inconsolata Nerd Font
7777
cask|font-open-sans|-|Open Sans font
7878
cask|font-poppins|-|Poppins font
7979
cask|font-roboto|-|Roboto font
80+
brew|automake|automake|Imported from macOS
81+
brew|cmake|cmake|Imported from macOS
82+
brew|gemini-cli|gemini-cli|Imported from macOS
83+
brew|hugo|hugo|Imported from macOS
84+
brew|libtool|libtool|Imported from macOS
85+
brew|maven|maven|Imported from macOS
86+
brew|openjdk@17|-|Imported from macOS
87+
brew|p7zip|p7zip|Imported from macOS
88+
brew|parallel|parallel|Imported from macOS
89+
brew|pipx|pipx|Imported from macOS
90+
brew|postgresql@18|-|Imported from macOS
91+
brew|protobuf-c|protobuf-c|Imported from macOS
92+
brew|python@3.12|-|Imported from macOS
93+
brew|sevenzip|sevenzip|Imported from macOS
94+
brew|shc|shc|Imported from macOS
95+
brew|sst/tap/opencode|-|Imported from macOS
96+
brew|testdisk|testdisk|Imported from macOS
97+
brew|virtualenv|virtualenv|Imported from macOS
98+
brew|woob|woob|Imported from macOS
99+
cask|android-studio|android-studio|Imported from macOS
100+
cask|anytype|anytype|Imported from macOS
101+
cask|autodesk-fusion|autodesk-fusion|Imported from macOS
102+
cask|balenaetcher|balenaetcher|Imported from macOS
103+
cask|claude|claude|Imported from macOS
104+
cask|ddpm|ddpm|Imported from macOS
105+
cask|hyprnote|hyprnote|Imported from macOS
106+
cask|keeweb|keeweb|Imported from macOS
107+
cask|logi-options+|-|Imported from macOS
108+
cask|notion|notion|Imported from macOS
109+
cask|onyx|onyx|Imported from macOS
110+
cask|postman|postman|Imported from macOS
111+
cask|spectacle|spectacle|Imported from macOS
112+
cask|spotify|spotify|Imported from macOS
113+
cask|thunderbird|thunderbird|Imported from macOS
114+
cask|yubico-yubikey-manager|yubico-yubikey-manager|Imported from macOS

src/wifi_from_keychain.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ require_cmd() {
6868
list_ssids_from_keychain() {
6969
# Use `security` to list generic passwords of kind "AirPort network password" and extract acct (SSID)
7070
security find-generic-password -D "AirPort network password" 2>/dev/null \
71-
| awk -F'"' '/acct/{print $2}' \
71+
| awk -F'"' '/"acct"<blob>="/{print $4}' \
7272
| sort -u
7373
}
7474

ui/app.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,37 @@ def api_action_install():
304304
@app.route('/api/action/import-installed', methods=['POST'])
305305
def api_action_import_installed():
306306
# Run bash src/import_installed.sh
307-
script = BASE_DIR / 'src' / 'import_installed.sh'
308-
if not script.exists():
309-
return jsonify({'error':'import_installed.sh script not found'}), 500
307+
def find_script(name):
308+
candidates = []
309+
# repo-relative (dev mode)
310+
candidates.append(BASE_DIR / 'src' / name)
311+
# current working dir
312+
candidates.append(Path.cwd() / 'src' / name)
313+
# next to the executable (one-dir builds)
314+
candidates.append(Path(sys.executable).parent / 'src' / name)
315+
# PyInstaller onefile unpack dir
316+
meipass = getattr(sys, '_MEIPASS', None)
317+
if meipass:
318+
candidates.append(Path(meipass) / 'src' / name)
319+
320+
found = None
321+
checked = []
322+
for c in candidates:
323+
checked.append(str(c))
324+
if c.exists():
325+
found = c
326+
break
327+
return found, checked
328+
329+
script_name = 'import_installed.sh'
330+
script, checked = find_script(script_name)
331+
if not script:
332+
return jsonify({'error': f"{script_name} script not found", 'checked': checked}), 500
333+
310334
try:
311335
cmd = ['bash', str(script)]
312336
res = subprocess.run(cmd, capture_output=True, text=True)
313-
return jsonify({'stdout': res.stdout, 'stderr': res.stderr, 'code': res.returncode})
337+
return jsonify({'stdout': res.stdout, 'stderr': res.stderr, 'code': res.returncode, 'used': str(script)})
314338
except Exception as e:
315339
return jsonify({'error': str(e)}), 500
316340

0 commit comments

Comments
 (0)