1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

common: add PromptTemporarily to SafetyChecks enum

This commit is contained in:
Martin Milata 2020-09-03 16:47:57 +02:00 committed by Tomas Susanka
parent 9d2ad96ad4
commit 7d37b2c90f
7 changed files with 16 additions and 13 deletions

View File

@ -18,8 +18,9 @@ enum BackupType {
* Level of safety checks for unsafe actions like spending from invalid path namespace or setting high transaction fee. * Level of safety checks for unsafe actions like spending from invalid path namespace or setting high transaction fee.
*/ */
enum SafetyCheckLevel { enum SafetyCheckLevel {
Strict = 0; // disallow unsafe actions Strict = 0; // disallow unsafe actions, this is the default
Prompt = 1; // ask user before unsafe action PromptAlways = 1; // ask user before unsafe action
PromptTemporarily = 2; // like PromptAlways but reverts to Strict after reboot
} }
/** /**
@ -98,7 +99,7 @@ message Features {
optional bool wipe_code_protection = 34; // is wipe code protection enabled optional bool wipe_code_protection = 34; // is wipe code protection enabled
optional bytes session_id = 35; optional bytes session_id = 35;
optional bool passphrase_always_on_device = 36; // device enforces passphrase entry on Trezor optional bool passphrase_always_on_device = 36; // device enforces passphrase entry on Trezor
optional SafetyCheckLevel safety_checks = 37; // safety check level, set to Prompt to limit path namespace enforcement optional SafetyCheckLevel safety_checks = 37; // safety check level, set to Prompt to limit path namespace enforcement
} }
/** /**

View File

@ -6,7 +6,7 @@ if __debug__:
try: try:
from typing import Dict, List # noqa: F401 from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401 from typing_extensions import Literal # noqa: F401
EnumTypeSafetyCheckLevel = Literal[0, 1] EnumTypeSafetyCheckLevel = Literal[0, 1, 2]
except ImportError: except ImportError:
pass pass
@ -44,5 +44,5 @@ class ApplySettings(p.MessageType):
6: ('auto_lock_delay_ms', p.UVarintType, 0), 6: ('auto_lock_delay_ms', p.UVarintType, 0),
7: ('display_rotation', p.UVarintType, 0), 7: ('display_rotation', p.UVarintType, 0),
8: ('passphrase_always_on_device', p.BoolType, 0), 8: ('passphrase_always_on_device', p.BoolType, 0),
9: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0), 9: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1, 2)), 0),
} }

View File

@ -8,7 +8,7 @@ if __debug__:
from typing_extensions import Literal # noqa: F401 from typing_extensions import Literal # noqa: F401
EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
EnumTypeBackupType = Literal[0, 1, 2] EnumTypeBackupType = Literal[0, 1, 2]
EnumTypeSafetyCheckLevel = Literal[0, 1] EnumTypeSafetyCheckLevel = Literal[0, 1, 2]
except ImportError: except ImportError:
pass pass
@ -127,5 +127,5 @@ class Features(p.MessageType):
34: ('wipe_code_protection', p.BoolType, 0), 34: ('wipe_code_protection', p.BoolType, 0),
35: ('session_id', p.BytesType, 0), 35: ('session_id', p.BytesType, 0),
36: ('passphrase_always_on_device', p.BoolType, 0), 36: ('passphrase_always_on_device', p.BoolType, 0),
37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0), 37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1, 2)), 0),
} }

View File

@ -4,4 +4,5 @@ if False:
from typing_extensions import Literal from typing_extensions import Literal
Strict = 0 # type: Literal[0] Strict = 0 # type: Literal[0]
Prompt = 1 # type: Literal[1] PromptAlways = 1 # type: Literal[1]
PromptTemporarily = 2 # type: Literal[2]

View File

@ -6,7 +6,7 @@ if __debug__:
try: try:
from typing import Dict, List # noqa: F401 from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401 from typing_extensions import Literal # noqa: F401
EnumTypeSafetyCheckLevel = Literal[0, 1] EnumTypeSafetyCheckLevel = Literal[0, 1, 2]
except ImportError: except ImportError:
pass pass
@ -44,5 +44,5 @@ class ApplySettings(p.MessageType):
6: ('auto_lock_delay_ms', p.UVarintType, 0), 6: ('auto_lock_delay_ms', p.UVarintType, 0),
7: ('display_rotation', p.UVarintType, 0), 7: ('display_rotation', p.UVarintType, 0),
8: ('passphrase_always_on_device', p.BoolType, 0), 8: ('passphrase_always_on_device', p.BoolType, 0),
9: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0), 9: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1, 2)), 0),
} }

View File

@ -8,7 +8,7 @@ if __debug__:
from typing_extensions import Literal # noqa: F401 from typing_extensions import Literal # noqa: F401
EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
EnumTypeBackupType = Literal[0, 1, 2] EnumTypeBackupType = Literal[0, 1, 2]
EnumTypeSafetyCheckLevel = Literal[0, 1] EnumTypeSafetyCheckLevel = Literal[0, 1, 2]
except ImportError: except ImportError:
pass pass
@ -127,5 +127,5 @@ class Features(p.MessageType):
34: ('wipe_code_protection', p.BoolType, 0), 34: ('wipe_code_protection', p.BoolType, 0),
35: ('session_id', p.BytesType, 0), 35: ('session_id', p.BytesType, 0),
36: ('passphrase_always_on_device', p.BoolType, 0), 36: ('passphrase_always_on_device', p.BoolType, 0),
37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0), 37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1, 2)), 0),
} }

View File

@ -4,4 +4,5 @@ if False:
from typing_extensions import Literal from typing_extensions import Literal
Strict = 0 # type: Literal[0] Strict = 0 # type: Literal[0]
Prompt = 1 # type: Literal[1] PromptAlways = 1 # type: Literal[1]
PromptTemporarily = 2 # type: Literal[2]