omgkit 2.12.0 → 2.15.0
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.
- package/README.md +97 -12
- package/package.json +2 -2
- package/plugin/agents/api-designer.md +5 -0
- package/plugin/agents/architect.md +8 -0
- package/plugin/agents/brainstormer.md +4 -0
- package/plugin/agents/cicd-manager.md +6 -0
- package/plugin/agents/code-reviewer.md +6 -0
- package/plugin/agents/copywriter.md +2 -0
- package/plugin/agents/data-engineer.md +255 -0
- package/plugin/agents/database-admin.md +10 -0
- package/plugin/agents/debugger.md +10 -0
- package/plugin/agents/devsecops.md +314 -0
- package/plugin/agents/docs-manager.md +4 -0
- package/plugin/agents/domain-decomposer.md +181 -0
- package/plugin/agents/embedded-systems.md +397 -0
- package/plugin/agents/fullstack-developer.md +12 -0
- package/plugin/agents/game-systems-designer.md +375 -0
- package/plugin/agents/git-manager.md +10 -0
- package/plugin/agents/journal-writer.md +2 -0
- package/plugin/agents/ml-engineer.md +284 -0
- package/plugin/agents/observability-engineer.md +353 -0
- package/plugin/agents/oracle.md +9 -0
- package/plugin/agents/performance-engineer.md +290 -0
- package/plugin/agents/pipeline-architect.md +6 -0
- package/plugin/agents/planner.md +12 -0
- package/plugin/agents/platform-engineer.md +325 -0
- package/plugin/agents/project-manager.md +3 -0
- package/plugin/agents/researcher.md +5 -0
- package/plugin/agents/scientific-computing.md +426 -0
- package/plugin/agents/scout.md +3 -0
- package/plugin/agents/security-auditor.md +7 -0
- package/plugin/agents/sprint-master.md +17 -0
- package/plugin/agents/tester.md +10 -0
- package/plugin/agents/ui-ux-designer.md +12 -0
- package/plugin/agents/vulnerability-scanner.md +6 -0
- package/plugin/commands/data/pipeline.md +47 -0
- package/plugin/commands/data/quality.md +49 -0
- package/plugin/commands/domain/analyze.md +34 -0
- package/plugin/commands/domain/map.md +41 -0
- package/plugin/commands/game/balance.md +56 -0
- package/plugin/commands/game/optimize.md +62 -0
- package/plugin/commands/iot/provision.md +58 -0
- package/plugin/commands/ml/evaluate.md +47 -0
- package/plugin/commands/ml/train.md +48 -0
- package/plugin/commands/perf/benchmark.md +54 -0
- package/plugin/commands/perf/profile.md +49 -0
- package/plugin/commands/platform/blueprint.md +56 -0
- package/plugin/commands/security/audit.md +54 -0
- package/plugin/commands/security/scan.md +55 -0
- package/plugin/commands/sre/dashboard.md +53 -0
- package/plugin/registry.yaml +711 -0
- package/plugin/skills/ai-ml/experiment-tracking/SKILL.md +338 -0
- package/plugin/skills/ai-ml/feature-stores/SKILL.md +340 -0
- package/plugin/skills/ai-ml/llm-ops/SKILL.md +454 -0
- package/plugin/skills/ai-ml/ml-pipelines/SKILL.md +390 -0
- package/plugin/skills/ai-ml/model-monitoring/SKILL.md +398 -0
- package/plugin/skills/ai-ml/model-serving/SKILL.md +386 -0
- package/plugin/skills/event-driven/cqrs-patterns/SKILL.md +348 -0
- package/plugin/skills/event-driven/event-sourcing/SKILL.md +334 -0
- package/plugin/skills/event-driven/kafka-deep/SKILL.md +252 -0
- package/plugin/skills/event-driven/saga-orchestration/SKILL.md +335 -0
- package/plugin/skills/event-driven/schema-registry/SKILL.md +328 -0
- package/plugin/skills/event-driven/stream-processing/SKILL.md +313 -0
- package/plugin/skills/game/game-audio/SKILL.md +446 -0
- package/plugin/skills/game/game-networking/SKILL.md +490 -0
- package/plugin/skills/game/godot-patterns/SKILL.md +413 -0
- package/plugin/skills/game/shader-programming/SKILL.md +492 -0
- package/plugin/skills/game/unity-patterns/SKILL.md +488 -0
- package/plugin/skills/iot/device-provisioning/SKILL.md +405 -0
- package/plugin/skills/iot/edge-computing/SKILL.md +369 -0
- package/plugin/skills/iot/industrial-protocols/SKILL.md +438 -0
- package/plugin/skills/iot/mqtt-deep/SKILL.md +418 -0
- package/plugin/skills/iot/ota-updates/SKILL.md +426 -0
- package/plugin/skills/microservices/api-gateway-patterns/SKILL.md +201 -0
- package/plugin/skills/microservices/circuit-breaker-patterns/SKILL.md +246 -0
- package/plugin/skills/microservices/contract-testing/SKILL.md +284 -0
- package/plugin/skills/microservices/distributed-tracing/SKILL.md +246 -0
- package/plugin/skills/microservices/service-discovery/SKILL.md +304 -0
- package/plugin/skills/microservices/service-mesh/SKILL.md +181 -0
- package/plugin/skills/mobile-advanced/mobile-ci-cd/SKILL.md +407 -0
- package/plugin/skills/mobile-advanced/mobile-security/SKILL.md +403 -0
- package/plugin/skills/mobile-advanced/offline-first/SKILL.md +473 -0
- package/plugin/skills/mobile-advanced/push-notifications/SKILL.md +494 -0
- package/plugin/skills/mobile-advanced/react-native-deep/SKILL.md +374 -0
- package/plugin/skills/simulation/numerical-methods/SKILL.md +434 -0
- package/plugin/skills/simulation/parallel-computing/SKILL.md +382 -0
- package/plugin/skills/simulation/physics-engines/SKILL.md +377 -0
- package/plugin/skills/simulation/validation-verification/SKILL.md +479 -0
- package/plugin/skills/simulation/visualization-scientific/SKILL.md +365 -0
- package/plugin/templates/autonomous/archetypes/event-driven-app.yaml +460 -0
- package/plugin/templates/autonomous/archetypes/microservices-app.yaml +431 -0
- package/plugin/templates/autonomous/state-schema.yaml +1 -1
- package/plugin/workflows/ai-engineering/agent-development.md +3 -3
- package/plugin/workflows/ai-engineering/fine-tuning.md +3 -3
- package/plugin/workflows/ai-engineering/model-evaluation.md +3 -3
- package/plugin/workflows/ai-engineering/prompt-engineering.md +2 -2
- package/plugin/workflows/ai-engineering/rag-development.md +4 -4
- package/plugin/workflows/ai-ml/data-pipeline.md +188 -0
- package/plugin/workflows/ai-ml/experiment-cycle.md +203 -0
- package/plugin/workflows/ai-ml/feature-engineering.md +208 -0
- package/plugin/workflows/ai-ml/model-deployment.md +199 -0
- package/plugin/workflows/ai-ml/monitoring-setup.md +227 -0
- package/plugin/workflows/api/api-design.md +1 -1
- package/plugin/workflows/api/api-testing.md +2 -2
- package/plugin/workflows/content/technical-docs.md +1 -1
- package/plugin/workflows/database/migration.md +1 -1
- package/plugin/workflows/database/optimization.md +1 -1
- package/plugin/workflows/database/schema-design.md +3 -3
- package/plugin/workflows/development/bug-fix.md +3 -3
- package/plugin/workflows/development/code-review.md +2 -1
- package/plugin/workflows/development/feature.md +3 -3
- package/plugin/workflows/development/refactor.md +2 -2
- package/plugin/workflows/event-driven/consumer-groups.md +190 -0
- package/plugin/workflows/event-driven/event-storming.md +172 -0
- package/plugin/workflows/event-driven/replay-testing.md +186 -0
- package/plugin/workflows/event-driven/saga-implementation.md +206 -0
- package/plugin/workflows/event-driven/schema-evolution.md +173 -0
- package/plugin/workflows/fullstack/authentication.md +4 -4
- package/plugin/workflows/fullstack/full-feature.md +4 -4
- package/plugin/workflows/game-dev/content-pipeline.md +218 -0
- package/plugin/workflows/game-dev/platform-submission.md +263 -0
- package/plugin/workflows/game-dev/playtesting.md +237 -0
- package/plugin/workflows/game-dev/prototype-to-production.md +205 -0
- package/plugin/workflows/microservices/contract-first.md +151 -0
- package/plugin/workflows/microservices/distributed-tracing.md +166 -0
- package/plugin/workflows/microservices/domain-decomposition.md +123 -0
- package/plugin/workflows/microservices/integration-testing.md +149 -0
- package/plugin/workflows/microservices/service-mesh-setup.md +153 -0
- package/plugin/workflows/microservices/service-scaffolding.md +151 -0
- package/plugin/workflows/omega/1000x-innovation.md +2 -2
- package/plugin/workflows/omega/100x-architecture.md +2 -2
- package/plugin/workflows/omega/10x-improvement.md +2 -2
- package/plugin/workflows/quality/performance-optimization.md +2 -2
- package/plugin/workflows/research/best-practices.md +1 -1
- package/plugin/workflows/research/technology-research.md +1 -1
- package/plugin/workflows/security/penetration-testing.md +3 -3
- package/plugin/workflows/security/security-audit.md +3 -3
- package/plugin/workflows/sprint/sprint-execution.md +2 -2
- package/plugin/workflows/sprint/sprint-retrospective.md +1 -1
- package/plugin/workflows/sprint/sprint-setup.md +1 -1
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# Mobile Security
|
|
2
|
+
|
|
3
|
+
Secure storage, certificate pinning, biometric authentication, app hardening, and OWASP mobile security.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Mobile security protects applications and user data from threats including reverse engineering, data theft, and network attacks.
|
|
8
|
+
|
|
9
|
+
## Core Concepts
|
|
10
|
+
|
|
11
|
+
### OWASP Mobile Top 10
|
|
12
|
+
1. Improper Platform Usage
|
|
13
|
+
2. Insecure Data Storage
|
|
14
|
+
3. Insecure Communication
|
|
15
|
+
4. Insecure Authentication
|
|
16
|
+
5. Insufficient Cryptography
|
|
17
|
+
6. Insecure Authorization
|
|
18
|
+
7. Client Code Quality
|
|
19
|
+
8. Code Tampering
|
|
20
|
+
9. Reverse Engineering
|
|
21
|
+
10. Extraneous Functionality
|
|
22
|
+
|
|
23
|
+
### Security Layers
|
|
24
|
+
- **Data at Rest**: Encrypted storage
|
|
25
|
+
- **Data in Transit**: TLS, certificate pinning
|
|
26
|
+
- **Authentication**: Biometrics, tokens
|
|
27
|
+
- **Code Protection**: Obfuscation, integrity checks
|
|
28
|
+
|
|
29
|
+
## Secure Storage
|
|
30
|
+
|
|
31
|
+
### React Native Implementation
|
|
32
|
+
```typescript
|
|
33
|
+
import * as Keychain from 'react-native-keychain';
|
|
34
|
+
import EncryptedStorage from 'react-native-encrypted-storage';
|
|
35
|
+
|
|
36
|
+
class SecureStorage {
|
|
37
|
+
// For sensitive credentials (passwords, tokens)
|
|
38
|
+
async storeCredentials(username: string, password: string): Promise<void> {
|
|
39
|
+
await Keychain.setGenericPassword(username, password, {
|
|
40
|
+
accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_ANY_OR_DEVICE_PASSCODE,
|
|
41
|
+
accessible: Keychain.ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
|
|
42
|
+
securityLevel: Keychain.SECURITY_LEVEL.SECURE_HARDWARE
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getCredentials(): Promise<{ username: string; password: string } | null> {
|
|
47
|
+
const credentials = await Keychain.getGenericPassword();
|
|
48
|
+
if (credentials) {
|
|
49
|
+
return {
|
|
50
|
+
username: credentials.username,
|
|
51
|
+
password: credentials.password
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// For larger encrypted data
|
|
58
|
+
async storeEncrypted(key: string, value: string): Promise<void> {
|
|
59
|
+
await EncryptedStorage.setItem(key, value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async getEncrypted(key: string): Promise<string | null> {
|
|
63
|
+
return await EncryptedStorage.getItem(key);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async clearAll(): Promise<void> {
|
|
67
|
+
await Keychain.resetGenericPassword();
|
|
68
|
+
await EncryptedStorage.clear();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### iOS Keychain (Native)
|
|
74
|
+
```swift
|
|
75
|
+
import Security
|
|
76
|
+
|
|
77
|
+
class KeychainManager {
|
|
78
|
+
static func save(key: String, data: Data) -> Bool {
|
|
79
|
+
let query: [String: Any] = [
|
|
80
|
+
kSecClass as String: kSecClassGenericPassword,
|
|
81
|
+
kSecAttrAccount as String: key,
|
|
82
|
+
kSecValueData as String: data,
|
|
83
|
+
kSecAttrAccessible as String: kSecAttrAccessibleWhenUnlockedThisDeviceOnly
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
SecItemDelete(query as CFDictionary)
|
|
87
|
+
let status = SecItemAdd(query as CFDictionary, nil)
|
|
88
|
+
return status == errSecSuccess
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static func load(key: String) -> Data? {
|
|
92
|
+
let query: [String: Any] = [
|
|
93
|
+
kSecClass as String: kSecClassGenericPassword,
|
|
94
|
+
kSecAttrAccount as String: key,
|
|
95
|
+
kSecReturnData as String: true,
|
|
96
|
+
kSecMatchLimit as String: kSecMatchLimitOne
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
var result: AnyObject?
|
|
100
|
+
let status = SecItemCopyMatching(query as CFDictionary, &result)
|
|
101
|
+
|
|
102
|
+
guard status == errSecSuccess else { return nil }
|
|
103
|
+
return result as? Data
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Android EncryptedSharedPreferences
|
|
109
|
+
```kotlin
|
|
110
|
+
import androidx.security.crypto.EncryptedSharedPreferences
|
|
111
|
+
import androidx.security.crypto.MasterKey
|
|
112
|
+
|
|
113
|
+
class SecurePreferences(context: Context) {
|
|
114
|
+
private val masterKey = MasterKey.Builder(context)
|
|
115
|
+
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
116
|
+
.build()
|
|
117
|
+
|
|
118
|
+
private val prefs = EncryptedSharedPreferences.create(
|
|
119
|
+
context,
|
|
120
|
+
"secure_prefs",
|
|
121
|
+
masterKey,
|
|
122
|
+
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
|
123
|
+
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
fun saveToken(token: String) {
|
|
127
|
+
prefs.edit().putString("auth_token", token).apply()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
fun getToken(): String? = prefs.getString("auth_token", null)
|
|
131
|
+
|
|
132
|
+
fun clear() = prefs.edit().clear().apply()
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Certificate Pinning
|
|
137
|
+
|
|
138
|
+
### React Native (SSL Pinning)
|
|
139
|
+
```typescript
|
|
140
|
+
import { fetch } from 'react-native-ssl-pinning';
|
|
141
|
+
|
|
142
|
+
const API_PINS = {
|
|
143
|
+
'api.example.com': {
|
|
144
|
+
// SHA256 hash of certificate public key
|
|
145
|
+
pins: [
|
|
146
|
+
'sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=',
|
|
147
|
+
'sha256/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=' // Backup
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
async function secureFetch(url: string, options: RequestInit) {
|
|
153
|
+
const hostname = new URL(url).hostname;
|
|
154
|
+
const pinConfig = API_PINS[hostname];
|
|
155
|
+
|
|
156
|
+
if (!pinConfig) {
|
|
157
|
+
throw new Error(`No pins configured for ${hostname}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return fetch(url, {
|
|
161
|
+
...options,
|
|
162
|
+
sslPinning: {
|
|
163
|
+
certs: pinConfig.pins
|
|
164
|
+
},
|
|
165
|
+
timeoutInterval: 30000
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### iOS Native (TrustKit)
|
|
171
|
+
```swift
|
|
172
|
+
import TrustKit
|
|
173
|
+
|
|
174
|
+
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
175
|
+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
|
176
|
+
|
|
177
|
+
let trustKitConfig: [String: Any] = [
|
|
178
|
+
kTSKSwizzleNetworkDelegates: true,
|
|
179
|
+
kTSKPinnedDomains: [
|
|
180
|
+
"api.example.com": [
|
|
181
|
+
kTSKEnforcePinning: true,
|
|
182
|
+
kTSKIncludeSubdomains: true,
|
|
183
|
+
kTSKPublicKeyHashes: [
|
|
184
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
|
185
|
+
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB="
|
|
186
|
+
],
|
|
187
|
+
kTSKReportUris: ["https://report.example.com/pinning"]
|
|
188
|
+
]
|
|
189
|
+
]
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
TrustKit.initSharedInstance(withConfiguration: trustKitConfig)
|
|
193
|
+
return true
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Biometric Authentication
|
|
199
|
+
|
|
200
|
+
### React Native
|
|
201
|
+
```typescript
|
|
202
|
+
import ReactNativeBiometrics, { BiometryTypes } from 'react-native-biometrics';
|
|
203
|
+
|
|
204
|
+
class BiometricAuth {
|
|
205
|
+
private biometrics = new ReactNativeBiometrics();
|
|
206
|
+
|
|
207
|
+
async isAvailable(): Promise<{ available: boolean; type: string }> {
|
|
208
|
+
const { available, biometryType } = await this.biometrics.isSensorAvailable();
|
|
209
|
+
return { available, type: biometryType || 'none' };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async authenticate(promptMessage: string): Promise<boolean> {
|
|
213
|
+
try {
|
|
214
|
+
const { success } = await this.biometrics.simplePrompt({
|
|
215
|
+
promptMessage,
|
|
216
|
+
cancelButtonText: 'Cancel',
|
|
217
|
+
fallbackPromptMessage: 'Use passcode'
|
|
218
|
+
});
|
|
219
|
+
return success;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
console.error('Biometric auth failed:', error);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Create biometric-protected key pair
|
|
227
|
+
async createKeys(): Promise<string> {
|
|
228
|
+
const { publicKey } = await this.biometrics.createKeys();
|
|
229
|
+
return publicKey;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Sign data with biometric verification
|
|
233
|
+
async signWithBiometrics(payload: string): Promise<string | null> {
|
|
234
|
+
try {
|
|
235
|
+
const { success, signature } = await this.biometrics.createSignature({
|
|
236
|
+
promptMessage: 'Authenticate to sign',
|
|
237
|
+
payload
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return success ? signature : null;
|
|
241
|
+
} catch {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## App Hardening
|
|
249
|
+
|
|
250
|
+
### Root/Jailbreak Detection
|
|
251
|
+
```typescript
|
|
252
|
+
import JailMonkey from 'jail-monkey';
|
|
253
|
+
|
|
254
|
+
class SecurityChecker {
|
|
255
|
+
isCompromised(): boolean {
|
|
256
|
+
return (
|
|
257
|
+
JailMonkey.isJailBroken() ||
|
|
258
|
+
JailMonkey.isOnExternalStorage() ||
|
|
259
|
+
JailMonkey.isDebuggedMode() ||
|
|
260
|
+
JailMonkey.hookDetected() ||
|
|
261
|
+
!JailMonkey.AdbEnabled()
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
enforceSecurityPolicy(): void {
|
|
266
|
+
if (this.isCompromised()) {
|
|
267
|
+
// Log security event
|
|
268
|
+
analytics.logEvent('security_violation', {
|
|
269
|
+
jailbroken: JailMonkey.isJailBroken(),
|
|
270
|
+
debugged: JailMonkey.isDebuggedMode()
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Disable sensitive features or exit
|
|
274
|
+
if (__DEV__) {
|
|
275
|
+
console.warn('Running on compromised device');
|
|
276
|
+
} else {
|
|
277
|
+
// Production: restrict functionality
|
|
278
|
+
this.restrictSensitiveFeatures();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Code Obfuscation (Android)
|
|
286
|
+
```groovy
|
|
287
|
+
// android/app/build.gradle
|
|
288
|
+
android {
|
|
289
|
+
buildTypes {
|
|
290
|
+
release {
|
|
291
|
+
minifyEnabled true
|
|
292
|
+
shrinkResources true
|
|
293
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
```proguard
|
|
300
|
+
# proguard-rules.pro
|
|
301
|
+
# Keep React Native
|
|
302
|
+
-keep class com.facebook.react.** { *; }
|
|
303
|
+
-keep class com.facebook.hermes.** { *; }
|
|
304
|
+
|
|
305
|
+
# Obfuscate app code
|
|
306
|
+
-repackageclasses 'o'
|
|
307
|
+
-allowaccessmodification
|
|
308
|
+
-optimizations !code/simplification/arithmetic
|
|
309
|
+
|
|
310
|
+
# Remove logging
|
|
311
|
+
-assumenosideeffects class android.util.Log {
|
|
312
|
+
public static *** d(...);
|
|
313
|
+
public static *** v(...);
|
|
314
|
+
public static *** i(...);
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Network Security
|
|
319
|
+
|
|
320
|
+
### Android Network Security Config
|
|
321
|
+
```xml
|
|
322
|
+
<!-- android/app/src/main/res/xml/network_security_config.xml -->
|
|
323
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
324
|
+
<network-security-config>
|
|
325
|
+
<base-config cleartextTrafficPermitted="false">
|
|
326
|
+
<trust-anchors>
|
|
327
|
+
<certificates src="system" />
|
|
328
|
+
</trust-anchors>
|
|
329
|
+
</base-config>
|
|
330
|
+
|
|
331
|
+
<domain-config>
|
|
332
|
+
<domain includeSubdomains="true">api.example.com</domain>
|
|
333
|
+
<pin-set expiration="2025-01-01">
|
|
334
|
+
<pin digest="SHA-256">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</pin>
|
|
335
|
+
<pin digest="SHA-256">BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=</pin>
|
|
336
|
+
</pin-set>
|
|
337
|
+
</domain-config>
|
|
338
|
+
</network-security-config>
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### iOS App Transport Security
|
|
342
|
+
```xml
|
|
343
|
+
<!-- ios/App/Info.plist -->
|
|
344
|
+
<key>NSAppTransportSecurity</key>
|
|
345
|
+
<dict>
|
|
346
|
+
<key>NSAllowsArbitraryLoads</key>
|
|
347
|
+
<false/>
|
|
348
|
+
<key>NSExceptionDomains</key>
|
|
349
|
+
<dict>
|
|
350
|
+
<key>api.example.com</key>
|
|
351
|
+
<dict>
|
|
352
|
+
<key>NSIncludesSubdomains</key>
|
|
353
|
+
<true/>
|
|
354
|
+
<key>NSRequiresCertificateTransparency</key>
|
|
355
|
+
<true/>
|
|
356
|
+
</dict>
|
|
357
|
+
</dict>
|
|
358
|
+
</dict>
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Best Practices
|
|
362
|
+
|
|
363
|
+
1. **Never Store Secrets in Code**: Use secure storage
|
|
364
|
+
2. **Certificate Pinning**: Pin to public key, not cert
|
|
365
|
+
3. **Biometric + PIN**: Always have fallback
|
|
366
|
+
4. **Obfuscate Production Builds**: ProGuard/R8
|
|
367
|
+
5. **Security Logging**: Monitor for attacks
|
|
368
|
+
|
|
369
|
+
## Security Checklist
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
□ Secure credential storage (Keychain/EncryptedPrefs)
|
|
373
|
+
□ Certificate pinning implemented
|
|
374
|
+
□ Biometric authentication available
|
|
375
|
+
□ Root/jailbreak detection
|
|
376
|
+
□ Code obfuscation enabled
|
|
377
|
+
□ Debug logging removed in production
|
|
378
|
+
□ Network security config (no cleartext)
|
|
379
|
+
□ Input validation
|
|
380
|
+
□ Session management secure
|
|
381
|
+
□ Sensitive data wiped on logout
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Anti-Patterns
|
|
385
|
+
|
|
386
|
+
- Storing tokens in AsyncStorage
|
|
387
|
+
- Hardcoded API keys
|
|
388
|
+
- No certificate pinning
|
|
389
|
+
- Logging sensitive data
|
|
390
|
+
- Trusting client-side validation
|
|
391
|
+
|
|
392
|
+
## When to Use
|
|
393
|
+
|
|
394
|
+
- Apps with sensitive data
|
|
395
|
+
- Financial applications
|
|
396
|
+
- Healthcare apps
|
|
397
|
+
- Enterprise applications
|
|
398
|
+
- Any production app
|
|
399
|
+
|
|
400
|
+
## When NOT to Use
|
|
401
|
+
|
|
402
|
+
- Never skip security basics
|
|
403
|
+
- Even prototypes should have basic security
|