narvy-cli 1.1.1__tar.gz → 1.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/CHANGELOG.md +54 -0
- {narvy_cli-1.1.1/narvy_cli.egg-info → narvy_cli-1.1.2}/PKG-INFO +79 -4
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/README.md +78 -3
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/__init__.py +1 -1
- narvy_cli-1.1.2/narvy/__main__.py +30 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/apk_memory_preflight.py +1 -1
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/decompiler.py +38 -15
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/doctor.py +1 -1
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/lynis_bootstrap.py +1 -1
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/ssh_exec.py +2 -2
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ios/binary_analyzer.py +2 -2
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/main.py +18 -3
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/native_hardening.py +1 -1
- narvy_cli-1.1.2/narvy/pathhint.py +98 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/proc.py +4 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/go.yml +132 -50
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/java.yml +20 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/javascript.yml +597 -270
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/php.yml +108 -32
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/python.yml +108 -25
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/ruby.yml +89 -77
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/secrets.yml +6 -4
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/sca/web_deps.py +98 -16
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/semgrep_engine.py +44 -2
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/web/nuclei_binary.py +1 -1
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/web/scanner.py +1 -1
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/web/source_analyzer.py +74 -13
- {narvy_cli-1.1.1 → narvy_cli-1.1.2/narvy_cli.egg-info}/PKG-INFO +79 -4
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy_cli.egg-info/SOURCES.txt +2 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/LICENSE +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/MANIFEST.in +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/SECURITY.md +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/android/__init__.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/android/source_analyzer.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/android/split_bundle.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/android_rule_context.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/auth.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ci_templates/bitbucket.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ci_templates/github.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ci_templates/gitlab.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/cloud/__init__.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/cloud/aws_scan.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/comment_filter.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/crypto_taint_lite.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/__init__.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/audit.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/host_knowledge.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/lynis_parser.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/narvy_checks.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/host/report.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ios/__init__.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ios/plist_checks.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ios/source_analyzer.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ios/third_party_filter.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/ios/trust_all_context.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/own_reports.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/reporter.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rule_engine.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/android/config.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/android/crypto.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/android/secrets.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/android/storage.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/android/webview.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/android.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/ios/objc/crypto.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/ios/objc/network.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/ios/objc/secrets.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/ios/objc/storage.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/ios/objc/webview.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/ios_swift.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/kotlin.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/rust.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/rules/web/secrets_supplement.yml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/sca/__init__.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/sca/android_deps.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/sca/ios_deps.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/sca/osv_client.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/scope_config.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/stack_protector_evidence.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/telemetry.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/third_party_filter.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/uploader.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/weak_prng_context.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/web/__init__.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/web/scan_blocklist.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy/web/ssrf_guard.py +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy_cli.egg-info/dependency_links.txt +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy_cli.egg-info/entry_points.txt +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy_cli.egg-info/requires.txt +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/narvy_cli.egg-info/top_level.txt +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/pyproject.toml +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/setup.cfg +0 -0
- {narvy_cli-1.1.1 → narvy_cli-1.1.2}/setup.py +0 -0
|
@@ -5,6 +5,60 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.2]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `python -m narvy` (`py -m narvy` on Windows) runs the CLI. It works when
|
|
13
|
+
pip put the `narvy` command in a directory that is not on PATH, the
|
|
14
|
+
default for a user install on Windows and macOS. Run that way, Narvy
|
|
15
|
+
prints once the command that adds the directory to PATH (PowerShell on
|
|
16
|
+
Windows, your shell rc file elsewhere). It never changes PATH itself;
|
|
17
|
+
`NARVY_NO_PATH_HINT=1` turns the hint off.
|
|
18
|
+
- README: install steps for Windows, macOS (Homebrew
|
|
19
|
+
`externally-managed-environment`) and Linux, with pipx first.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- A user install run as `python -m narvy` (or by the launcher's full path)
|
|
24
|
+
did not find semgrep in the same off-PATH directory, skipped the code pass
|
|
25
|
+
and reported only dependency CVEs. semgrep is now looked up there and its
|
|
26
|
+
directory is put on the PATH it runs with (it starts `pysemgrep` through
|
|
27
|
+
PATH).
|
|
28
|
+
- macOS: when no Java 11+ was installed, the downloaded JRE was never found
|
|
29
|
+
("no bin/ dir found inside"), so APK scans failed on every such Mac. The
|
|
30
|
+
macOS layout (`Contents/Home/bin`) is handled, Apple Silicon and ARM Linux
|
|
31
|
+
get the native aarch64 JRE instead of x64, and a cached JRE that does not
|
|
32
|
+
run is downloaded again.
|
|
33
|
+
- Windows: jadx failed to start when its path contained a space (a user name
|
|
34
|
+
like `Jean Dupont`, or `C:\Program Files`), because `cmd /c` stripped the
|
|
35
|
+
wrong quotes. The jadx command line now goes through `cmd /d /s /c` as one
|
|
36
|
+
quoted string.
|
|
37
|
+
- Windows: tool output (semgrep, jadx, nuclei, ssh) is decoded as UTF-8
|
|
38
|
+
instead of the console code page, semgrep runs in Python UTF-8 mode, and
|
|
39
|
+
output redirected to a file or pipe replaces a character the code page
|
|
40
|
+
cannot encode instead of stopping the scan with `UnicodeEncodeError`.
|
|
41
|
+
- A file still locked in a temporary directory (antivirus, a slow child
|
|
42
|
+
process) no longer fails the scan at cleanup.
|
|
43
|
+
- SCA: only one version of each package was checked. A lockfile that holds
|
|
44
|
+
`minimist 1.2.8` and a nested `minimist 0.0.8` now checks both. A version
|
|
45
|
+
taken from a manifest range is still dropped when a lockfile resolves that
|
|
46
|
+
package.
|
|
47
|
+
- yarn.lock (berry): the package comes from the `resolution:` line, so
|
|
48
|
+
aliases (`string-width-cjs@npm:string-width@...`) and `patch:` entries
|
|
49
|
+
name the real package, and `__metadata`, workspace, git and local entries
|
|
50
|
+
are no longer sent to OSV as packages.
|
|
51
|
+
- semgrep with more than one worker drops taint-mode results at random with
|
|
52
|
+
no error. Every rule pack that holds a taint rule now runs in its own
|
|
53
|
+
single-worker semgrep process (packs still run side by side). Files where
|
|
54
|
+
a rule hit the per-file timeout are named in the scan notes.
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
|
|
58
|
+
- Community rule precision round (PHP, JavaScript, Go, Java, Python, Ruby):
|
|
59
|
+
fewer findings on code that is not reachable by an attacker. Informational
|
|
60
|
+
rules are lowered to LOW with the reason.
|
|
61
|
+
|
|
8
62
|
## [1.1.1]
|
|
9
63
|
|
|
10
64
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: narvy-cli
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: Free, local SAST scanner for Android, iOS, and polyglot web/backend source - plus passive web, host-audit, and cloud-posture scanning.
|
|
5
5
|
Author: Narvy
|
|
6
6
|
License: Apache-2.0
|
|
@@ -63,11 +63,83 @@ exactly in [Telemetry](#telemetry), which you can turn off.
|
|
|
63
63
|
## Install
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
|
|
66
|
+
pipx install narvy-cli # recommended, puts `narvy` on PATH (run `pipx ensurepath` once)
|
|
67
|
+
pip install narvy-cli # or plain pip
|
|
67
68
|
```
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
If your shell says `narvy: command not found` / `The term 'narvy' is not
|
|
71
|
+
recognized`, pip installed the command into a directory that is not on your
|
|
72
|
+
PATH. `python -m narvy` always works (`py -m narvy` on Windows), and prints
|
|
73
|
+
once the command that adds that directory to PATH. Narvy never edits PATH
|
|
74
|
+
itself.
|
|
75
|
+
|
|
76
|
+
### Windows
|
|
77
|
+
|
|
78
|
+
Recommended, with [pipx](https://pipx.pypa.io):
|
|
79
|
+
|
|
80
|
+
```powershell
|
|
81
|
+
py -m pip install --user pipx
|
|
82
|
+
py -m pipx ensurepath # then close and reopen the terminal
|
|
83
|
+
pipx install narvy-cli
|
|
84
|
+
narvy scan app.apk
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Without pipx:
|
|
88
|
+
|
|
89
|
+
```powershell
|
|
90
|
+
py -m pip install narvy-cli
|
|
91
|
+
py -m narvy scan app.apk
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
To use the short `narvy` command after a plain `pip install`, add pip's
|
|
95
|
+
Scripts directory to PATH. For the current PowerShell window only
|
|
96
|
+
(Python 3.14 from python.org; change `Python314` to your version):
|
|
97
|
+
|
|
98
|
+
```powershell
|
|
99
|
+
$env:Path += ";$env:APPDATA\Python\Python314\Scripts"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
To make it permanent for your user account, then open a new terminal:
|
|
103
|
+
|
|
104
|
+
```powershell
|
|
105
|
+
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$env:APPDATA\Python\Python314\Scripts", "User")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The exact directory is in pip's `WARNING: The script narvy.exe is installed
|
|
109
|
+
in ... which is not on PATH` line, and in the hint `py -m narvy` prints. The
|
|
110
|
+
Microsoft Store Python uses a different one (under
|
|
111
|
+
`%LOCALAPPDATA%\Packages\PythonSoftwareFoundation.Python.3.x_...\LocalCache\local-packages`).
|
|
112
|
+
Windows on ARM: semgrep has no Windows ARM64 build, use x64 Python.
|
|
113
|
+
|
|
114
|
+
### macOS
|
|
115
|
+
|
|
116
|
+
Homebrew's Python refuses `pip install` outside a virtualenv
|
|
117
|
+
(`error: externally-managed-environment`). Use pipx:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
brew install pipx && pipx ensurepath # then open a new terminal
|
|
121
|
+
pipx install narvy-cli
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
or a virtualenv (`python3 -m venv ~/.venvs/narvy && ~/.venvs/narvy/bin/pip install narvy-cli`).
|
|
125
|
+
A `pip install --user` puts `narvy` in `~/Library/Python/3.x/bin`, which is
|
|
126
|
+
not on PATH: add it with
|
|
127
|
+
`echo 'export PATH="$HOME/Library/Python/3.14/bin:$PATH"' >> ~/.zshrc`, or run
|
|
128
|
+
`python3 -m narvy`.
|
|
129
|
+
|
|
130
|
+
### Linux
|
|
131
|
+
|
|
132
|
+
pipx (`sudo apt install pipx` / `dnf install pipx`, then `pipx ensurepath`) is
|
|
133
|
+
the simplest. Debian 12+ and Ubuntu 23.04+ refuse a system-wide `pip install`
|
|
134
|
+
the same way Homebrew does. A `pip install --user` puts `narvy` in
|
|
135
|
+
`~/.local/bin`; if that is not on PATH, add
|
|
136
|
+
`export PATH="$HOME/.local/bin:$PATH"` to `~/.bashrc`, or run
|
|
137
|
+
`python3 -m narvy`.
|
|
138
|
+
|
|
139
|
+
### Requirements
|
|
140
|
+
|
|
141
|
+
Android scans need Java 11+. If none is found, a JRE (and jadx) is
|
|
142
|
+
downloaded into `~/.narvy/tools` on the first APK scan. Everything else
|
|
71
143
|
is pure Python plus a couple of optional extras:
|
|
72
144
|
|
|
73
145
|
```bash
|
|
@@ -215,6 +287,9 @@ number of checks it did not run. It never hides a finding it did compute.
|
|
|
215
287
|
in its own output when it applies.
|
|
216
288
|
- Only one architecture's native libraries are checked in a multi-ABI
|
|
217
289
|
APK/split bundle.
|
|
290
|
+
- Windows: a decompiled file whose full path passes 260 characters is only
|
|
291
|
+
read when Windows long-path support is enabled
|
|
292
|
+
(`LongPathsEnabled`); a very deep package tree in `%TEMP%` can hit it.
|
|
218
293
|
|
|
219
294
|
See [SETUP.md](SETUP.md) for detailed install/troubleshooting steps and the
|
|
220
295
|
exact commands this README's examples were run against.
|
|
@@ -30,11 +30,83 @@ exactly in [Telemetry](#telemetry), which you can turn off.
|
|
|
30
30
|
## Install
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
|
|
33
|
+
pipx install narvy-cli # recommended, puts `narvy` on PATH (run `pipx ensurepath` once)
|
|
34
|
+
pip install narvy-cli # or plain pip
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
If your shell says `narvy: command not found` / `The term 'narvy' is not
|
|
38
|
+
recognized`, pip installed the command into a directory that is not on your
|
|
39
|
+
PATH. `python -m narvy` always works (`py -m narvy` on Windows), and prints
|
|
40
|
+
once the command that adds that directory to PATH. Narvy never edits PATH
|
|
41
|
+
itself.
|
|
42
|
+
|
|
43
|
+
### Windows
|
|
44
|
+
|
|
45
|
+
Recommended, with [pipx](https://pipx.pypa.io):
|
|
46
|
+
|
|
47
|
+
```powershell
|
|
48
|
+
py -m pip install --user pipx
|
|
49
|
+
py -m pipx ensurepath # then close and reopen the terminal
|
|
50
|
+
pipx install narvy-cli
|
|
51
|
+
narvy scan app.apk
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Without pipx:
|
|
55
|
+
|
|
56
|
+
```powershell
|
|
57
|
+
py -m pip install narvy-cli
|
|
58
|
+
py -m narvy scan app.apk
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
To use the short `narvy` command after a plain `pip install`, add pip's
|
|
62
|
+
Scripts directory to PATH. For the current PowerShell window only
|
|
63
|
+
(Python 3.14 from python.org; change `Python314` to your version):
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
$env:Path += ";$env:APPDATA\Python\Python314\Scripts"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To make it permanent for your user account, then open a new terminal:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$env:APPDATA\Python\Python314\Scripts", "User")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The exact directory is in pip's `WARNING: The script narvy.exe is installed
|
|
76
|
+
in ... which is not on PATH` line, and in the hint `py -m narvy` prints. The
|
|
77
|
+
Microsoft Store Python uses a different one (under
|
|
78
|
+
`%LOCALAPPDATA%\Packages\PythonSoftwareFoundation.Python.3.x_...\LocalCache\local-packages`).
|
|
79
|
+
Windows on ARM: semgrep has no Windows ARM64 build, use x64 Python.
|
|
80
|
+
|
|
81
|
+
### macOS
|
|
82
|
+
|
|
83
|
+
Homebrew's Python refuses `pip install` outside a virtualenv
|
|
84
|
+
(`error: externally-managed-environment`). Use pipx:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
brew install pipx && pipx ensurepath # then open a new terminal
|
|
88
|
+
pipx install narvy-cli
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
or a virtualenv (`python3 -m venv ~/.venvs/narvy && ~/.venvs/narvy/bin/pip install narvy-cli`).
|
|
92
|
+
A `pip install --user` puts `narvy` in `~/Library/Python/3.x/bin`, which is
|
|
93
|
+
not on PATH: add it with
|
|
94
|
+
`echo 'export PATH="$HOME/Library/Python/3.14/bin:$PATH"' >> ~/.zshrc`, or run
|
|
95
|
+
`python3 -m narvy`.
|
|
96
|
+
|
|
97
|
+
### Linux
|
|
98
|
+
|
|
99
|
+
pipx (`sudo apt install pipx` / `dnf install pipx`, then `pipx ensurepath`) is
|
|
100
|
+
the simplest. Debian 12+ and Ubuntu 23.04+ refuse a system-wide `pip install`
|
|
101
|
+
the same way Homebrew does. A `pip install --user` puts `narvy` in
|
|
102
|
+
`~/.local/bin`; if that is not on PATH, add
|
|
103
|
+
`export PATH="$HOME/.local/bin:$PATH"` to `~/.bashrc`, or run
|
|
104
|
+
`python3 -m narvy`.
|
|
105
|
+
|
|
106
|
+
### Requirements
|
|
107
|
+
|
|
108
|
+
Android scans need Java 11+. If none is found, a JRE (and jadx) is
|
|
109
|
+
downloaded into `~/.narvy/tools` on the first APK scan. Everything else
|
|
38
110
|
is pure Python plus a couple of optional extras:
|
|
39
111
|
|
|
40
112
|
```bash
|
|
@@ -182,6 +254,9 @@ number of checks it did not run. It never hides a finding it did compute.
|
|
|
182
254
|
in its own output when it applies.
|
|
183
255
|
- Only one architecture's native libraries are checked in a multi-ABI
|
|
184
256
|
APK/split bundle.
|
|
257
|
+
- Windows: a decompiled file whose full path passes 260 characters is only
|
|
258
|
+
read when Windows long-path support is enabled
|
|
259
|
+
(`LongPathsEnabled`); a very deep package tree in `%TEMP%` can hit it.
|
|
185
260
|
|
|
186
261
|
See [SETUP.md](SETUP.md) for detailed install/troubleshooting steps and the
|
|
187
262
|
exact commands this README's examples were run against.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""`python -m narvy` (or `py -m narvy` on Windows) runs the CLI.
|
|
2
|
+
|
|
3
|
+
Works even when pip put the `narvy` command in a Scripts/bin directory that is
|
|
4
|
+
not on PATH, which is the default for a user install on Windows and macOS.
|
|
5
|
+
"""
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _prog() -> str:
|
|
11
|
+
"""Name shown in usage lines: the interpreter the user actually typed, plus -m narvy."""
|
|
12
|
+
argv0 = (getattr(sys, "orig_argv", None) or [""])[0]
|
|
13
|
+
name = os.path.basename(argv0)
|
|
14
|
+
if name.lower().endswith(".exe"):
|
|
15
|
+
name = name[:-4]
|
|
16
|
+
if not name.lower().startswith(("python", "py")):
|
|
17
|
+
name = "python"
|
|
18
|
+
return f"{name} -m narvy"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def main() -> None:
|
|
22
|
+
from .pathhint import maybe_print_path_hint
|
|
23
|
+
from .main import cli
|
|
24
|
+
|
|
25
|
+
maybe_print_path_hint()
|
|
26
|
+
cli(prog=_prog())
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
main()
|
|
@@ -73,7 +73,7 @@ def available_ram_mb() -> Optional[int]:
|
|
|
73
73
|
elif system == "Darwin":
|
|
74
74
|
# vm_stat exposes reclaimable inactive+purgeable pools that SC_AVPHYS_PAGES omits.
|
|
75
75
|
import subprocess
|
|
76
|
-
out = subprocess.run(["vm_stat"], capture_output=True, text=True, timeout=10).stdout
|
|
76
|
+
out = subprocess.run(["vm_stat"], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=10).stdout
|
|
77
77
|
page = 4096
|
|
78
78
|
pm = re.search(r"page size of (\d+) bytes", out)
|
|
79
79
|
if pm:
|
|
@@ -30,8 +30,14 @@ JADX_BIN = os.path.join(JADX_HOME, "bin", "jadx.bat" if _IS_WINDOWS else "jadx")
|
|
|
30
30
|
# jadx 1.5.0 needs Java 11+; a JRE is fetched when the system has none.
|
|
31
31
|
_JRE_MAJOR = "17"
|
|
32
32
|
_JRE_ADOPTIUM_OS = "windows" if _IS_WINDOWS else ("mac" if _IS_MAC else "linux")
|
|
33
|
-
#
|
|
34
|
-
|
|
33
|
+
# Apple Silicon and ARM Linux get the native aarch64 build (an x64 JRE needs
|
|
34
|
+
# Rosetta on a Mac and does not run at all on ARM Linux). Windows stays x64:
|
|
35
|
+
# Temurin 17 has no Windows ARM JRE, and Windows on ARM emulates x64.
|
|
36
|
+
_JRE_ADOPTIUM_ARCH = (
|
|
37
|
+
"aarch64"
|
|
38
|
+
if not _IS_WINDOWS and platform.machine().lower() in ("arm64", "aarch64")
|
|
39
|
+
else "x64"
|
|
40
|
+
)
|
|
35
41
|
JRE_URL = (
|
|
36
42
|
f"https://api.adoptium.net/v3/binary/latest/{_JRE_MAJOR}/ga/"
|
|
37
43
|
f"{_JRE_ADOPTIUM_OS}/{_JRE_ADOPTIUM_ARCH}/jre/hotspot/normal/eclipse"
|
|
@@ -69,7 +75,7 @@ def resolve_jadx_binary():
|
|
|
69
75
|
|
|
70
76
|
def _java_major_version(java_bin):
|
|
71
77
|
try:
|
|
72
|
-
result = subprocess.run([java_bin, "-version"], capture_output=True, text=True, timeout=10)
|
|
78
|
+
result = subprocess.run([java_bin, "-version"], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=10)
|
|
73
79
|
except Exception:
|
|
74
80
|
return None
|
|
75
81
|
out = result.stderr or result.stdout or ""
|
|
@@ -87,10 +93,12 @@ def _jre_bin_dir():
|
|
|
87
93
|
# Discovered, not hardcoded: the Adoptium top-level dir carries the patch version.
|
|
88
94
|
if not os.path.isdir(JRE_HOME):
|
|
89
95
|
return None
|
|
90
|
-
for entry in os.listdir(JRE_HOME):
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
for entry in sorted(os.listdir(JRE_HOME)):
|
|
97
|
+
# Linux/Windows: <jdk-17...-jre>/bin. macOS: <jdk-17...-jre>/Contents/Home/bin.
|
|
98
|
+
for sub in (("bin",), ("Contents", "Home", "bin")):
|
|
99
|
+
candidate = os.path.join(JRE_HOME, entry, *sub)
|
|
100
|
+
if os.path.isdir(candidate):
|
|
101
|
+
return candidate
|
|
94
102
|
return None
|
|
95
103
|
|
|
96
104
|
|
|
@@ -133,16 +141,31 @@ def resolve_java_home():
|
|
|
133
141
|
|
|
134
142
|
bin_dir = _jre_bin_dir()
|
|
135
143
|
if bin_dir:
|
|
136
|
-
|
|
144
|
+
java = os.path.join(bin_dir, "java.exe" if _IS_WINDOWS else "java")
|
|
145
|
+
# A JRE left by an older narvy can be the wrong architecture (x64 on
|
|
146
|
+
# Apple Silicon without Rosetta): it must actually run, or it is replaced.
|
|
147
|
+
if (_java_major_version(java) or 0) >= 11:
|
|
148
|
+
return bin_dir
|
|
149
|
+
logger.warning(f"The cached JRE in {JRE_HOME} does not run here - downloading a fresh one")
|
|
137
150
|
|
|
138
151
|
return _download_jre()
|
|
139
152
|
|
|
140
153
|
|
|
141
154
|
def _jadx_cmd(jadx_bin, extra_args):
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
"""argv for jadx. On Windows a .bat goes through cmd.exe as ONE string.
|
|
156
|
+
|
|
157
|
+
A list like ["cmd", "/c", bat, ...] breaks as soon as the .bat path is quoted
|
|
158
|
+
(a space in the user name, or C:\\Program Files): cmd /c strips the first
|
|
159
|
+
and the last quote of the line and runs `C:\\Users\\Jean`. With /s and the
|
|
160
|
+
whole line wrapped in one extra pair of quotes, cmd strips exactly that pair.
|
|
161
|
+
"""
|
|
162
|
+
if _IS_WINDOWS and jadx_bin.lower().endswith((".bat", ".cmd")):
|
|
163
|
+
return 'cmd /d /s /c "' + subprocess.list2cmdline([jadx_bin] + list(extra_args)) + '"'
|
|
164
|
+
return [jadx_bin] + list(extra_args)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _cmd_text(cmd):
|
|
168
|
+
return cmd if isinstance(cmd, str) else " ".join(str(c) for c in cmd)
|
|
146
169
|
|
|
147
170
|
|
|
148
171
|
def _validate_apk_zip(apk_path: str):
|
|
@@ -260,7 +283,7 @@ def decompile_apk(apk_path: str, output_dir: str, max_mem: str = "4g", force: bo
|
|
|
260
283
|
process = subprocess.run(
|
|
261
284
|
cmd,
|
|
262
285
|
capture_output=True,
|
|
263
|
-
text=True,
|
|
286
|
+
text=True, encoding="utf-8", errors="replace",
|
|
264
287
|
check=True,
|
|
265
288
|
timeout=900,
|
|
266
289
|
env=jadx_env,
|
|
@@ -269,7 +292,7 @@ def decompile_apk(apk_path: str, output_dir: str, max_mem: str = "4g", force: bo
|
|
|
269
292
|
return True, ""
|
|
270
293
|
except subprocess.CalledProcessError as e:
|
|
271
294
|
# jadx/cmd.exe don't consistently use stderr; report both streams.
|
|
272
|
-
parts = [f"JADX failed (exit code {e.returncode})", f"Command run: {
|
|
295
|
+
parts = [f"JADX failed (exit code {e.returncode})", f"Command run: {_cmd_text(cmd)}"]
|
|
273
296
|
if e.stdout:
|
|
274
297
|
parts.append(f"JADX stdout:\n{e.stdout}")
|
|
275
298
|
if e.stderr:
|
|
@@ -279,7 +302,7 @@ def decompile_apk(apk_path: str, output_dir: str, max_mem: str = "4g", force: bo
|
|
|
279
302
|
"No output captured on either stdout or stderr. Run "
|
|
280
303
|
"`narvy doctor` to check your Java/jadx setup, or try "
|
|
281
304
|
f"running this exact command yourself to see the raw error: "
|
|
282
|
-
f"{
|
|
305
|
+
f"{_cmd_text(cmd)}"
|
|
283
306
|
)
|
|
284
307
|
# OOM is unambiguous; a bare -9 (SIGKILL) is ambiguous, so they differ.
|
|
285
308
|
_combined_output = (e.stdout or "") + (e.stderr or "")
|
|
@@ -18,7 +18,7 @@ console = Console()
|
|
|
18
18
|
|
|
19
19
|
def _java_version(java_bin):
|
|
20
20
|
"""Run `java -version` and return (version_line, major_version_int_or_None)."""
|
|
21
|
-
result = subprocess.run([java_bin, "-version"], capture_output=True, text=True, timeout=10)
|
|
21
|
+
result = subprocess.run([java_bin, "-version"], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=10)
|
|
22
22
|
out = result.stderr or result.stdout or ""
|
|
23
23
|
version_line = out.splitlines()[0] if out else "unknown version"
|
|
24
24
|
# Handles both the old "1.8.0_501" scheme and the modern "17.0.2" one.
|
|
@@ -225,7 +225,7 @@ def scp_to_remote(conn: HostConn, local_path: str, remote_path: str,
|
|
|
225
225
|
argv = ["sshpass", "-e", *argv]
|
|
226
226
|
|
|
227
227
|
try:
|
|
228
|
-
proc = subprocess.run(argv, capture_output=True, text=True,
|
|
228
|
+
proc = subprocess.run(argv, capture_output=True, text=True, encoding="utf-8", errors="replace",
|
|
229
229
|
timeout=timeout, env=env)
|
|
230
230
|
except subprocess.TimeoutExpired as exc:
|
|
231
231
|
raise LynisBootstrapError(
|
|
@@ -85,7 +85,7 @@ def capture_host_key(hostname: str, port: int = 22,
|
|
|
85
85
|
try:
|
|
86
86
|
proc = subprocess.run(
|
|
87
87
|
["ssh-keyscan", "-p", str(port), "-T", str(timeout), hostname],
|
|
88
|
-
capture_output=True, text=True, timeout=timeout + 10,
|
|
88
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout + 10,
|
|
89
89
|
)
|
|
90
90
|
except (subprocess.TimeoutExpired, OSError):
|
|
91
91
|
return None
|
|
@@ -178,7 +178,7 @@ def ssh_exec(conn: HostConn, remote_cmd: str,
|
|
|
178
178
|
|
|
179
179
|
try:
|
|
180
180
|
proc = subprocess.run(
|
|
181
|
-
argv, capture_output=True, text=True, timeout=timeout, env=env,
|
|
181
|
+
argv, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout, env=env,
|
|
182
182
|
)
|
|
183
183
|
except subprocess.TimeoutExpired as exc:
|
|
184
184
|
raise SSHExecError(
|
|
@@ -54,7 +54,7 @@ def _icdump_class_count(binary_path: str, timeout: int = 60
|
|
|
54
54
|
try:
|
|
55
55
|
proc = subprocess.run(
|
|
56
56
|
[_sys.executable, "-c", _ICDUMP_PROBE_SCRIPT, binary_path],
|
|
57
|
-
capture_output=True, text=True, timeout=timeout,
|
|
57
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout,
|
|
58
58
|
)
|
|
59
59
|
except subprocess.TimeoutExpired:
|
|
60
60
|
return False, 0, 0, f"timed out after {timeout}s"
|
|
@@ -997,7 +997,7 @@ def analyze_ipa(ipa_path: str, override_config: Optional[ScopeConfig] = None) ->
|
|
|
997
997
|
framework_members = [n for n in names if n.startswith(frameworks_prefix)]
|
|
998
998
|
|
|
999
999
|
import tempfile
|
|
1000
|
-
with tempfile.TemporaryDirectory(prefix="narvy-ios-") as tmpdir:
|
|
1000
|
+
with tempfile.TemporaryDirectory(prefix="narvy-ios-", ignore_cleanup_errors=True) as tmpdir:
|
|
1001
1001
|
main_binary_path = _safe_extract_member(zf, main_binary_member, tmpdir)
|
|
1002
1002
|
if main_binary_path is None:
|
|
1003
1003
|
result["error"] = f"Failed to extract main binary {main_binary_member} " \
|
|
@@ -856,7 +856,7 @@ def _run_local_scan(apk_path, max_mem, override_config=None, force=False,
|
|
|
856
856
|
sca_cov = None
|
|
857
857
|
with scan_progress() as progress:
|
|
858
858
|
task1 = progress.add_task("[green]Decompiling APK...", total=1)
|
|
859
|
-
with tempfile.TemporaryDirectory() as temp_dir:
|
|
859
|
+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as temp_dir:
|
|
860
860
|
ok, decompile_error = decompile_apk(apk_path, temp_dir, max_mem, force=force,
|
|
861
861
|
extra_inputs=extra_dex_inputs)
|
|
862
862
|
if not ok:
|
|
@@ -2676,8 +2676,23 @@ def cmd_init_ci(args):
|
|
|
2676
2676
|
)
|
|
2677
2677
|
|
|
2678
2678
|
|
|
2679
|
-
def
|
|
2680
|
-
|
|
2679
|
+
def _safe_console_streams():
|
|
2680
|
+
"""Redirected output on Windows uses the ANSI code page (cp1252): a finding
|
|
2681
|
+
snippet with a character outside it would crash the whole run with
|
|
2682
|
+
UnicodeEncodeError. Replace such characters instead of dying."""
|
|
2683
|
+
for stream in (sys.stdout, sys.stderr):
|
|
2684
|
+
enc = (getattr(stream, "encoding", None) or "").lower().replace("-", "")
|
|
2685
|
+
if enc.startswith("utf"):
|
|
2686
|
+
continue
|
|
2687
|
+
try:
|
|
2688
|
+
stream.reconfigure(errors="replace")
|
|
2689
|
+
except (AttributeError, ValueError, OSError):
|
|
2690
|
+
pass
|
|
2691
|
+
|
|
2692
|
+
|
|
2693
|
+
def cli(prog=None):
|
|
2694
|
+
_safe_console_streams()
|
|
2695
|
+
parser =_ArgumentParser(prog=prog, allow_abbrev=False, description=(
|
|
2681
2696
|
"Narvy CLI - Static Analysis for Android APKs/AABs, iOS IPAs, "
|
|
2682
2697
|
"Android/iOS source projects, and web/backend source projects "
|
|
2683
2698
|
f"({web_source_analyzer.SUPPORTED_LANGUAGES_LABEL})"
|
|
@@ -471,7 +471,7 @@ def scan(apk_path: str) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]], Dic
|
|
|
471
471
|
if not arch_members:
|
|
472
472
|
return findings, [], stats
|
|
473
473
|
|
|
474
|
-
with tempfile.TemporaryDirectory(prefix="narvy-nh-") as tmpdir:
|
|
474
|
+
with tempfile.TemporaryDirectory(prefix="narvy-nh-", ignore_cleanup_errors=True) as tmpdir:
|
|
475
475
|
for basename in sorted(arch_members):
|
|
476
476
|
member = arch_members[basename]
|
|
477
477
|
local_path = _safe_extract(zf, member, tmpdir)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""One-line hint when `narvy` was installed but its directory is not on PATH.
|
|
2
|
+
|
|
3
|
+
Only used by `python -m narvy`: someone who typed `narvy` already has it on
|
|
4
|
+
PATH. PATH is never changed for the user, the hint prints the command to run.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import shutil
|
|
10
|
+
import sys
|
|
11
|
+
import sysconfig
|
|
12
|
+
from typing import List, Optional
|
|
13
|
+
|
|
14
|
+
MARKER = os.path.join(os.path.expanduser("~/.narvy"), "path_hint_shown")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _launcher_names() -> List[str]:
|
|
18
|
+
if os.name == "nt":
|
|
19
|
+
return ["narvy.exe", "narvy"]
|
|
20
|
+
return ["narvy"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _candidate_script_dirs() -> List[str]:
|
|
24
|
+
"""Where pip may have written the `narvy` launcher for this interpreter."""
|
|
25
|
+
dirs: List[str] = []
|
|
26
|
+
schemes = [None]
|
|
27
|
+
try:
|
|
28
|
+
user_scheme = sysconfig.get_preferred_scheme("user")
|
|
29
|
+
except (AttributeError, KeyError): # Python < 3.10 or a patched distro build
|
|
30
|
+
user_scheme = f"{os.name}_user"
|
|
31
|
+
schemes.append(user_scheme)
|
|
32
|
+
for scheme in schemes:
|
|
33
|
+
try:
|
|
34
|
+
path = sysconfig.get_path("scripts") if scheme is None else sysconfig.get_path("scripts", scheme)
|
|
35
|
+
except KeyError:
|
|
36
|
+
continue
|
|
37
|
+
if path and path not in dirs:
|
|
38
|
+
dirs.append(path)
|
|
39
|
+
return dirs
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _norm(path: str) -> str:
|
|
43
|
+
return os.path.normcase(os.path.normpath(path.strip().strip('"'))) if path.strip() else ""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def find_unlisted_scripts_dir(environ=None) -> Optional[str]:
|
|
47
|
+
"""The directory holding the `narvy` launcher when it is not on PATH, else None."""
|
|
48
|
+
environ = os.environ if environ is None else environ
|
|
49
|
+
path_value = environ.get("PATH", "")
|
|
50
|
+
if shutil.which("narvy", path=path_value):
|
|
51
|
+
return None
|
|
52
|
+
on_path = {_norm(p) for p in path_value.split(os.pathsep) if p.strip()}
|
|
53
|
+
for d in _candidate_script_dirs():
|
|
54
|
+
if _norm(d) in on_path:
|
|
55
|
+
continue
|
|
56
|
+
if any(os.path.isfile(os.path.join(d, n)) for n in _launcher_names()):
|
|
57
|
+
return d
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def hint_text(scripts_dir: str, platform: str = sys.platform) -> str:
|
|
62
|
+
if platform == "win32":
|
|
63
|
+
ps_dir = scripts_dir.replace("'", "''") # PowerShell single-quote escape
|
|
64
|
+
return (
|
|
65
|
+
f"narvy: the `narvy` command was installed to {scripts_dir}, which is not on PATH. "
|
|
66
|
+
"To add it for good, run in PowerShell: "
|
|
67
|
+
"[Environment]::SetEnvironmentVariable('Path', "
|
|
68
|
+
"[Environment]::GetEnvironmentVariable('Path', 'User') + "
|
|
69
|
+
f"';{ps_dir}', 'User') then open a new terminal. "
|
|
70
|
+
"Until then `py -m narvy` (or `python -m narvy`) works."
|
|
71
|
+
)
|
|
72
|
+
shell_rc = "~/.zshrc" if platform == "darwin" else "~/.bashrc"
|
|
73
|
+
return (
|
|
74
|
+
f"narvy: the `narvy` command was installed to {scripts_dir}, which is not on PATH. "
|
|
75
|
+
f"To add it, run: echo 'export PATH=\"{scripts_dir}:$PATH\"' >> {shell_rc} "
|
|
76
|
+
"then open a new terminal. Until then `python3 -m narvy` works."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def maybe_print_path_hint() -> None:
|
|
81
|
+
"""Print the hint once per machine, on an interactive terminal only. Never raises."""
|
|
82
|
+
try:
|
|
83
|
+
if os.environ.get("NARVY_NO_PATH_HINT") or not sys.stderr.isatty():
|
|
84
|
+
return
|
|
85
|
+
if os.path.exists(MARKER):
|
|
86
|
+
return
|
|
87
|
+
scripts_dir = find_unlisted_scripts_dir()
|
|
88
|
+
if not scripts_dir:
|
|
89
|
+
return
|
|
90
|
+
sys.stderr.write(hint_text(scripts_dir) + "\n")
|
|
91
|
+
try:
|
|
92
|
+
os.makedirs(os.path.dirname(MARKER), exist_ok=True)
|
|
93
|
+
with open(MARKER, "w", encoding="utf-8") as fh:
|
|
94
|
+
fh.write(scripts_dir + "\n")
|
|
95
|
+
except OSError:
|
|
96
|
+
pass
|
|
97
|
+
except Exception:
|
|
98
|
+
pass
|
|
@@ -54,6 +54,10 @@ def run_tree(cmd: List[str], timeout: Optional[float] = None, check: bool = Fals
|
|
|
54
54
|
kwargs.setdefault("stdout", subprocess.PIPE)
|
|
55
55
|
kwargs.setdefault("stderr", subprocess.PIPE)
|
|
56
56
|
kwargs.setdefault("text", True)
|
|
57
|
+
if kwargs.get("text"):
|
|
58
|
+
# Tools emit UTF-8; the Windows default (cp1252) raises on some of those bytes.
|
|
59
|
+
kwargs.setdefault("encoding", "utf-8")
|
|
60
|
+
kwargs.setdefault("errors", "replace")
|
|
57
61
|
if _POSIX and "preexec_fn" not in kwargs:
|
|
58
62
|
kwargs["start_new_session"] = True
|
|
59
63
|
elif _POSIX:
|