evaluate static method

Future<List<RiskFlag>> evaluate()

Implementation

static Future<List<RiskFlag>> evaluate() async {
  final results = await Future.wait<bool>([
    DeviceSafetyInfo.isRootedDevice,
    DeviceSafetyInfo.isHooked,
    DeviceSafetyInfo.isDebuggerAttached,
    DeviceSafetyInfo.isScreenCaptured,
    DeviceSafetyInfo.isVPNCheck,
    DeviceSafetyInfo.isScreenLock.then((locked) => !locked),
  ]);

  final flags = <RiskFlag>[];
  if (results[0]) {
    flags.add(const RiskFlag(
      id: 'rooted',
      title: 'Device is rooted or jailbroken',
      description: 'Rooted devices can bypass normal app sandboxing protections.',
    ));
  }
  if (results[1]) {
    flags.add(const RiskFlag(
      id: 'hooked',
      title: 'Hooking framework detected',
      description:
          'Tools like Frida or Xposed can intercept or modify app behavior at runtime.',
    ));
  }
  if (results[2]) {
    flags.add(const RiskFlag(
      id: 'debugger',
      title: 'Debugger attached',
      description: 'A debugger can inspect or modify the app while it runs.',
    ));
  }
  if (results[3]) {
    flags.add(const RiskFlag(
      id: 'screen_captured',
      title: 'Screen is being recorded or mirrored',
      description: 'Sensitive on-screen content may be visible to another device or app.',
    ));
  }
  if (results[4]) {
    flags.add(const RiskFlag(
      id: 'vpn',
      title: 'VPN is active',
      description:
          'Network traffic is being routed through a third party. This can be legitimate, but can also be used to mask origin.',
    ));
  }
  if (results[5]) {
    flags.add(const RiskFlag(
      id: 'no_screen_lock',
      title: 'No screen lock configured',
      description:
          'Without a PIN, pattern, or biometric lock, anyone with physical access to the device can use it.',
    ));
  }
  return flags;
}