mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
feat(suite): disable device meta checks by message system
This commit is contained in:
committed by
Jiri Zbytovsky
parent
8a261a580b
commit
cbaabde477
@@ -6,13 +6,12 @@ import {
|
||||
} from '@suite-common/firmware-authenticity';
|
||||
import { Feature, selectIsFeatureDisabled } from '@suite-common/message-system';
|
||||
import {
|
||||
getIsDeviceIdValid,
|
||||
selectFirmwareHashCheckError,
|
||||
selectFirmwareRevisionCheckError,
|
||||
selectIsDeviceIdCheckSuccess,
|
||||
selectIsDeviceInvariabilityCheckSuccess,
|
||||
selectIsEntropyCheckFailed,
|
||||
selectIsFirmwareAuthenticityCheckDismissed,
|
||||
selectSelectedDevice,
|
||||
} from '@suite-common/wallet-core';
|
||||
|
||||
import { AppState } from 'src/types/suite';
|
||||
@@ -96,9 +95,23 @@ export const selectIsEntropyCheckEnabledAndFailed = (state: AppState) => {
|
||||
return isEntropyCheckEnabled && !isEntropyCheckDisabledByMessageSystem && isEntropyCheckFailed;
|
||||
};
|
||||
|
||||
export const selectIsDeviceIdCheckEnabledAndFailed = (state: AppState) => {
|
||||
const isDisabledByMessageSystem = selectIsFeatureDisabled(state, Feature.idCheck);
|
||||
const isDeviceIdValid = selectIsDeviceIdCheckSuccess(state);
|
||||
|
||||
return !isDisabledByMessageSystem && !isDeviceIdValid;
|
||||
};
|
||||
|
||||
export const selectIsDeviceInvariabilityEnabledAndFailed = (state: AppState) => {
|
||||
const isDisabledByMessageSystem = selectIsFeatureDisabled(state, Feature.invariabilityCheck);
|
||||
const isDeviceInvariabilityCheckSuccess = selectIsDeviceInvariabilityCheckSuccess(state);
|
||||
|
||||
return !isDisabledByMessageSystem && !isDeviceInvariabilityCheckSuccess;
|
||||
};
|
||||
|
||||
export const selectShouldDisplayDeviceCompromised = (state: AppState): boolean => {
|
||||
const isDeviceIdValid = getIsDeviceIdValid(selectSelectedDevice(state));
|
||||
const deviceInvariabilitySuccess = selectIsDeviceInvariabilityCheckSuccess(state);
|
||||
const isDeviceIdCheckFailed = selectIsDeviceIdCheckEnabledAndFailed(state);
|
||||
const isDeviceInvariabilityCheckFailed = selectIsDeviceInvariabilityEnabledAndFailed(state);
|
||||
|
||||
const isFirmwareCheckEnabledAndFailed =
|
||||
selectIsFirmwareAuthenticityCheckEnabledAndHardFailed(state);
|
||||
@@ -108,8 +121,8 @@ export const selectShouldDisplayDeviceCompromised = (state: AppState): boolean =
|
||||
const isEntropyCheckEnabledAndFailed = selectIsEntropyCheckEnabledAndFailed(state);
|
||||
|
||||
return (
|
||||
!isDeviceIdValid ||
|
||||
!deviceInvariabilitySuccess ||
|
||||
isDeviceIdCheckFailed ||
|
||||
isDeviceInvariabilityCheckFailed ||
|
||||
(!isFirmwareAuthenticityCheckDismissed && isFirmwareCheckEnabledAndFailed) ||
|
||||
isEntropyCheckEnabledAndFailed
|
||||
);
|
||||
|
||||
@@ -74,6 +74,9 @@ export const Feature = {
|
||||
deviceAuthenticityCheckOptiga: 'security.deviceAuthenticityCheck.optiga',
|
||||
deviceAuthenticityCheckTropic: 'security.deviceAuthenticityCheck.tropic',
|
||||
|
||||
idCheck: 'security.deviceMetaChecks.id',
|
||||
invariabilityCheck: 'security.deviceMetaChecks.invariability',
|
||||
|
||||
trading: {
|
||||
buy: 'trading.buy',
|
||||
sell: 'trading.sell',
|
||||
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
} from './deviceConstants';
|
||||
import { DeviceRootState } from './deviceReducer';
|
||||
import { deviceInvariabilityCheck } from './services/deviceInvariabilityCheck';
|
||||
import { getIsDeviceIdValid } from './services/getIsDeviceIdValid';
|
||||
|
||||
const createMemoizedSelector = createWeakMapSelector.withTypes<DeviceRootState>();
|
||||
|
||||
@@ -401,9 +402,23 @@ export const selectWasFwHashCheckOtherErrorLastTime = createMemoizedSelector(
|
||||
},
|
||||
);
|
||||
|
||||
export const selectIsDeviceIdCheckSuccess = createMemoizedSelector(
|
||||
[selectSelectedDevice],
|
||||
device => getIsDeviceIdValid(device) === true,
|
||||
);
|
||||
|
||||
export const selectIsDeviceInvariabilityCheckSuccess = createMemoizedSelector(
|
||||
[selectSelectedDevice, selectSelectedPersistentDeviceData],
|
||||
(device, previousData) => deviceInvariabilityCheck({ device, previousData }).success,
|
||||
(device, previousData) => {
|
||||
// just a failsafe in case memoization returned wrong results
|
||||
if (device && previousData && device.id !== previousData.device_id) {
|
||||
console.error('Device invariability check ID mismatch');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return deviceInvariabilityCheck({ device, previousData }).success;
|
||||
},
|
||||
);
|
||||
|
||||
export const selectIsPortfolioTrackerDevice = createMemoizedSelector(
|
||||
|
||||
Reference in New Issue
Block a user