narvy-cli 1.0.0__py3-none-any.whl

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 (93) hide show
  1. narvy/__init__.py +3 -0
  2. narvy/android/__init__.py +0 -0
  3. narvy/android/source_analyzer.py +268 -0
  4. narvy/android/split_bundle.py +475 -0
  5. narvy/android_rule_context.py +196 -0
  6. narvy/apk_memory_preflight.py +248 -0
  7. narvy/auth.py +40 -0
  8. narvy/ci_templates/bitbucket.yml +25 -0
  9. narvy/ci_templates/github.yml +60 -0
  10. narvy/ci_templates/gitlab.yml +32 -0
  11. narvy/cloud/__init__.py +0 -0
  12. narvy/cloud/aws_scan.py +1188 -0
  13. narvy/comment_filter.py +134 -0
  14. narvy/crypto_taint_lite.py +82 -0
  15. narvy/decompiler.py +337 -0
  16. narvy/doctor.py +244 -0
  17. narvy/host/__init__.py +0 -0
  18. narvy/host/audit.py +157 -0
  19. narvy/host/host_knowledge.py +982 -0
  20. narvy/host/lynis_bootstrap.py +400 -0
  21. narvy/host/lynis_parser.py +358 -0
  22. narvy/host/narvy_checks.py +789 -0
  23. narvy/host/report.py +69 -0
  24. narvy/host/ssh_exec.py +219 -0
  25. narvy/ios/__init__.py +0 -0
  26. narvy/ios/binary_analyzer.py +1201 -0
  27. narvy/ios/plist_checks.py +249 -0
  28. narvy/ios/source_analyzer.py +301 -0
  29. narvy/ios/third_party_filter.py +242 -0
  30. narvy/ios/trust_all_context.py +66 -0
  31. narvy/main.py +1983 -0
  32. narvy/native_hardening.py +503 -0
  33. narvy/reporter.py +151 -0
  34. narvy/rule_engine.py +57 -0
  35. narvy/rules/android/config.yml +77 -0
  36. narvy/rules/android/crypto.yml +34 -0
  37. narvy/rules/android/secrets.yml +161 -0
  38. narvy/rules/android/storage.yml +24 -0
  39. narvy/rules/android/webview.yml +23 -0
  40. narvy/rules/android.yml +219 -0
  41. narvy/rules/ios/objc/crypto.yml +56 -0
  42. narvy/rules/ios/objc/network.yml +67 -0
  43. narvy/rules/ios/objc/secrets.yml +79 -0
  44. narvy/rules/ios/objc/storage.yml +45 -0
  45. narvy/rules/ios/objc/webview.yml +45 -0
  46. narvy/rules/ios_swift.yml +327 -0
  47. narvy/rules/web/go.yml +2837 -0
  48. narvy/rules/web/java.yml +1576 -0
  49. narvy/rules/web/javascript.yml +3683 -0
  50. narvy/rules/web/kotlin.yml +413 -0
  51. narvy/rules/web/local/csharp_narvy/config.yml +61 -0
  52. narvy/rules/web/local/csharp_narvy/crypto.yml +64 -0
  53. narvy/rules/web/local/csharp_narvy/deserialization.yml +59 -0
  54. narvy/rules/web/local/csharp_narvy/injection.yml +122 -0
  55. narvy/rules/web/local/csharp_narvy/xxe.yml +48 -0
  56. narvy/rules/web/local/java_narvy/auth_jwt.yml +134 -0
  57. narvy/rules/web/local/java_narvy/deserialization.yml +108 -0
  58. narvy/rules/web/local/java_narvy/mybatis.yml +39 -0
  59. narvy/rules/web/local/java_narvy/snakeyaml.yml +34 -0
  60. narvy/rules/web/local/java_narvy/spring_authz.yml +32 -0
  61. narvy/rules/web/local/java_narvy/spring_config.yml +67 -0
  62. narvy/rules/web/local/java_narvy/spring_hardening.yml +291 -0
  63. narvy/rules/web/local/java_narvy/sqli.yml +235 -0
  64. narvy/rules/web/local/java_narvy/xxe.yml +212 -0
  65. narvy/rules/web/php.yml +1644 -0
  66. narvy/rules/web/python.yml +3967 -0
  67. narvy/rules/web/ruby.yml +703 -0
  68. narvy/rules/web/rust.yml +258 -0
  69. narvy/rules/web/secrets.yml +1420 -0
  70. narvy/rules/web/secrets_supplement.yml +383 -0
  71. narvy/sca/__init__.py +1 -0
  72. narvy/sca/android_deps.py +349 -0
  73. narvy/sca/ios_deps.py +578 -0
  74. narvy/sca/osv_client.py +617 -0
  75. narvy/sca/web_deps.py +955 -0
  76. narvy/scope_config.py +195 -0
  77. narvy/semgrep_engine.py +219 -0
  78. narvy/stack_protector_evidence.py +96 -0
  79. narvy/third_party_filter.py +211 -0
  80. narvy/uploader.py +92 -0
  81. narvy/weak_prng_context.py +270 -0
  82. narvy/web/__init__.py +0 -0
  83. narvy/web/nuclei_binary.py +105 -0
  84. narvy/web/scan_blocklist.py +96 -0
  85. narvy/web/scanner.py +842 -0
  86. narvy/web/source_analyzer.py +714 -0
  87. narvy/web/ssrf_guard.py +374 -0
  88. narvy_cli-1.0.0.dist-info/METADATA +165 -0
  89. narvy_cli-1.0.0.dist-info/RECORD +93 -0
  90. narvy_cli-1.0.0.dist-info/WHEEL +5 -0
  91. narvy_cli-1.0.0.dist-info/entry_points.txt +2 -0
  92. narvy_cli-1.0.0.dist-info/licenses/LICENSE +202 -0
  93. narvy_cli-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,96 @@
