narvy-cli 1.3.7__tar.gz → 1.3.8__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.
Files changed (133) hide show
  1. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/CHANGELOG.md +41 -0
  2. {narvy_cli-1.3.7/narvy_cli.egg-info → narvy_cli-1.3.8}/PKG-INFO +1 -1
  3. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/__init__.py +1 -1
  4. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/android/source_analyzer.py +12 -1
  5. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cbom.py +9 -2
  6. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cloud/aws_scan.py +7 -0
  7. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cloud/gcp_scan.py +3 -1
  8. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/decompiler.py +5 -2
  9. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/lynis_bootstrap.py +3 -1
  10. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ios/source_analyzer.py +4 -0
  11. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/main.py +2 -1
  12. narvy_cli-1.3.8/narvy/production_source.py +489 -0
  13. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/ios_deps.py +3 -1
  14. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/secret_output.py +11 -0
  15. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/secret_presentation.py +734 -67
  16. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/semgrep_engine.py +18 -2
  17. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/telemetry.py +2 -1
  18. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/uploader.py +11 -5
  19. narvy_cli-1.3.8/narvy/useragent.py +22 -0
  20. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/web/nuclei_binary.py +4 -1
  21. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/web/source_analyzer.py +22 -3
  22. {narvy_cli-1.3.7 → narvy_cli-1.3.8/narvy_cli.egg-info}/PKG-INFO +1 -1
  23. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy_cli.egg-info/SOURCES.txt +2 -0
  24. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/LICENSE +0 -0
  25. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/MANIFEST.in +0 -0
  26. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/README.md +0 -0
  27. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/SECURITY.md +0 -0
  28. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/__main__.py +0 -0
  29. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/android/__init__.py +0 -0
  30. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/android/split_bundle.py +0 -0
  31. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/android_rule_context.py +0 -0
  32. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/apk_memory_preflight.py +0 -0
  33. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/app_inventory.py +0 -0
  34. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/auth.py +0 -0
  35. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ci_templates/bitbucket.yml +0 -0
  36. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ci_templates/github.yml +0 -0
  37. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ci_templates/gitlab.yml +0 -0
  38. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cloud/__init__.py +0 -0
  39. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cloud/normalize.py +0 -0
  40. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cloud/rule_severity.py +0 -0
  41. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cloud/severity.py +0 -0
  42. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/cloud/upload.py +0 -0
  43. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/comment_filter.py +0 -0
  44. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/crypto_taint_lite.py +0 -0
  45. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/doctor.py +0 -0
  46. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/gitlab_report.py +0 -0
  47. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/__init__.py +0 -0
  48. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/audit.py +0 -0
  49. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/host_knowledge.py +0 -0
  50. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/lynis_parser.py +0 -0
  51. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/narvy_checks.py +0 -0
  52. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/report.py +0 -0
  53. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/host/ssh_exec.py +0 -0
  54. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ios/__init__.py +0 -0
  55. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ios/binary_analyzer.py +0 -0
  56. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ios/plist_checks.py +0 -0
  57. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ios/third_party_filter.py +0 -0
  58. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/ios/trust_all_context.py +0 -0
  59. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/native_hardening.py +0 -0
  60. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/own_reports.py +0 -0
  61. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/pathhint.py +0 -0
  62. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/pathnorm.py +0 -0
  63. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/proc.py +0 -0
  64. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/repo_identity.py +0 -0
  65. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/reporter.py +0 -0
  66. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rule_engine.py +0 -0
  67. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/android/config.yml +0 -0
  68. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/android/crypto.yml +0 -0
  69. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/android/secrets.yml +0 -0
  70. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/android/storage.yml +0 -0
  71. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/android/webview.yml +0 -0
  72. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/android.yml +0 -0
  73. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/ios/objc/crypto.yml +0 -0
  74. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/ios/objc/network.yml +0 -0
  75. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/ios/objc/secrets.yml +0 -0
  76. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/ios/objc/storage.yml +0 -0
  77. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/ios/objc/webview.yml +0 -0
  78. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/ios_swift.yml +0 -0
  79. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/go.yml +0 -0
  80. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/java.yml +0 -0
  81. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/javascript.yml +0 -0
  82. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/kotlin.yml +0 -0
  83. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/php.yml +0 -0
  84. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/python.yml +0 -0
  85. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/ruby.yml +0 -0
  86. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/rust.yml +0 -0
  87. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/secrets.yml +0 -0
  88. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/rules/web/secrets_supplement.yml +0 -0
  89. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sbom.py +0 -0
  90. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/__init__.py +0 -0
  91. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/android_deps.py +0 -0
  92. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/osv_client.py +0 -0
  93. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/osv_localdb.py +0 -0
  94. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/osv_semantic.py +0 -0
  95. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/severity_calibration.py +0 -0
  96. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/sca/web_deps.py +0 -0
  97. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/scope_config.py +0 -0
  98. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/secret_value_grade.py +0 -0
  99. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/stack_protector_evidence.py +0 -0
  100. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/__init__.py +0 -0
  101. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/__main__.py +0 -0
  102. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/analyze.py +0 -0
  103. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/__init__.py +0 -0
  104. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/arsc.py +0 -0
  105. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/axml.py +0 -0
  106. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/checks.py +0 -0
  107. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/elf.py +0 -0
  108. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/loader.py +0 -0
  109. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/protoxml.py +0 -0
  110. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/android/xmlmodel.py +0 -0
  111. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/archive.py +0 -0
  112. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/cli.py +0 -0
  113. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/data/__init__.py +0 -0
  114. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/data/apple.py +0 -0
  115. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/data/play.py +0 -0
  116. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/ios/__init__.py +0 -0
  117. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/ios/checks.py +0 -0
  118. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/ios/loader.py +0 -0
  119. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/ios/macho.py +0 -0
  120. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/store_check/model.py +0 -0
  121. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/third_party_filter.py +0 -0
  122. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/weak_prng_context.py +0 -0
  123. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/web/__init__.py +0 -0
  124. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/web/scan_blocklist.py +0 -0
  125. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/web/scanner.py +0 -0
  126. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy/web/ssrf_guard.py +0 -0
  127. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy_cli.egg-info/dependency_links.txt +0 -0
  128. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy_cli.egg-info/entry_points.txt +0 -0
  129. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy_cli.egg-info/requires.txt +0 -0
  130. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/narvy_cli.egg-info/top_level.txt +0 -0
  131. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/pyproject.toml +0 -0
  132. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/setup.cfg +0 -0
  133. {narvy_cli-1.3.7 → narvy_cli-1.3.8}/setup.py +0 -0
