1111 FILE_HASSIO_SECURITY ,
1212)
1313from ..coresys import CoreSys , CoreSysAttributes
14- from ..exceptions import (
15- CodeNotaryError ,
16- CodeNotaryUntrusted ,
17- PwnedError ,
18- SecurityJobError ,
19- )
20- from ..jobs .const import JobConcurrency
21- from ..jobs .decorator import Job , JobCondition
22- from ..resolution .const import ContextType , IssueType , SuggestionType
23- from ..utils .codenotary import cas_validate
14+ from ..exceptions import PwnedError
2415from ..utils .common import FileConfiguration
2516from ..utils .pwned import check_pwned_password
2617from ..validate import SCHEMA_SECURITY_CONFIG
27- from .const import ContentTrustResult , IntegrityResult
2818
2919_LOGGER : logging .Logger = logging .getLogger (__name__ )
3020
@@ -67,30 +57,6 @@ def pwned(self, value: bool) -> None:
6757 """Set pwned is enabled/disabled."""
6858 self ._data [ATTR_PWNED ] = value
6959
70- async def verify_content (self , signer : str , checksum : str ) -> None :
71- """Verify content on CAS."""
72- if not self .content_trust :
73- _LOGGER .warning ("Disabled content-trust, skip validation" )
74- return
75-
76- try :
77- await cas_validate (signer , checksum )
78- except CodeNotaryUntrusted :
79- raise
80- except CodeNotaryError :
81- if self .force :
82- raise
83- self .sys_resolution .create_issue (
84- IssueType .TRUST ,
85- ContextType .SYSTEM ,
86- suggestions = [SuggestionType .EXECUTE_INTEGRITY ],
87- )
88- return
89-
90- async def verify_own_content (self , checksum : str ) -> None :
91- """Verify content from HA org."""
92- return await self .
verify_content (
"[email protected] " ,
checksum )
93-
9460 async def verify_secret (self , pwned_hash : str ) -> None :
9561 """Verify pwned state of a secret."""
9662 if not self .pwned :
@@ -103,73 +69,3 @@ async def verify_secret(self, pwned_hash: str) -> None:
10369 if self .force :
10470 raise
10571 return
106-
107- @Job (
108- name = "security_manager_integrity_check" ,
109- conditions = [JobCondition .INTERNET_SYSTEM ],
110- on_condition = SecurityJobError ,
111- concurrency = JobConcurrency .REJECT ,
112- )
113- async def integrity_check (self ) -> IntegrityResult :
114- """Run a full system integrity check of the platform.
115-
116- We only allow to install trusted content.
117- This is a out of the band manual check.
118- """
119- result : IntegrityResult = IntegrityResult ()
120- if not self .content_trust :
121- _LOGGER .warning (
122- "Skipping integrity check, content_trust is globally disabled"
123- )
124- return result
125-
126- # Supervisor
127- try :
128- await self .sys_supervisor .check_trust ()
129- result .supervisor = ContentTrustResult .PASS
130- except CodeNotaryUntrusted :
131- result .supervisor = ContentTrustResult .ERROR
132- self .sys_resolution .create_issue (IssueType .TRUST , ContextType .SUPERVISOR )
133- except CodeNotaryError :
134- result .supervisor = ContentTrustResult .FAILED
135-
136- # Core
137- try :
138- await self .sys_homeassistant .core .check_trust ()
139- result .core = ContentTrustResult .PASS
140- except CodeNotaryUntrusted :
141- result .core = ContentTrustResult .ERROR
142- self .sys_resolution .create_issue (IssueType .TRUST , ContextType .CORE )
143- except CodeNotaryError :
144- result .core = ContentTrustResult .FAILED
145-
146- # Plugins
147- for plugin in self .sys_plugins .all_plugins :
148- try :
149- await plugin .check_trust ()
150- result .plugins [plugin .slug ] = ContentTrustResult .PASS
151- except CodeNotaryUntrusted :
152- result .plugins [plugin .slug ] = ContentTrustResult .ERROR
153- self .sys_resolution .create_issue (
154- IssueType .TRUST , ContextType .PLUGIN , reference = plugin .slug
155- )
156- except CodeNotaryError :
157- result .plugins [plugin .slug ] = ContentTrustResult .FAILED
158-
159- # Add-ons
160- for addon in self .sys_addons .installed :
161- if not addon .signed :
162- result .addons [addon .slug ] = ContentTrustResult .UNTESTED
163- continue
164- try :
165- await addon .check_trust ()
166- result .addons [addon .slug ] = ContentTrustResult .PASS
167- except CodeNotaryUntrusted :
168- result .addons [addon .slug ] = ContentTrustResult .ERROR
169- self .sys_resolution .create_issue (
170- IssueType .TRUST , ContextType .ADDON , reference = addon .slug
171- )
172- except CodeNotaryError :
173- result .addons [addon .slug ] = ContentTrustResult .FAILED
174-
175- return result
0 commit comments