1
+ """Optional web-scan denylist. Nothing refused by default; set SCAN_BLOCKLIST_EXTRA
2
+ to refuse domains. Internal/reserved-target protection lives in web/ssrf_guard.py.
3
+ _MAJOR_PLATFORMS/_OWN_DOMAINS below are reference only, NOT enforced by default.
4
+ """
5
+
6
+ import os
7
+ from typing import Optional, Set
8
+ from urllib.parse import urlparse
9
+
10
+ try:
11
+ from loguru import logger
12
+ except Exception: # pragma: no cover
13
+ import logging
14
+ logger = logging.getLogger("scan_blocklist")
15
+
16
+
17
+ REFUSAL_MESSAGE = (
18
+ "This target looks like a property you do not own. Narvy only scans "
19
+ "sites you own or are authorized to test. Point it at your own domain."
20
+ )
21
+
22
+
23
+ _OWN_DOMAINS = {
24
+ 'narvy.io',
25
+ }
26
+
27
+ # Registrable domains only; subdomains are covered by the suffix match.
28
+ _MAJOR_PLATFORMS = {
29
+ 'twitter.com', 'x.com', 'facebook.com', 'fb.com', 'instagram.com',
30
+ 'linkedin.com', 'tiktok.com', 'snapchat.com', 'pinterest.com',
31
+ 'reddit.com', 'whatsapp.com', 'telegram.org', 'discord.com',
32
+ 'threads.net', 'mastodon.social', 'tumblr.com', 'twitch.tv',
33
+ 'google.com', 'google.co.uk', 'youtube.com', 'gmail.com',
34
+ 'googleapis.com', 'gstatic.com',
35
+ 'microsoft.com', 'live.com', 'office.com', 'bing.com', 'azure.com',
36
+ 'windows.com', 'apple.com', 'icloud.com', 'amazon.com', 'aws.amazon.com',
37
+ 'amazonaws.com',
38
+ 'github.com', 'gitlab.com', 'bitbucket.org', 'cloudflare.com',
39
+ 'slack.com', 'zoom.us', 'dropbox.com', 'salesforce.com', 'atlassian.com',
40
+ 'shopify.com', 'stripe.com', 'paypal.com', 'wordpress.com', 'wix.com',
41
+ 'squarespace.com', 'netflix.com', 'spotify.com',
42
+ 'yahoo.com', 'outlook.com', 'proton.me', 'protonmail.com',
43
+ }
44
+
45
+
46
+ def _env_extra_domains() -> Set[str]:
47
+ """Extra refused domains from the comma-separated SCAN_BLOCKLIST_EXTRA env var."""
48
+ raw = os.environ.get('SCAN_BLOCKLIST_EXTRA', '')
49
+ return {d.strip().lower().lstrip('.') for d in raw.split(',') if d.strip()}
50
+
51
+
52
+ def blocked_domains() -> Set[str]:
53
+ return _env_extra_domains()
54
+
55
+
56
+ class ScanBlocked(Exception):
57
+ """Its message is always REFUSAL_MESSAGE, safe to surface verbatim."""
58
+
59
+ def __init__(self, message: str = REFUSAL_MESSAGE):
60
+ super().__init__(message)
61
+
62
+
63
+ def normalize_host(host: Optional[str]) -> str:
64
+ """Lowercase, strip a trailing FQDN dot and a leading ``www.``."""
65
+ if not host:
66
+ return ''
67
+ host = host.strip().lower()
68
+ if host.endswith('.'):
69
+ host = host[:-1]
70
+ if host.startswith('www.'):
71
+ host = host[4:]
72
+ return host
73
+
74
+
75
+ def is_blocked_host(host: Optional[str]) -> bool:
76
+ """True if the normalized host equals a refused domain or is a subdomain of one."""
77
+ norm = normalize_host(host)
78
+ if not norm:
79
+ return False
80
+ for domain in blocked_domains():
81
+ if norm == domain or norm.endswith('.' + domain):
82
+ return True
83
+ return False
84
+
85
+
86
+ def check_blocklist(url: str) -> None:
87
+ """Raise ``ScanBlocked`` if ``url`` targets a refused domain."""
88
+ if not url or not isinstance(url, str):
89
+ return
90
+ try:
91
+ host = urlparse(url).hostname
92
+ except Exception:
93
+ return
94
+ if is_blocked_host(host):
95
+ logger.warning(f"[scan_blocklist] refused target the user is unlikely to own host={host!r}")
96
+ raise ScanBlocked()