(ns, sccd, new_hash=None)
| 217 | |
| 218 | |
| 219 | def _fixup_sccd(ns, sccd, new_hash=None): |
| 220 | if not new_hash: |
| 221 | return sccd |
| 222 | |
| 223 | NS = dict(s="http://schemas.microsoft.com/appx/2016/sccd") |
| 224 | with open(sccd, "rb") as f: |
| 225 | xml = ET.parse(f) |
| 226 | |
| 227 | pfn = get_packagefamilyname(APPX_DATA["Name"], APPX_DATA["Publisher"]) |
| 228 | |
| 229 | ae = xml.find("s:AuthorizedEntities", NS) |
| 230 | ae.clear() |
| 231 | |
| 232 | e = ET.SubElement(ae, ET.QName(NS["s"], "AuthorizedEntity")) |
| 233 | e.set("AppPackageFamilyName", pfn) |
| 234 | e.set("CertificateSignatureHash", new_hash) |
| 235 | |
| 236 | for e in xml.findall("s:Catalog", NS): |
| 237 | e.text = "FFFF" |
| 238 | |
| 239 | sccd = ns.temp / sccd.name |
| 240 | sccd.parent.mkdir(parents=True, exist_ok=True) |
| 241 | with open(sccd, "wb") as f: |
| 242 | xml.write(f, encoding="utf-8") |
| 243 | |
| 244 | return sccd |
| 245 | |
| 246 | |
| 247 | def find_or_add(xml, element, attr=None, always_add=False): |
no test coverage detected
searching dependent graphs…