Security Scanning
Understanding Scan Results
Section titled “Understanding Scan Results”!!! info Byteria SDK performs continuous security scanning of your application and its runtime environment. The scan results provide insights into the security posture of your app. Scan Trigger Methods:
// Get latest scan resultString scanResult = AlphynSDK.getScanResult();
// Scan results are also delivered via callbackspublic void onSuccess(AlphynCallbackResult result) { if (result.isScanResponse()) { AlphynScanResult scanResult = result.getScanResult(); processScanResult(scanResult); }}Scan Result Types
Section titled “Scan Result Types”| Result | Description | Recommended Action |
|---|---|---|
TRUSTED | App passed all security checks | Continue normal operation |
FLAGGED | Potential security concerns detected | Monitor and investigate |
UNTRUSTED | App failed critical security checks | Restrict functionality or terminate |
UNKNOWN | Scan result unclear or invalid | Retry scan or investigate |
INITIALIZATION_ERROR | SDK failed to initialize properly | Fix initialization issues |
Scan Result Handling:
private void processScanResult(AlphynScanResult scanResult) { Log.i("Byteria", String.format("Scan Result: %s %s", scanResult.getEmoji(), scanResult.getDisplayName()));
// Branch on the exact result so the response matches severity. switch (scanResult) { case UNTRUSTED: // Failed critical security checks - the most severe state Log.e("Byteria", "Untrusted - restricting or terminating"); terminateAppForSecurity(); break; case FLAGGED: // Potential concerns - continue with enhanced monitoring Log.w("Byteria", "Flagged - enabling enhanced security monitoring"); enableEnhancedMonitoring(); break; case TRUSTED: Log.i("Byteria", "Application verified as secure"); proceedWithNormalOperation(); break; default: break; }}Note:
isThreat()returns true forUNTRUSTEDorFLAGGED;isCriticalThreat()returns true forFLAGGEDonly. Prefer switching on the exactAlphynScanResultvalue when the response depends on severity.
Handling Scan Responses
Section titled “Handling Scan Responses”Comprehensive Scan Response Handler:
public class SecurityManager { private boolean enhancedMonitoringEnabled = false;
public void handleScanResponse(AlphynScanResult result) { switch (result) { case TRUSTED: onTrustedResult(); break;
case FLAGGED: onFlaggedResult(); break;
case UNTRUSTED: onUntrustedResult(); break;
case INITIALIZATION_ERROR: onInitializationError(); break;
case UNKNOWN: default: onUnknownResult(); break; } }
private void onTrustedResult() { Log.i("Security", "✅ Application is trusted"); disableEnhancedMonitoring(); // Allow full functionality }
private void onFlaggedResult() { Log.w("Security", "⚠️ Application flagged - enabling monitoring"); enableEnhancedMonitoring(); // Continue with caution, possibly restrict sensitive features }
private void onUntrustedResult() { Log.e("Security", "🚨 Application untrusted - terminating"); // Critical security failure - terminate app System.exit(0); }
private void enableEnhancedMonitoring() { if (!enhancedMonitoringEnabled) { enhancedMonitoringEnabled = true; Log.i("Security", "Enhanced security monitoring enabled"); // Implement additional security measures } }}Threat Detection
Section titled “Threat Detection”Real-time Threat Monitoring:
@Overridepublic void onThreatDetected(AlphynCallbackResult result) { ThreatInfo threat = analyzeThreat(result);
Log.w("Security", String.format("Threat detected: %s (Severity: %s)", threat.type, threat.severity));
// Log threat details for analysis logThreatEvent(threat);
// Take appropriate action based on threat severity switch (threat.severity) { case HIGH: handleHighSeverityThreat(threat); break; case MEDIUM: handleMediumSeverityThreat(threat); break; case LOW: handleLowSeverityThreat(threat); break; }}
private static class ThreatInfo { String type; String severity; String description; long timestamp;}