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,258 @@
1
+ # Rust web-source security rules, authored by Narvy.
2
+ # Covers OS command injection, raw SQL string construction with sqlx,
3
+ # weak/broken hashing, and untrusted binary deserialization.
4
+
5
+ rules:
6
+
7
+ # OS command injection - shell -c with a non-literal argument
8
+ - id: narvy.rust.command-injection.command-injection-arg.command-injection-arg
9
+ message: >
10
+ A shell is launched with `-c` and a non-literal command string
11
+ (Command::new("sh").arg("-c").arg(<expr>)). Whatever the expression
12
+ evaluates to is parsed by the shell, so untrusted input yields arbitrary
13
+ command execution (CWE-78). Remediation: run the target program directly
14
+ with a fixed argument vector (Command::new("prog").arg(user_value)) so no
15
+ shell interprets metacharacters, and validate the value against an
16
+ allow-list.
17
+ severity: ERROR
18
+ languages: [rust]
19
+ metadata:
20
+ category: security
21
+ cwe:
22
+ - "CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')"
23
+ owasp:
24
+ - "A03:2021 - Injection"
25
+ subcategory: [vuln]
26
+ likelihood: HIGH
27
+ impact: HIGH
28
+ confidence: MEDIUM
29
+ source: narvy-local
30
+ patterns:
31
+ - pattern-either:
32
+ - pattern: Command::new("sh").arg("-c").arg($CMD)
33
+ - pattern: Command::new("bash").arg("-c").arg($CMD)
34
+ - pattern: Command::new("/bin/sh").arg("-c").arg($CMD)
35
+ - pattern: Command::new("/bin/bash").arg("-c").arg($CMD)
36
+ - pattern: Command::new("zsh").arg("-c").arg($CMD)
37
+ - pattern: std::process::Command::new("sh").arg("-c").arg($CMD)
38
+ - pattern: std::process::Command::new("bash").arg("-c").arg($CMD)
39
+ - pattern: std::process::Command::new("/bin/sh").arg("-c").arg($CMD)
40
+ - pattern: std::process::Command::new("/bin/bash").arg("-c").arg($CMD)
41
+ - metavariable-pattern:
42
+ metavariable: $CMD
43
+ patterns:
44
+ - pattern-not: '"..."'
45
+
46
+ # OS command injection - program name is not a string literal
47
+ - id: narvy.rust.command-injection.command-injection-non-literal.command-injection-non-literal
48
+ message: >
49
+ The program passed to Command::new is not a string literal. If the value
50
+ is influenced by untrusted input an attacker can choose which binary to
51
+ execute (CWE-78). Remediation: select the executable from a fixed,
52
+ hard-coded allow-list rather than building the program name at runtime;
53
+ if a path must be configurable, resolve it from trusted configuration and
54
+ validate it before use.
55
+ severity: WARNING
56
+ languages: [rust]
57
+ metadata:
58
+ category: security
59
+ cwe:
60
+ - "CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')"
61
+ owasp:
62
+ - "A03:2021 - Injection"
63
+ subcategory: [audit]
64
+ likelihood: MEDIUM
65
+ impact: HIGH
66
+ confidence: LOW
67
+ source: narvy-local
68
+ patterns:
69
+ - pattern-either:
70
+ - pattern: Command::new($CMD)
71
+ - pattern: std::process::Command::new($CMD)
72
+ - pattern-not: Command::new("...")
73
+ - pattern-not: std::process::Command::new("...")
74
+ - pattern-not: Command::new(&"...")
75
+ - pattern-not: std::process::Command::new(&"...")
76
+
77
+ # Broken password hashing - MD5
78
+ - id: narvy.rust.md5-used-as-password-hash.md5-used-as-password-hash.md5-used-as-password-hash
79
+ message: >
80
+ The md5 crate is used to hash data. MD5 is a fast, collision-broken hash
81
+ with no work factor, so using it for passwords or credentials leaves them
82
+ trivially recoverable with rainbow tables or brute force
83
+ (CWE-916, CWE-327). Remediation: hash passwords with a purpose-built
84
+ password KDF - argon2, bcrypt, or scrypt - and reserve MD5, if anything,
85
+ for non-security checksums only.
86
+ severity: ERROR
87
+ languages: [rust]
88
+ metadata:
89
+ category: security
90
+ cwe:
91
+ - "CWE-916: Use of Password Hash With Insufficient Computational Effort"
92
+ - "CWE-327: Use of a Broken or Risky Cryptographic Algorithm"
93
+ owasp:
94
+ - "A02:2021 - Cryptographic Failures"
95
+ subcategory: [vuln]
96
+ likelihood: HIGH
97
+ impact: HIGH
98
+ confidence: MEDIUM
99
+ source: narvy-local
100
+ pattern-either:
101
+ - pattern: md5::compute(...)
102
+ - pattern: Md5::new()
103
+ - pattern: md5::Md5::new()
104
+ - pattern: Md5::digest(...)
105
+ - pattern: md5::Md5::digest(...)
106
+
107
+ # Weak hash - SHA-1
108
+ - id: narvy.rust.sha1-weak-hash.sha1-weak-hash.sha1-weak-hash
109
+ message: >
110
+ SHA-1 is used to compute a hash. SHA-1 is broken against collision attacks
111
+ and must not be used for signatures, integrity guarantees, or credential
112
+ handling (CWE-327). Remediation: use SHA-256 or SHA-3 for integrity, and a
113
+ dedicated password KDF (argon2/bcrypt/scrypt) for credentials.
114
+ severity: WARNING
115
+ languages: [rust]
116
+ metadata:
117
+ category: security
118
+ cwe:
119
+ - "CWE-327: Use of a Broken or Risky Cryptographic Algorithm"
120
+ owasp:
121
+ - "A02:2021 - Cryptographic Failures"
122
+ subcategory: [audit]
123
+ likelihood: MEDIUM
124
+ impact: MEDIUM
125
+ confidence: MEDIUM
126
+ source: narvy-local
127
+ pattern-either:
128
+ - pattern: Sha1::new()
129
+ - pattern: sha1::Sha1::new()
130
+ - pattern: Sha1::digest(...)
131
+ - pattern: sha1::Sha1::digest(...)
132
+
133
+ # SQL injection - sqlx query built with format!()
134
+ - id: narvy.rust.sql-injection.sql-injection-format.sql-injection-format
135
+ message: >
136
+ A sqlx query string is built with format!(). Any value interpolated by
137
+ format! becomes part of the SQL text, so a user-controlled argument allows
138
+ SQL injection (CWE-89). Remediation: keep the SQL literal and pass values
139
+ as bound parameters - sqlx::query("... WHERE id = $1").bind(id) - or use
140
+ the compile-time-checked query!/query_as! macros.
141
+ severity: ERROR
142
+ languages: [rust]
143
+ metadata:
144
+ category: security
145
+ cwe:
146
+ - "CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')"
147
+ owasp:
148
+ - "A03:2021 - Injection"
149
+ subcategory: [vuln]
150
+ likelihood: HIGH
151
+ impact: HIGH
152
+ confidence: MEDIUM
153
+ source: narvy-local
154
+ pattern-either:
155
+ - pattern: sqlx::query(&format!(...))
156
+ - pattern: sqlx::query(format!(...).as_str())
157
+ - pattern: sqlx::query_as::<_, $T>(&format!(...))
158
+ - pattern: sqlx::query_scalar(&format!(...))
159
+ - pattern: |
160
+ let $S = format!(...);
161
+ ...
162
+ sqlx::query(&$S)
163
+ - pattern: |
164
+ let $S = format!(...);
165
+ ...
166
+ sqlx::query($S.as_str())
167
+ - pattern: |
168
+ let $S = format!(...);
169
+ ...
170
+ sqlx::query_as::<_, $T>(&$S)
171
+
172
+ # SQL injection - sqlx query built by mutating a String
173
+ - id: narvy.rust.sql-injection.sql-injection-string-push.sql-injection-string-push
174
+ message: >
175
+ A mutable String is assembled with runtime data (write!/push_str) and then
176
+ handed to sqlx::query. Concatenating values into raw SQL text allows SQL
177
+ injection (CWE-89). Remediation: build the statement with a fixed SQL
178
+ string and bound parameters, or use sqlx's QueryBuilder with .push_bind()
179
+ so values are never spliced into the query text.
180
+ severity: ERROR
181
+ languages: [rust]
182
+ metadata:
183
+ category: security
184
+ cwe:
185
+ - "CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')"
186
+ owasp:
187
+ - "A03:2021 - Injection"
188
+ subcategory: [audit]
189
+ likelihood: HIGH
190
+ impact: HIGH
191
+ confidence: LOW
192
+ source: narvy-local
193
+ pattern-either:
194
+ - pattern: |
195
+ let mut $S = String::new();
196
+ ...
197
+ write!($S, ...).unwrap();
198
+ ...
199
+ sqlx::query(&$S)
200
+ - pattern: |
201
+ let mut $S = String::new();
202
+ ...
203
+ write!($S, ...)?;
204
+ ...
205
+ sqlx::query(&$S)
206
+ - pattern: |
207
+ let mut $S = String::new();
208
+ ...
209
+ write!($S, ...).expect(...);
210
+ ...
211
+ sqlx::query(&$S)
212
+ - pattern: |
213
+ let mut $S = String::new();
214
+ ...
215
+ writeln!($S, ...).unwrap();
216
+ ...
217
+ sqlx::query(&$S)
218
+ - pattern: |
219
+ let mut $S = String::new();
220
+ ...
221
+ writeln!($S, ...)?;
222
+ ...
223
+ sqlx::query(&$S)
224
+ - pattern: |
225
+ let mut $S = String::new();
226
+ ...
227
+ $S.push_str(&format!(...));
228
+ ...
229
+ sqlx::query(&$S)
230
+
231
+ # Untrusted deserialization - bincode
232
+ - id: narvy.rust.bincode-deserialize.bincode-deserialize.bincode-deserialize
233
+ message: >
234
+ Data is decoded with bincode::deserialize. Bincode performs no validation
235
+ of length prefixes or structure, so a hostile buffer can drive very large
236
+ allocations (denial of service) and, combined with unsound downstream
237
+ code, memory-safety problems (CWE-502). Remediation: only deserialize
238
+ bincode from a trusted source; for data crossing a trust boundary, apply
239
+ a configured size limit (bincode::options().with_limit(...)) and
240
+ authenticate the bytes (e.g. an HMAC) before decoding.
241
+ severity: WARNING
242
+ languages: [rust]
243
+ metadata:
244
+ category: security
245
+ cwe:
246
+ - "CWE-502: Deserialization of Untrusted Data"
247
+ owasp:
248
+ - "A08:2021 - Software and Data Integrity Failures"
249
+ subcategory: [audit]
250
+ likelihood: LOW
251
+ impact: MEDIUM
252
+ confidence: LOW
253
+ source: narvy-local
254
+ pattern-either:
255
+ - pattern: bincode::deserialize(...)
256
+ - pattern: bincode::deserialize_from(...)
257
+ - pattern: bincode::deserialize_in_place(...)
258
+ - pattern: bincode::options().deserialize(...)