@@ -5,6 +5,47 @@ 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.3.8]
9
+
10
+ ### Added
11
+
12
+ - `--upload` sends the CLI version: the `/api/v1/ingest` body carries
13
+ `cli_version` (the installed narvy-cli version), so the uploaded scan states
14
+ which CLI produced it. Earlier versions sent nothing and their uploads state
15
+ no engine version.
16
+
17
+ ### Fixed
18
+
19
+ - Source scans: a package of the app named `test`, `tests`, `vendor`,
20
+ `build` or `dist` under a production source root
21
+ (`src/main/java/com/acme/app/test/`, `src/main/kotlin/...`, SwiftPM
22
+ `Sources/<Target>/`) is the app's own code. A finding there was missing
23
+ (semgrep's default ignore list drops those folder names at any depth, and
24
+ the web pass excluded `vendor` / `build` by bare name), and one in a
25
+ package named `fixtures` or `mocks` was lowered to LOW as test code. Real
26
+ test source sets (`src/test`, `src/androidTest`), a root `build/` or
27
+ `vendor/`, Go and PHP `vendor/` and vendored C under a SwiftPM target stay
28
+ excluded. A production flavor or build type (`src/release/java`,
29
+ `src/dev/java`) is read like `src/main`; a `<name>Test` source set
30
+ declared as a flavor or build type in a `build.gradle(.kts)` (`abTest`)
31
+ is production code. Known test source sets (`androidTest`, `testDebug`,
32
+ `integrationTest`...) and an undeclared `<name>Test` set are lowered to
33
+ LOW like test code, never removed (`testDebug` and `integrationTest` were
34
+ reported at full severity). APK / AAB scans: every package
35
+ of the decompiled app is scanned, `test` and `vendor` included (an APK
36
+ has no test source set). A project with its own `.semgrepignore` keeps it. Needs the
37
+ pinned semgrep 1.152; with another semgrep version the scan behaves as in
38
+ 1.3.7.
39
+
40
+ ### Changed
41
+
42
+ - Every request the CLI makes on its own behalf goes out with the User-Agent
43
+ `narvy-cli/<version>` (was `python-requests/<x.y.z>`): Narvy API (whoami,
44
+ upload, ingest, scans), usage telemetry, jadx / JRE / nuclei downloads,
45
+ GitHub advisory lookups, Lynis download, GCP and AWS API calls (AWS:
46
+ appended to the boto3 User-Agent). The OSV client already did. Requests to
47
+ a web target being scanned keep the browser User-Agent.
48
+
8
49
  ## [1.3.7]
