security checks implementation

ipd-changes-for-vida-plus
mobileteam 1 day ago
parent af8df09bf7
commit 3277a78f6a

@ -44,6 +44,8 @@ abstract class SecurityService {
void setOnCriticalThreatCallback(OnCriticalThreatDetected callback); void setOnCriticalThreatCallback(OnCriticalThreatDetected callback);
} }
SecurityService service = SecurityServiceImpl();
/// Implementation of SecurityService using Talsec (freeRASP) /// Implementation of SecurityService using Talsec (freeRASP)
class SecurityServiceImpl implements SecurityService { class SecurityServiceImpl implements SecurityService {
Logger logger = Logger( Logger logger = Logger(

@ -156,5 +156,5 @@ void setupLocator() {
locator.registerFactory(() => InterventionMedicationViewModel()); locator.registerFactory(() => InterventionMedicationViewModel());
locator.registerFactory(() => ERSignInViewModel()); locator.registerFactory(() => ERSignInViewModel());
locator.registerFactory(() => PharmacyInterventionViewModel()); locator.registerFactory(() => PharmacyInterventionViewModel());
locator.registerFactory<SecurityService>(() => SecurityServiceImpl()); locator.registerFactory(() => SecurityServiceImpl());
} }

@ -32,11 +32,11 @@ void main() async {
await clearPrefsOnFirstLaunch(); await clearPrefsOnFirstLaunch();
tz.initializeTimeZones(); tz.initializeTimeZones();
if (!kReleaseMode) { if (kReleaseMode) {
await locator.get<SecurityService>().initialize(); await service.initialize();
// Set up critical threat callback to navigate to unsafe device page // Set up critical threat callback to navigate to unsafe device page
locator.get<SecurityService>().setOnCriticalThreatCallback(() { service.setOnCriticalThreatCallback(() {
final navigationService = locator.get<NavigationService>(); final navigationService = locator.get<NavigationService>();
final context = navigationService.navigatorKey.currentContext; final context = navigationService.navigatorKey.currentContext;
if (context != null) { if (context != null) {

@ -31,7 +31,7 @@ class _SplashScreenState extends State<SplashScreen> {
void initState() { void initState() {
super.initState(); super.initState();
AppGlobal.CONTEX = context; AppGlobal.CONTEX = context;
if (!kReleaseMode) { if (kReleaseMode) {
checkDeviceSafety(); checkDeviceSafety();
} }
Timer(Duration(seconds: 2, milliseconds: 500), () async { Timer(Duration(seconds: 2, milliseconds: 500), () async {

@ -65,7 +65,7 @@ class _UnsafeDeviceState extends State<UnsafeDevice> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
SizedBox(height: 24), SizedBox(height: 24),
if (locator.get<SecurityService>().detectedThreats.isNotEmpty) ...[ if (service.detectedThreats.isNotEmpty) ...[
Text( Text(
'Detected Issues:', 'Detected Issues:',
style: TextStyle( style: TextStyle(
@ -83,16 +83,15 @@ class _UnsafeDeviceState extends State<UnsafeDevice> {
border: Border.all(color: Colors.red.withOpacity(0.3)), border: Border.all(color: Colors.red.withOpacity(0.3)),
), ),
child: Column( child: Column(
children: locator children: service.detectedThreats
.get<SecurityService>()
.detectedThreats
.where((t) => t.severity == ThreatSeverity.critical) .where((t) => t.severity == ThreatSeverity.critical)
.take(5) // Show max 5 threats .take(5) // Show max 5 threats
.map((threat) => Padding( .map((threat) => Padding(
padding: EdgeInsets.symmetric(vertical: 4), padding: EdgeInsets.symmetric(vertical: 4),
child: Row( child: Row(
children: [ children: [
Icon(Icons.error_outline, size: 16, color: Colors.red), Icon(Icons.error_outline,
size: 16, color: Colors.red),
SizedBox(width: 8), SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(

Loading…
Cancel
Save