ai_root_shield 0.4.0 → 0.5.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.
- checksums.yaml +4 -4
- data/README.md +160 -14
- data/exe/ai_root_shield +220 -7
- data/lib/ai_root_shield/version.rb +1 -1
- data/lib/ai_root_shield.rb +152 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ab00a90d8cb8fbc0cb67c95ef7bc24b29b6cc9c77049be87d228b4dbdb6f4e8
|
4
|
+
data.tar.gz: c4be63597e34946070cea7ffd0d9d978cc3049923e5d4b86aca02fc2151f23df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22228772e76a7d77b02a42c1a448c5aa694cdf2c90fe193d489d71264fb2e9946090a72d49fe4c98a7670b65d56e3f6e872242ee950c4599effd52226801a65
|
7
|
+
data.tar.gz: 0e2e77706e50afb391d0fcf5c40ea2c541033392b279edb7a4fdd42087736724084cac47c9f046a39d908920dfd117811075428c057484864b13c4efa8e6bc4c
|
data/README.md
CHANGED
@@ -9,28 +9,41 @@
|
|
9
9
|
> **Created by [Ahmet KAHRAMAN](https://ahmetxhero.web.app)** - Mobile Developer & Cyber Security Expert
|
10
10
|
> *"Security first, innovation always"* 🛡️
|
11
11
|
|
12
|
-
An AI-powered Ruby library that performs comprehensive
|
12
|
+
An enterprise-grade AI-powered Ruby library that performs comprehensive cross-platform mobile security analysis. Features advanced platform-specific detection, hardware security validation, CI/CD integration, and enterprise SIEM connectivity - all without requiring a backend.
|
13
13
|
|
14
14
|
## Features
|
15
15
|
|
16
|
+
### 🔒 Core Security Detection
|
16
17
|
- **Root & Jailbreak Detection**: Comprehensive detection of rooted Android devices and jailbroken iOS devices
|
17
18
|
- **Emulator/Simulator Detection**: Identifies virtual devices, emulators, and simulators
|
18
19
|
- **Hooking Framework Detection**: Detects Frida, Xposed, Substrate, and other instrumentation tools
|
19
20
|
- **Application Integrity Checks**: Validates app signatures and detects repackaging/tampering
|
20
21
|
- **Network Security Analysis**: Identifies TLS issues, custom CAs, and MITM tools
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
-
|
22
|
+
|
23
|
+
### 🆕 v0.5.0 Platform-Specific Security Modules
|
24
|
+
- **Android SafetyNet & Play Integrity API**: Native Google security API integration
|
25
|
+
- **iOS Advanced Jailbreak Detection**: DYLD injection, sandbox escape, code signing validation
|
26
|
+
- **Hardware Security Analysis**: TEE/SE validation, biometric consistency checks
|
27
|
+
- **Cross-Platform Unified Reporting**: Standardized security reports across platforms
|
28
|
+
|
29
|
+
### 🛠️ Developer Tools & CI/CD Integration
|
30
|
+
- **CI/CD Security Testing Module**: Automated security tests for GitHub Actions, GitLab CI, Jenkins
|
31
|
+
- **Web Dashboard**: Optional GUI for log analysis and risk visualization
|
32
|
+
- **Risk Score Visualization**: Interactive charts, timelines, and heatmaps
|
33
|
+
- **SIEM/SOC Integrations**: Splunk, Elastic Stack, QRadar, Sentinel, Sumo Logic, Datadog
|
34
|
+
|
35
|
+
### 🔐 Advanced Security Features
|
36
|
+
- **Certificate Pinning Helper**: TLS public key pinning with common CA support
|
37
|
+
- **Advanced Proxy Detection**: VPN, Tor, custom DNS, and MITM appliance detection
|
38
|
+
- **Enterprise Policy Management**: JSON-based customizable security rules and compliance
|
25
39
|
- **RASP Protection**: Runtime Application Self-Protection with real-time threat blocking
|
26
|
-
- **Anti-Debug Mechanisms**: Ptrace, GDB, LLDB detection and blocking
|
27
|
-
- **Anti-Tamper Protection**: Code integrity and memory patch detection
|
28
|
-
- **Dynamic Memory Protection**: Frida injection hook mitigation
|
29
|
-
- **Runtime Integrity Monitor**: Critical function hash validation
|
30
40
|
- **AI Behavioral Analysis**: ONNX-powered behavioral pattern analysis with anomaly detection
|
31
|
-
- **
|
32
|
-
|
41
|
+
- **Hardware Attestation**: Android Key Attestation and iOS Device Check integration
|
42
|
+
|
43
|
+
### 📊 Enterprise Features
|
44
|
+
- **Compliance Frameworks**: OWASP MASVS, NIST, ISO 27001, PCI DSS, GDPR support
|
33
45
|
- **Risk Scoring System**: Comprehensive risk assessment with weighted factors (0-100 scale)
|
46
|
+
- **Threat Intelligence**: IoC extraction and attack vector identification
|
34
47
|
- **CLI Tool**: Command-line interface with multiple output formats
|
35
48
|
- **Privacy-First**: Completely offline, no data collection or external dependencies
|
36
49
|
|
@@ -68,6 +81,50 @@ puts result[:risk_score] # => 87
|
|
68
81
|
puts result[:factors] # => ["ROOT_SU_FOUND", "FRIDA_GADGET", "TLS_UNPINNED"]
|
69
82
|
```
|
70
83
|
|
84
|
+
### v0.5.0 Platform-Specific Analysis
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
require "ai_root_shield"
|
88
|
+
|
89
|
+
# Load device logs
|
90
|
+
device_logs = JSON.parse(File.read("device_logs/android_device.json"))
|
91
|
+
|
92
|
+
# Android-specific security analysis
|
93
|
+
android_results = AiRootShield.analyze_android_security(device_logs, {
|
94
|
+
api_key: "your_safetynet_api_key",
|
95
|
+
package_name: "com.yourapp.package"
|
96
|
+
})
|
97
|
+
|
98
|
+
puts "SafetyNet Basic Integrity: #{android_results[:safetynet][:basic_integrity]}"
|
99
|
+
puts "Play Integrity Verdict: #{android_results[:play_integrity][:device_verdict]}"
|
100
|
+
puts "Hardware TEE Available: #{android_results[:hardware_security][:tee_available]}"
|
101
|
+
|
102
|
+
# iOS-specific security analysis
|
103
|
+
ios_logs = JSON.parse(File.read("device_logs/ios_device.json"))
|
104
|
+
ios_results = AiRootShield.analyze_ios_security(ios_logs)
|
105
|
+
|
106
|
+
puts "Jailbreak Detected: #{ios_results[:jailbreak_detection][:file_system_check][:detected]}"
|
107
|
+
puts "Code Signing Valid: #{ios_results[:code_signing][:main_bundle_signed]}"
|
108
|
+
puts "Secure Enclave Available: #{ios_results[:hardware_security][:secure_enclave_available]}"
|
109
|
+
|
110
|
+
# Hardware security analysis
|
111
|
+
hardware_analysis = AiRootShield.analyze_hardware_security(device_logs, 'android')
|
112
|
+
puts "Hardware Security Score: #{hardware_analysis[:security_score]}"
|
113
|
+
|
114
|
+
# Generate unified cross-platform report
|
115
|
+
unified_report = AiRootShield.generate_unified_report(
|
116
|
+
android_results: android_results,
|
117
|
+
ios_results: ios_results,
|
118
|
+
metadata: {
|
119
|
+
app_name: "MySecureApp",
|
120
|
+
app_version: "1.0.0",
|
121
|
+
organization: "MyCompany"
|
122
|
+
}
|
123
|
+
)
|
124
|
+
|
125
|
+
puts "Overall Risk Level: #{unified_report[:unified_risk_assessment][:risk_level]}"
|
126
|
+
```
|
127
|
+
|
71
128
|
### Advanced Configuration
|
72
129
|
|
73
130
|
```ruby
|
@@ -94,6 +151,76 @@ actions = AiRootShield::RiskCalculator.recommended_actions(result[:factors])
|
|
94
151
|
actions.each { |action| puts "→ #{action}" }
|
95
152
|
```
|
96
153
|
|
154
|
+
### CI/CD Integration (New in v0.5.0)
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
# Run security tests in CI/CD pipeline
|
158
|
+
test_results = AiRootShield.run_ci_cd_tests("device_logs/sample.json", {
|
159
|
+
fail_on_high_risk: true,
|
160
|
+
risk_threshold: 70,
|
161
|
+
report_format: 'json',
|
162
|
+
artifacts_path: './security_artifacts'
|
163
|
+
})
|
164
|
+
|
165
|
+
puts "Pipeline Result: #{test_results[:pipeline_result][:result]}"
|
166
|
+
|
167
|
+
# Generate CI/CD configuration
|
168
|
+
github_config = AiRootShield.generate_ci_config('github_actions')
|
169
|
+
File.write('.github/workflows/security.yml', github_config)
|
170
|
+
|
171
|
+
gitlab_config = AiRootShield.generate_ci_config('gitlab_ci')
|
172
|
+
File.write('.gitlab-ci.yml', gitlab_config)
|
173
|
+
```
|
174
|
+
|
175
|
+
### SIEM Integration (New in v0.5.0)
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
# Configure SIEM connector
|
179
|
+
AiRootShield.configure_siem(:splunk, {
|
180
|
+
api_endpoint: 'https://your-splunk-instance.com:8088',
|
181
|
+
api_key: 'your-hec-token',
|
182
|
+
index: 'mobile_security'
|
183
|
+
})
|
184
|
+
|
185
|
+
# Send security events to SIEM
|
186
|
+
analysis_results = AiRootShield.analyze_android_security(device_logs)
|
187
|
+
AiRootShield.send_to_siem(analysis_results, {
|
188
|
+
device_id: 'device-123',
|
189
|
+
user_id: 'user-456',
|
190
|
+
app_version: '1.0.0'
|
191
|
+
})
|
192
|
+
|
193
|
+
# Configure multiple SIEM platforms
|
194
|
+
elastic_connector = AiRootShield.configure_siem(:elastic, {
|
195
|
+
api_endpoint: 'https://your-elastic-cluster.com',
|
196
|
+
api_key: 'your-api-key',
|
197
|
+
index: 'ai-root-shield-events'
|
198
|
+
})
|
199
|
+
|
200
|
+
datadog_connector = AiRootShield.configure_siem(:datadog, {
|
201
|
+
api_endpoint: 'https://api.datadoghq.com',
|
202
|
+
api_key: 'your-datadog-api-key'
|
203
|
+
})
|
204
|
+
```
|
205
|
+
|
206
|
+
### Web Dashboard (New in v0.5.0)
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
# Start the web dashboard
|
210
|
+
AiRootShield.start_dashboard({
|
211
|
+
port: 4567,
|
212
|
+
bind: '0.0.0.0'
|
213
|
+
})
|
214
|
+
|
215
|
+
# Dashboard will be available at http://localhost:4567
|
216
|
+
# Features:
|
217
|
+
# - Real-time security analysis
|
218
|
+
# - Risk score visualization
|
219
|
+
# - Interactive charts and heatmaps
|
220
|
+
# - Historical trend analysis
|
221
|
+
# - Compliance reporting
|
222
|
+
```
|
223
|
+
|
97
224
|
### CLI Usage
|
98
225
|
|
99
226
|
The gem includes a command-line interface:
|
@@ -102,6 +229,23 @@ The gem includes a command-line interface:
|
|
102
229
|
# Basic scan
|
103
230
|
$ ai_root_shield device_logs/sample.json
|
104
231
|
|
232
|
+
# Platform-specific analysis
|
233
|
+
$ ai_root_shield --platform android --safetynet-api-key YOUR_KEY device_logs/android.json
|
234
|
+
$ ai_root_shield --platform ios --enable-jailbreak-detection device_logs/ios.json
|
235
|
+
|
236
|
+
# CI/CD mode with artifacts
|
237
|
+
$ ai_root_shield --ci-mode --format json --artifacts-path ./reports device_logs/sample.json
|
238
|
+
|
239
|
+
# SIEM integration
|
240
|
+
$ ai_root_shield --siem splunk --siem-endpoint https://splunk.com:8088 --siem-token TOKEN device_logs/sample.json
|
241
|
+
|
242
|
+
# Web dashboard
|
243
|
+
$ ai_root_shield --start-dashboard --port 8080
|
244
|
+
|
245
|
+
# Generate CI/CD configs
|
246
|
+
$ ai_root_shield --generate-ci-config github-actions > .github/workflows/security.yml
|
247
|
+
$ ai_root_shield --generate-ci-config gitlab-ci > .gitlab-ci.yml
|
248
|
+
|
105
249
|
# With options
|
106
250
|
$ ai_root_shield --format text --threshold 60 device_logs/sample.json
|
107
251
|
|
@@ -365,9 +509,11 @@ See the `examples/device_logs/` directory for complete examples.
|
|
365
509
|
|
366
510
|
- **v0.1** ✅ Static root/jailbreak checks
|
367
511
|
- **v0.2** ✅ Emulator/simulator detection + TLS pinning helper
|
368
|
-
- **v0.3**
|
369
|
-
- **v0.4**
|
370
|
-
- **
|
512
|
+
- **v0.3** ✅ AI behavioral model (ONNX inference) + RASP protection
|
513
|
+
- **v0.4** ✅ Advanced network security + enterprise policy management
|
514
|
+
- **v0.5** ✅ Platform-specific modules + CI/CD integration + SIEM connectivity
|
515
|
+
- **v0.6** 🔄 Real-time threat feeds + ML model updates
|
516
|
+
- **v1.0** 🎯 Enterprise security orchestration platform
|
371
517
|
|
372
518
|
## 🤝 Contributing
|
373
519
|
|
data/exe/ai_root_shield
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require "optparse"
|
5
5
|
require "json"
|
6
|
+
require "fileutils"
|
6
7
|
require_relative "../lib/ai_root_shield"
|
7
8
|
|
8
9
|
# Command line interface for AI Root Shield
|
@@ -24,13 +25,37 @@ class AiRootShieldCLI
|
|
24
25
|
enable_certificate_pinning: false,
|
25
26
|
enable_proxy_detection: false,
|
26
27
|
target_ip: nil,
|
27
|
-
target_url: nil
|
28
|
+
target_url: nil,
|
29
|
+
# v0.5.0 new options
|
30
|
+
platform: nil,
|
31
|
+
safetynet_api_key: nil,
|
32
|
+
package_name: nil,
|
33
|
+
ci_mode: false,
|
34
|
+
artifacts_path: './security_test_artifacts',
|
35
|
+
siem_platform: nil,
|
36
|
+
siem_endpoint: nil,
|
37
|
+
siem_token: nil,
|
38
|
+
start_dashboard: false,
|
39
|
+
dashboard_port: 4567,
|
40
|
+
generate_ci_config: nil,
|
41
|
+
enable_unified_reporting: false
|
28
42
|
}
|
29
43
|
end
|
30
44
|
|
31
45
|
def run(args)
|
32
46
|
parse_options(args)
|
33
47
|
|
48
|
+
# Handle special commands first
|
49
|
+
if @options[:start_dashboard]
|
50
|
+
start_dashboard
|
51
|
+
return
|
52
|
+
end
|
53
|
+
|
54
|
+
if @options[:generate_ci_config]
|
55
|
+
generate_ci_config
|
56
|
+
return
|
57
|
+
end
|
58
|
+
|
34
59
|
if args.empty?
|
35
60
|
puts "Error: Please provide a device logs file path"
|
36
61
|
puts "Usage: ai_root_shield [options] <device_logs.json>"
|
@@ -45,6 +70,15 @@ class AiRootShieldCLI
|
|
45
70
|
end
|
46
71
|
|
47
72
|
begin
|
73
|
+
# Configure SIEM if provided
|
74
|
+
if @options[:siem_platform] && @options[:siem_endpoint] && @options[:siem_token]
|
75
|
+
puts "Configuring SIEM integration (#{@options[:siem_platform]})..." if @options[:verbose]
|
76
|
+
AiRootShield.configure_siem(@options[:siem_platform].to_sym, {
|
77
|
+
api_endpoint: @options[:siem_endpoint],
|
78
|
+
api_key: @options[:siem_token]
|
79
|
+
})
|
80
|
+
end
|
81
|
+
|
48
82
|
# Configure enterprise policy if provided
|
49
83
|
if @options[:policy_file]
|
50
84
|
puts "Loading enterprise policy from #{@options[:policy_file]}..." if @options[:verbose]
|
@@ -83,7 +117,23 @@ class AiRootShieldCLI
|
|
83
117
|
sleep(@options[:rasp_monitoring_time])
|
84
118
|
end
|
85
119
|
|
86
|
-
|
120
|
+
# Run analysis based on mode
|
121
|
+
if @options[:ci_mode]
|
122
|
+
result = run_ci_cd_analysis(device_logs_path)
|
123
|
+
elsif @options[:platform]
|
124
|
+
result = run_platform_specific_analysis(device_logs_path)
|
125
|
+
else
|
126
|
+
result = AiRootShield.scan_device_with_config(device_logs_path, @options)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Send to SIEM if configured
|
130
|
+
if @options[:siem_platform]
|
131
|
+
puts "Sending results to SIEM..." if @options[:verbose]
|
132
|
+
AiRootShield.send_to_siem(result, {
|
133
|
+
cli_version: AiRootShield::VERSION,
|
134
|
+
scan_timestamp: Time.now.utc.iso8601
|
135
|
+
})
|
136
|
+
end
|
87
137
|
|
88
138
|
# Add RASP status to result if enabled
|
89
139
|
if @options[:enable_rasp_protection] && AiRootShield.rasp_active?
|
@@ -184,6 +234,70 @@ class AiRootShieldCLI
|
|
184
234
|
@options[:target_url] = url
|
185
235
|
end
|
186
236
|
|
237
|
+
# v0.5.0 Platform-specific options
|
238
|
+
opts.separator ""
|
239
|
+
opts.separator "Platform-specific Analysis (v0.5.0):"
|
240
|
+
|
241
|
+
opts.on("--platform PLATFORM", ["android", "ios"], "Platform-specific analysis (android, ios)") do |platform|
|
242
|
+
@options[:platform] = platform
|
243
|
+
end
|
244
|
+
|
245
|
+
opts.on("--safetynet-key KEY", "Google SafetyNet API key for Android analysis") do |key|
|
246
|
+
@options[:safetynet_api_key] = key
|
247
|
+
end
|
248
|
+
|
249
|
+
opts.on("--package-name NAME", "Android package name for analysis") do |name|
|
250
|
+
@options[:package_name] = name
|
251
|
+
end
|
252
|
+
|
253
|
+
opts.on("--unified-report", "Generate unified cross-platform report") do
|
254
|
+
@options[:enable_unified_reporting] = true
|
255
|
+
end
|
256
|
+
|
257
|
+
# CI/CD Integration options
|
258
|
+
opts.separator ""
|
259
|
+
opts.separator "CI/CD Integration (v0.5.0):"
|
260
|
+
|
261
|
+
opts.on("--ci-mode", "Run in CI/CD mode with test artifacts") do
|
262
|
+
@options[:ci_mode] = true
|
263
|
+
end
|
264
|
+
|
265
|
+
opts.on("--artifacts-path PATH", "Path for CI/CD test artifacts (default: ./security_test_artifacts)") do |path|
|
266
|
+
@options[:artifacts_path] = path
|
267
|
+
end
|
268
|
+
|
269
|
+
opts.on("--generate-ci-config PLATFORM", ["github", "gitlab", "jenkins", "azure"], "Generate CI config for platform") do |platform|
|
270
|
+
@options[:generate_ci_config] = platform
|
271
|
+
end
|
272
|
+
|
273
|
+
# SIEM Integration options
|
274
|
+
opts.separator ""
|
275
|
+
opts.separator "SIEM Integration (v0.5.0):"
|
276
|
+
|
277
|
+
opts.on("--siem-platform PLATFORM", ["splunk", "elastic", "qradar", "sentinel", "datadog", "chronicle", "arcsight"], "SIEM platform") do |platform|
|
278
|
+
@options[:siem_platform] = platform
|
279
|
+
end
|
280
|
+
|
281
|
+
opts.on("--siem-endpoint URL", "SIEM API endpoint URL") do |url|
|
282
|
+
@options[:siem_endpoint] = url
|
283
|
+
end
|
284
|
+
|
285
|
+
opts.on("--siem-token TOKEN", "SIEM API authentication token") do |token|
|
286
|
+
@options[:siem_token] = token
|
287
|
+
end
|
288
|
+
|
289
|
+
# Dashboard options
|
290
|
+
opts.separator ""
|
291
|
+
opts.separator "Dashboard (v0.5.0):"
|
292
|
+
|
293
|
+
opts.on("--start-dashboard", "Start web dashboard server") do
|
294
|
+
@options[:start_dashboard] = true
|
295
|
+
end
|
296
|
+
|
297
|
+
opts.on("--dashboard-port PORT", Integer, "Dashboard port (default: 4567)") do |port|
|
298
|
+
@options[:dashboard_port] = port
|
299
|
+
end
|
300
|
+
|
187
301
|
opts.on("-h", "--help", "Show this help message") do
|
188
302
|
puts opts
|
189
303
|
exit
|
@@ -280,14 +394,113 @@ class AiRootShieldCLI
|
|
280
394
|
end
|
281
395
|
|
282
396
|
def output_summary_format(result)
|
283
|
-
|
397
|
+
# Handle unified report format
|
398
|
+
if result[:executive_summary]
|
399
|
+
risk_level = result[:executive_summary][:overall_risk_level]
|
400
|
+
security_score = result[:executive_summary][:security_posture_score]
|
401
|
+
threat_count = result[:executive_summary][:critical_findings]&.length || 0
|
402
|
+
|
403
|
+
puts "Risk Level: #{risk_level} (Security Score: #{security_score}/100)"
|
404
|
+
puts "Threats: #{threat_count} critical findings detected"
|
405
|
+
|
406
|
+
if result[:executive_summary][:key_recommendations]&.any?
|
407
|
+
puts "Primary Concerns: #{result[:executive_summary][:key_recommendations].first(3).join(', ')}"
|
408
|
+
end
|
409
|
+
else
|
410
|
+
# Handle regular analysis format
|
411
|
+
risk_level = AiRootShield::RiskCalculator.risk_level_description(result[:risk_score])
|
412
|
+
|
413
|
+
puts "Risk Level: #{risk_level} (#{result[:risk_score]}/100)"
|
414
|
+
puts "Threats: #{result[:factors]&.length || 0} detected"
|
415
|
+
|
416
|
+
if result[:factors]&.any?
|
417
|
+
puts "Primary Concerns: #{result[:factors].first(3).join(', ')}"
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
# v0.5.0 New Methods
|
423
|
+
def run_platform_specific_analysis(device_logs_path)
|
424
|
+
puts "Running #{@options[:platform]} platform-specific analysis..." if @options[:verbose]
|
284
425
|
|
285
|
-
|
286
|
-
|
426
|
+
case @options[:platform]
|
427
|
+
when 'android'
|
428
|
+
config = {}
|
429
|
+
config[:safetynet_api_key] = @options[:safetynet_api_key] if @options[:safetynet_api_key]
|
430
|
+
config[:package_name] = @options[:package_name] if @options[:package_name]
|
431
|
+
|
432
|
+
result = AiRootShield.analyze_android_device(device_logs_path, config)
|
433
|
+
when 'ios'
|
434
|
+
result = AiRootShield.analyze_ios_device(device_logs_path)
|
435
|
+
else
|
436
|
+
raise "Unsupported platform: #{@options[:platform]}"
|
437
|
+
end
|
287
438
|
|
288
|
-
if
|
289
|
-
puts "
|
439
|
+
if @options[:enable_unified_reporting]
|
440
|
+
puts "Generating unified cross-platform report..." if @options[:verbose]
|
441
|
+
case @options[:platform]
|
442
|
+
when 'android'
|
443
|
+
unified_result = AiRootShield.generate_unified_report(android_results: result)
|
444
|
+
when 'ios'
|
445
|
+
unified_result = AiRootShield.generate_unified_report(ios_results: result)
|
446
|
+
end
|
447
|
+
return unified_result
|
290
448
|
end
|
449
|
+
|
450
|
+
result
|
451
|
+
end
|
452
|
+
|
453
|
+
def run_ci_cd_analysis(device_logs_path)
|
454
|
+
puts "Running CI/CD security analysis..." if @options[:verbose]
|
455
|
+
|
456
|
+
# Create artifacts directory
|
457
|
+
Dir.mkdir(@options[:artifacts_path]) unless Dir.exist?(@options[:artifacts_path])
|
458
|
+
|
459
|
+
# Run CI/CD tests
|
460
|
+
result = AiRootShield.run_ci_cd_tests(device_logs_path, {
|
461
|
+
artifacts_path: @options[:artifacts_path],
|
462
|
+
verbose: @options[:verbose]
|
463
|
+
})
|
464
|
+
|
465
|
+
puts "CI/CD test artifacts saved to: #{@options[:artifacts_path]}" if @options[:verbose]
|
466
|
+
result
|
467
|
+
end
|
468
|
+
|
469
|
+
def start_dashboard
|
470
|
+
puts "Starting AI Root Shield Dashboard on port #{@options[:dashboard_port]}..."
|
471
|
+
puts "Dashboard will be available at: http://localhost:#{@options[:dashboard_port]}"
|
472
|
+
puts "Press Ctrl+C to stop the dashboard"
|
473
|
+
|
474
|
+
begin
|
475
|
+
AiRootShield.start_dashboard(@options[:dashboard_port])
|
476
|
+
rescue Interrupt
|
477
|
+
puts "\nDashboard stopped."
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def generate_ci_config
|
482
|
+
puts "Generating CI/CD configuration for #{@options[:generate_ci_config]}..."
|
483
|
+
|
484
|
+
config_content = AiRootShield.generate_ci_config(@options[:generate_ci_config].to_sym)
|
485
|
+
|
486
|
+
filename = case @options[:generate_ci_config]
|
487
|
+
when 'github'
|
488
|
+
'.github/workflows/security-scan.yml'
|
489
|
+
when 'gitlab'
|
490
|
+
'.gitlab-ci.yml'
|
491
|
+
when 'jenkins'
|
492
|
+
'Jenkinsfile'
|
493
|
+
when 'azure'
|
494
|
+
'azure-pipelines.yml'
|
495
|
+
end
|
496
|
+
|
497
|
+
# Create directory if needed
|
498
|
+
dir = File.dirname(filename)
|
499
|
+
FileUtils.mkdir_p(dir) unless Dir.exist?(dir) || dir == '.'
|
500
|
+
|
501
|
+
File.write(filename, config_content)
|
502
|
+
puts "CI/CD configuration saved to: #{filename}"
|
503
|
+
puts "Please review and customize the configuration as needed."
|
291
504
|
end
|
292
505
|
end
|
293
506
|
|
data/lib/ai_root_shield.rb
CHANGED
@@ -15,6 +15,21 @@ require_relative "ai_root_shield/certificate_pinning_helper"
|
|
15
15
|
require_relative "ai_root_shield/advanced_proxy_detector"
|
16
16
|
require_relative "ai_root_shield/enterprise_policy_manager"
|
17
17
|
|
18
|
+
# v0.5.0 Platform-specific security modules
|
19
|
+
require_relative "ai_root_shield/platform/android_security_module"
|
20
|
+
require_relative "ai_root_shield/platform/ios_security_module"
|
21
|
+
require_relative "ai_root_shield/platform/hardware_security_analyzer"
|
22
|
+
require_relative "ai_root_shield/platform/unified_report_generator"
|
23
|
+
|
24
|
+
# v0.5.0 CI/CD and developer tools
|
25
|
+
require_relative "ai_root_shield/ci_cd/security_test_module"
|
26
|
+
|
27
|
+
# v0.5.0 Dashboard and visualization
|
28
|
+
require_relative "ai_root_shield/dashboard/web_dashboard"
|
29
|
+
|
30
|
+
# v0.5.0 Third-party integrations
|
31
|
+
require_relative "ai_root_shield/integrations/siem_connector"
|
32
|
+
|
18
33
|
module AiRootShield
|
19
34
|
class Error < StandardError; end
|
20
35
|
|
@@ -23,6 +38,12 @@ module AiRootShield
|
|
23
38
|
@policy_manager = nil
|
24
39
|
@certificate_pinning = nil
|
25
40
|
@proxy_detector = nil
|
41
|
+
@android_module = nil
|
42
|
+
@ios_module = nil
|
43
|
+
@hardware_analyzer = nil
|
44
|
+
@report_generator = nil
|
45
|
+
@ci_cd_module = nil
|
46
|
+
@siem_connector = nil
|
26
47
|
|
27
48
|
# Main entry point for device scanning
|
28
49
|
# @param device_logs_path [String] Path to device logs JSON file
|
@@ -133,6 +154,128 @@ module AiRootShield
|
|
133
154
|
@proxy_detector
|
134
155
|
end
|
135
156
|
|
157
|
+
# v0.5.0 Platform-specific security analysis
|
158
|
+
# Analyze Android device security using SafetyNet and Play Integrity APIs
|
159
|
+
# @param device_logs [Hash] Device logs data
|
160
|
+
# @param config [Hash] Configuration options
|
161
|
+
# @return [Hash] Android security analysis results
|
162
|
+
def self.analyze_android_security(device_logs, config = {})
|
163
|
+
@android_module ||= Platform::AndroidSecurityModule.new(config)
|
164
|
+
@android_module.analyze_device_security(device_logs)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Analyze iOS device security with advanced jailbreak detection
|
168
|
+
# @param device_logs [Hash] Device logs data
|
169
|
+
# @return [Hash] iOS security analysis results
|
170
|
+
def self.analyze_ios_security(device_logs)
|
171
|
+
@ios_module ||= Platform::IosSecurityModule.new
|
172
|
+
@ios_module.analyze_device_security(device_logs)
|
173
|
+
end
|
174
|
+
|
175
|
+
# Analyze hardware security features (TEE/SE, biometrics)
|
176
|
+
# @param device_logs [Hash] Device logs data
|
177
|
+
# @param platform [String] Platform type ('android' or 'ios')
|
178
|
+
# @return [Hash] Hardware security analysis results
|
179
|
+
def self.analyze_hardware_security(device_logs, platform)
|
180
|
+
@hardware_analyzer ||= Platform::HardwareSecurityAnalyzer.new
|
181
|
+
@hardware_analyzer.analyze_hardware_security(device_logs, platform)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Generate unified cross-platform security report
|
185
|
+
# @param android_results [Hash] Android analysis results
|
186
|
+
# @param ios_results [Hash] iOS analysis results
|
187
|
+
# @param metadata [Hash] Report metadata
|
188
|
+
# @return [Hash] Unified security report
|
189
|
+
def self.generate_unified_report(android_results: nil, ios_results: nil, metadata: {})
|
190
|
+
@report_generator ||= Platform::UnifiedReportGenerator.new
|
191
|
+
@report_generator.generate_unified_report(
|
192
|
+
android_results: android_results,
|
193
|
+
ios_results: ios_results,
|
194
|
+
metadata: metadata
|
195
|
+
)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Run CI/CD security tests
|
199
|
+
# @param device_logs_path [String] Path to device logs file
|
200
|
+
# @param options [Hash] Test configuration options
|
201
|
+
# @return [Hash] CI/CD test results
|
202
|
+
def self.run_ci_cd_tests(device_logs_path, options = {})
|
203
|
+
@ci_cd_module ||= CiCd::SecurityTestModule.new(options)
|
204
|
+
@ci_cd_module.run_security_tests(device_logs_path, options)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Generate CI/CD configuration for specified platform
|
208
|
+
# @param platform [String] CI/CD platform name
|
209
|
+
# @param options [Hash] Configuration options
|
210
|
+
# @return [String] CI/CD configuration content
|
211
|
+
def self.generate_ci_config(platform, options = {})
|
212
|
+
@ci_cd_module ||= CiCd::SecurityTestModule.new
|
213
|
+
@ci_cd_module.generate_ci_config(platform, options)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Configure SIEM integration
|
217
|
+
# @param platform [Symbol] SIEM platform (:splunk, :elastic, etc.)
|
218
|
+
# @param config [Hash] SIEM configuration
|
219
|
+
# @return [Integrations::SiemConnector] SIEM connector instance
|
220
|
+
def self.configure_siem(platform, config = {})
|
221
|
+
@siem_connector = Integrations::SiemConnector.new(platform, config)
|
222
|
+
end
|
223
|
+
|
224
|
+
# Send security events to SIEM
|
225
|
+
# @param analysis_results [Hash] Security analysis results
|
226
|
+
# @param metadata [Hash] Event metadata
|
227
|
+
# @return [Hash] SIEM response
|
228
|
+
def self.send_to_siem(analysis_results, metadata = {})
|
229
|
+
return { error: "SIEM not configured" } unless @siem_connector
|
230
|
+
|
231
|
+
@siem_connector.send_security_event(analysis_results, metadata)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Start web dashboard
|
235
|
+
# @param port [Integer] Port number
|
236
|
+
def self.start_dashboard(port = 4567)
|
237
|
+
dashboard = AiRootShield::Dashboard::WebDashboard.new
|
238
|
+
dashboard.start(port)
|
239
|
+
end
|
240
|
+
|
241
|
+
# Platform-specific analysis methods for CLI
|
242
|
+
def self.analyze_android_device(device_logs_path, config = {})
|
243
|
+
device_logs = JSON.parse(File.read(device_logs_path))
|
244
|
+
android_module = AiRootShield::Platform::AndroidSecurityModule.new(
|
245
|
+
api_key: config[:safetynet_api_key],
|
246
|
+
package_name: config[:package_name]
|
247
|
+
)
|
248
|
+
android_module.analyze_device_security(device_logs)
|
249
|
+
end
|
250
|
+
|
251
|
+
def self.analyze_ios_device(device_logs_path, config = {})
|
252
|
+
device_logs = JSON.parse(File.read(device_logs_path))
|
253
|
+
ios_module = AiRootShield::Platform::IosSecurityModule.new
|
254
|
+
ios_module.analyze_device_security(device_logs)
|
255
|
+
end
|
256
|
+
|
257
|
+
# CI/CD integration method for CLI
|
258
|
+
def self.run_ci_cd_tests(device_logs_path, config = {})
|
259
|
+
ci_module = AiRootShield::CiCd::SecurityTestModule.new
|
260
|
+
ci_module.run_security_tests(device_logs_path, config)
|
261
|
+
end
|
262
|
+
|
263
|
+
# Generate CI configuration for CLI
|
264
|
+
def self.generate_ci_config(platform)
|
265
|
+
ci_module = AiRootShield::CiCd::SecurityTestModule.new
|
266
|
+
ci_module.generate_ci_config(platform)
|
267
|
+
end
|
268
|
+
|
269
|
+
# Generate unified cross-platform report for CLI
|
270
|
+
def self.generate_unified_report(android_results: nil, ios_results: nil, metadata: {})
|
271
|
+
report_generator = AiRootShield::Platform::UnifiedReportGenerator.new
|
272
|
+
report_generator.generate_unified_report(
|
273
|
+
android_results: android_results,
|
274
|
+
ios_results: ios_results,
|
275
|
+
metadata: metadata
|
276
|
+
)
|
277
|
+
end
|
278
|
+
|
136
279
|
# Check if RASP protection is active
|
137
280
|
# @return [Boolean] True if RASP protection is active
|
138
281
|
def self.rasp_active?
|
@@ -148,11 +291,19 @@ module AiRootShield
|
|
148
291
|
policy_configured: !@policy_manager.nil?,
|
149
292
|
certificate_pinning_configured: !@certificate_pinning.nil?,
|
150
293
|
proxy_detection_configured: !@proxy_detector.nil?,
|
294
|
+
siem_configured: !@siem_connector.nil?,
|
295
|
+
platform_modules: {
|
296
|
+
android_module: !@android_module.nil?,
|
297
|
+
ios_module: !@ios_module.nil?,
|
298
|
+
hardware_analyzer: !@hardware_analyzer.nil?,
|
299
|
+
report_generator: !@report_generator.nil?
|
300
|
+
},
|
151
301
|
components: {
|
152
302
|
rasp: @rasp_protection&.protection_status,
|
153
303
|
policy: @policy_manager&.policy_statistics,
|
154
304
|
certificate_pinning: @certificate_pinning&.pinning_status,
|
155
|
-
proxy_detection: @proxy_detector&.detection_statistics
|
305
|
+
proxy_detection: @proxy_detector&.detection_statistics,
|
306
|
+
siem: @siem_connector ? { platform: @siem_connector.instance_variable_get(:@platform) } : nil
|
156
307
|
}
|
157
308
|
}
|
158
309
|
end
|