9
50
 
10
51
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: narvy-cli
3
- Version: 1.3.7
3
+ Version: 1.3.8
4
4
  Summary: Local static security scanner for Android and iOS apps and source code, with offline Google Play and App Store upload checks.
5
5
  Author: Narvy
6
6
  License: Apache-2.0
@@ -1,3 +1,3 @@
1
1
  """Narvy CLI - free, local SAST for Android, iOS and polyglot source."""
2
2
 
3
- __version__ = "1.3.7"
3
+ __version__ = "1.3.8"
@@ -7,6 +7,7 @@ from typing import Any, Dict, List, Optional, Tuple
7
7
 
8
8
  from narvy.rule_engine import load_rules_from_dir, run_rules_on_file
9
9
  from narvy.pathnorm import canonical_path
10
+ from narvy.production_source import register_gradle_variants, scope_view, source_set_of
10
11
  from narvy import semgrep_engine
11
12
  from narvy import crypto_taint_lite
12
13
  from narvy.scope_config import ScopeConfig
@@ -105,7 +106,14 @@ def _drop_prefkey_echo_secrets(source_dir: str, findings: List[Dict[str, Any]])
105
106
 
106
107
 
107
108
  def _is_test_path(rel_path: str) -> bool:
108
- p = "/" + rel_path.replace("\\", "/").lstrip("/")
109
+ # Read without the app's own package folders below a production source
110
+ # root: com/acme/test/ and com/acme/fixtures/ are packages; src/test/ and
111
+ # src/androidTest/ still match (narvy/production_source).
112
+ # A known test source set or an undeclared <x>Test set (src/loadTest/
113
+ # with no such flavor / build type) is lowered, never removed.
114
+ if source_set_of(rel_path) in ("test", "hidden"):
115
+ return True
116
+ p = "/" + scope_view(rel_path).replace("\\", "/").lstrip("/")
109
117
  if any(frag in p.lower() for frag in _TEST_PATH_FRAGMENTS):
110
118
  return True
111
119
  return bool(_TEST_FILE_RE.search(p.rsplit("/", 1)[-1]))
@@ -269,6 +277,9 @@ def analyze_source(source_dir: str, override_config: Optional[ScopeConfig] = Non
269
277
  source_dir = canonical_path(source_dir)
270
278
  notes: List[str] = []
271
279
  all_findings: List[Dict[str, Any]] = []
280
+ # The project's flavor / build-type names: an "abTest" flavor is
281
+ # production code, not a test source set.
282
+ register_gradle_variants(source_dir)
272
283
 
273
284
  manifest_paths = sorted(find_android_manifests(source_dir))
274
285
  own_roots = get_own_package_roots_gradle(manifest_paths)
@@ -41,6 +41,7 @@ from typing import Any, Dict, Iterable, List, Optional, Tuple
41
41
 
42
42
  from . import __version__
43
43
  from .comment_filter import build_comment_mask
44
+ from .production_source import keep_package_dir
44
45
 
45
46
  SPEC_VERSION = "1.6"
46
47
 
@@ -178,9 +179,15 @@ class Occurrence:
178
179
 
179
180
  def _iter_source_files(root: str) -> Iterable[str]:
180
181
  for dirpath, dirnames, filenames in os.walk(root):
182
+ # A package folder below a production source root
183
+ # (src/main/java/com/acme/test/, .../vendor/) is the app's own code
184
+ # (narvy/production_source); "generated" never is.
181
185
  dirnames[:] = [d for d in dirnames
182
- if d not in _SKIP_DIRS and d not in _TEST_DIRS and not d.startswith(".")
183
- and not d.endswith(("Tests", "Test", "UITests"))]
186
+ if not d.startswith(".")
187
+ and ((d not in _SKIP_DIRS and d not in _TEST_DIRS
188
+ and not d.endswith(("Tests", "Test", "UITests")))
189
+ or (d != "generated"
190
+ and keep_package_dir(os.path.join(dirpath, d))))]
184
191
  for fn in filenames:
185
192
  if (fn.endswith(_SOURCE_EXTS) and not fn.endswith((".min.js", ".bundle.js", ".d.ts", ".d.mts", ".d.cts"))
186
193
  and not _TEST_FILE_RE.search(fn)):
@@ -146,6 +146,13 @@ def _boto3_client(service, endpoint_url=None, **kwargs):
146
146
  """
147
147
  if endpoint_url is not None:
148
148
  kwargs['endpoint_url'] = endpoint_url
149
+ if 'config' not in kwargs:
150
+ try:
151
+ from botocore.config import Config
152
+ from narvy.useragent import USER_AGENT
153
+ kwargs['config'] = Config(user_agent_extra=USER_AGENT)
154
+ except Exception: # noqa: BLE001 - the identity never blocks a scan
155
+ pass
149
156
  return boto3.client(service, **kwargs)
150
157
 
151
158
 
@@ -10,6 +10,8 @@ from datetime import datetime
10
10
  import google.auth
11
11
  from google.auth.transport.requests import Request
12
12
  import requests
13
+
14
+ from narvy.useragent import with_ua
13
15
  import logging
14
16
 
15
17
  from .rule_severity import stamp_items as _stamp_rule_severity
@@ -53,7 +55,7 @@ def make_request(url, credentials, _scan_ctx=None):
53
55
  if _scan_ctx is not None:
54
56
  _scan_ctx['total_calls'] = _scan_ctx.get('total_calls', 0) + 1
55
57
 
56
- headers = {"Authorization": f"Bearer {credentials.token}"}
58
+ headers = with_ua({"Authorization": f"Bearer {credentials.token}"})
57
59
  try:
58
60
  response = requests.get(url, headers=headers, timeout=30)
59
61
  except requests.exceptions.RequestException as e:
@@ -10,6 +10,8 @@ import logging
10
10
 
11
11
  import requests
12
12
 
13
+ from narvy.useragent import with_ua
14
+
13
15
  from .apk_memory_preflight import (
14
16
  MIN_HEAP_MB,
15
17
  app_scale,
@@ -75,7 +77,7 @@ def _download_jadx():
75
77
  os.makedirs(TOOLS_DIR, exist_ok=True)
76
78
  zip_path = os.path.join(TOOLS_DIR, f"jadx-{JADX_VERSION}.zip")
77
79
  logger.info(f"jadx not found on PATH - downloading {JADX_URL}")
78
- resp = requests.get(JADX_URL, stream=True, timeout=120)
80
+ resp = requests.get(JADX_URL, stream=True, timeout=120, headers=with_ua())
79
81
  resp.raise_for_status()
80
82
  with open(zip_path, "wb") as f:
81
83
  for chunk in resp.iter_content(chunk_size=1 << 20):
@@ -134,7 +136,8 @@ def _download_jre():
134
136
  is_zip = _IS_WINDOWS
135
137
  archive_path = os.path.join(TOOLS_DIR, f"jre-{_JRE_MAJOR}.{'zip' if is_zip else 'tar.gz'}")
136
138
  logger.info(f"No usable Java 11+ found - downloading a JRE ourselves from {JRE_URL}")
137
- resp = requests.get(JRE_URL, stream=True, timeout=180, allow_redirects=True)
139
+ resp = requests.get(JRE_URL, stream=True, timeout=180, allow_redirects=True,
140
+ headers=with_ua())
138
141
  resp.raise_for_status()
139
142
  with open(archive_path, "wb") as f:
140
143
  for chunk in resp.iter_content(chunk_size=1 << 20):
@@ -98,7 +98,9 @@ def _download_tarball(timeout: int = DOWNLOAD_TIMEOUT) -> str:
98
98
  try:
99
99
  fd, tmp_path = tempfile.mkstemp(prefix=".lynis_dl_", dir=directory)
100
100
  os.close(fd)
101
- with urllib.request.urlopen(LYNIS_URL, timeout=timeout) as resp, \
101
+ from narvy.useragent import with_ua
102
+ _req = urllib.request.Request(LYNIS_URL, headers=with_ua())
103
+ with urllib.request.urlopen(_req, timeout=timeout) as resp, \
102
104
  open(tmp_path, "wb") as out:
103
105
  while True:
104
106
  chunk = resp.read(1024 * 256)
@@ -12,6 +12,7 @@ from narvy.rule_engine import load_rules_from_dir, run_rules_on_file
12
12
  from narvy.pathnorm import canonical_path
13
13
  from narvy import semgrep_engine
14
14
  from narvy import secret_value_grade
15
+ from narvy import production_source
15
16
  from narvy.proc import run_tree
16
17
  from narvy import comment_filter
17
18
  from narvy.ios.third_party_filter import is_ios_vendor_dir_path, IOS_VENDOR_DIR_NAMES
@@ -138,6 +139,9 @@ def _run_swift_semgrep(source_dir: str,
138
139
  "--timeout", "60"]
139
140
  + semgrep_engine.resource_args(semgrep_engine.semgrep_jobs())
140
141
  + exclude_args
142
+ # A SwiftPM target subfolder named test/ or vendor/ (no C files) is
143
+ # not dropped by semgrep's default ignore list (production_source).
144
+ + production_source.default_ignore_args(semgrep_engine.semgrep_bin(), source_dir)
141
145
  )
142
146
  try:
143
147
  proc = run_tree(cmd, timeout=timeout, env=semgrep_engine.semgrep_env())
@@ -1019,7 +1019,8 @@ def _run_local_scan(apk_path, max_mem, override_config=None, force=False,
1019
1019
  if semgrep_engine.is_available():
1020
1020
  console.print("[dim]Running deep structural analysis (AST-aware, taint-tracking) - can take several minutes on larger apps, this is normal, don't interrupt.[/dim]")
1021
1021
  task3 = progress.add_task("[cyan]Deep structural analysis...", total=None)
1022
- semgrep_findings = semgrep_engine.run_semgrep(temp_dir, own_roots=own_roots, override_config=override_config)
1022
+ semgrep_findings = semgrep_engine.run_semgrep(temp_dir, own_roots=own_roots, override_config=override_config,
1023
+ jadx_tree=True)
1023
1024
  if semgrep_findings:
1024
1025
  all_findings.extend(semgrep_findings)
1025
1026
  if semgrep_engine.LAST_RUN.get('status') == 'ok':