
    Id:Q                         d dl Z d dlZd dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d Zd Zd	 Z G d
 dee      Z G d de      Zy)    N)
gp_pol_extgp_file_applier)misc)
get_string)log)NamedTemporaryFilec                     g d}g d}| |v r(t        j                  t        |j                              S |j                  t
        j                  k(  r| |v r|j                  dk(  S |j                  S )N)(VirtualKeyboardFeaturesDeviceArcDataSnapshotHours"RequiredClientCertificateForDevice RequiredClientCertificateForUserRegisteredProtocolHandlersWebUsbAllowDevicesForUrls DeviceAutoUpdateTimeRestrictionsDeviceUpdateStagingScheduleDeviceMinimumVersionDeviceDisplayResolutionExtensionSettingsKerberosAccounts$NetworkFileSharesPreconfiguredSharesNetworkThrottlingEnabledTPMFirmwareUpdateSettingsDeviceOffHoursParentAccessCodeConfigPerAppTimeLimitsPerAppTimeLimitsWhitelistPerAppTimeLimitsAllowlistUsageTimeLimitPluginVmImage DeviceLoginScreenPowerManagementPowerManagementIdleSettingsScreenLockDelaysScreenBrightnessPercentDevicePowerPeakShiftDayConfig(DeviceAdvancedBatteryChargeModeDayConfigPrintingPaperSizeDefaultAutoLaunchProtocolsFromOriginsBrowsingDataLifetimeDataLeakPreventionRulesList*DeviceLoginScreenWebUsbAllowDevicesForUrlsDeviceScheduledUpdateCheckKeyPermissionsManagedBookmarksManagedConfigurationPerOriginProxySettingsSystemProxySettingsWebAppInstallForceList(  (ShowAccessibilityOptionsInSystemTrayMenuLargeCursorEnabledSpokenFeedbackEnabledHighContrastEnabledVirtualKeyboardEnabledStickyKeysEnabledKeyboardDefaultToFunctionKeysDictationEnabledSelectToSpeakEnabledKeyboardFocusHighlightEnabledCursorHighlightEnabledCaretHighlightEnabledMonoAudioEnabledAccessibilityShortcutsEnabledAutoclickEnabled*DeviceLoginScreenDefaultLargeCursorEnabled-DeviceLoginScreenDefaultSpokenFeedbackEnabled+DeviceLoginScreenDefaultHighContrastEnabled.DeviceLoginScreenDefaultVirtualKeyboardEnabled#DeviceLoginScreenLargeCursorEnabled&DeviceLoginScreenSpokenFeedbackEnabled$DeviceLoginScreenHighContrastEnabled'DeviceLoginScreenVirtualKeyboardEnabled!DeviceLoginScreenDictationEnabled%DeviceLoginScreenSelectToSpeakEnabled'DeviceLoginScreenCursorHighlightEnabled&DeviceLoginScreenCaretHighlightEnabled!DeviceLoginScreenMonoAudioEnabled!DeviceLoginScreenAutoclickEnabled"DeviceLoginScreenStickyKeysEnabled.DeviceLoginScreenKeyboardFocusHighlightEnabled,DeviceLoginScreenShowOptionsInSystemTrayMenu.DeviceLoginScreenAccessibilityShortcutsEnabled FloatingAccessibilityMenuEnabled
ArcEnabledUnaffiliatedArcAllowed!AppRecommendationZeroStateEnabledDeviceBorealisAllowedUserBorealisAllowedSystemUse24HourClockDefaultSearchProviderEnabledChromeOsReleaseChannelDelegatedDeviceAutoUpdateDisabledDeviceAutoUpdateP2PEnabled DeviceUpdateHttpDownloadsEnabledRebootAfterUpdateBlockExternalExtensionsVoiceInteractionContextEnabledVoiceInteractionHotwordEnabledEnableMediaRouterShowCastIconInToolbarDriveDisabledDriveDisabledOverCellularDisableAuthNegotiateCnameLookupEnableAuthNegotiatePortBasicAuthOverHttpEnabled AuthNegotiateDelegateByKdcPolicyAllowCrossOriginAuthPromptNtlmV2Enabled"IntegratedWebAuthenticationAllowedBrowserSwitcherEnabled BrowserSwitcherKeepLastChromeTabBrowserSwitcherUseIeSitelistVirtualMachinesAllowedCrostiniAllowed!DeviceUnaffiliatedCrostiniAllowedCrostiniExportImportUIAllowedCrostiniPortForwardingAllowedNativeMessagingUserLevelHostsNetworkFileSharesAllowedNetBiosShareDiscoveryEnabledNTLMShareAuthenticationEnabledDeviceDataRoamingEnabledDeviceWiFiFastTransitionEnabledDeviceWiFiAllowedDeviceAllowBluetooth+DeviceAllowRedeemChromeOsRegistrationOffersDeviceQuirksDownloadEnabledSuggestedContentEnabled"DeviceShowLowDiskSpaceNotificationPasswordManagerEnabledPasswordLeakDetectionEnabledPluginVmAllowedPluginVmDataCollectionAllowedUserPluginVmAllowedDeviceRebootOnShutdown PowerManagementUsesAudioActivity PowerManagementUsesVideoActivityAllowWakeLocksAllowScreenWakeLocksWaitForInitialUserActivityPowerSmartDimEnabledDevicePowerPeakShiftEnabledDeviceBootOnAcEnabled&DeviceAdvancedBatteryChargeModeEnabledDeviceUsbPowerShareEnabledPrintingEnabledCloudPrintProxyEnabled&PrintingSendUsernameAndFilenameEnabledCloudPrintSubmitEnabledDisablePrintPreviewPrintHeaderFooter#PrintPreviewUseSystemDefaultPrinterUserNativePrintersAllowedUserPrintersAllowedDeletePrintJobHistoryAllowed%DeviceLoginScreenPrivacyScreenEnabledPrivacyScreenEnabledPinUnlockWeakPinsAllowedPinUnlockAutosubmitEnabled!RemoteAccessHostFirewallTraversalRemoteAccessHostRequireCurtain"RemoteAccessHostAllowClientPairing&RemoteAccessHostAllowRelayedConnection0RemoteAccessHostAllowUiAccessForRemoteAssistance!RemoteAccessHostAllowFileTransfer,RemoteAccessHostAllowRemoteAccessConnectionsAttestationEnabledForUserSafeBrowsingEnabled$SafeBrowsingExtendedReportingEnabledDeviceGuestModeEnabledDeviceAllowNewUsersDeviceShowUserNamesOnSigninDeviceEphemeralUsersEnabled$DeviceShowNumericKeyboardForPasswordDeviceFamilyLinkAccountsAllowedShowHomeButtonHomepageIsNewTabPageDeviceMetricsReportingEnabledDeviceWilcoDtcAllowed$AbusiveExperienceInterventionEnforceAccessibilityImageLabelsEnabledAdditionalDnsQueryTypesEnabledAdvancedProtectionAllowedAllowDeletingBrowserHistoryAllowDinosaurEasterEggAllowFileSelectionDialogsAllowScreenLockAllowSyncXHRInPageDismissalAlternateErrorPagesEnabledAlwaysOpenPdfExternallyAppCacheForceEnabledAudioCaptureAllowedAudioOutputAllowedAudioProcessHighPriorityEnabledAudioSandboxEnabledAutoFillEnabledAutofillAddressEnabledAutofillCreditCardEnabledAutoplayAllowedBackgroundModeEnabledBlockThirdPartyCookiesBookmarkBarEnabledBrowserAddPersonEnabledBrowserGuestModeEnabledBrowserGuestModeEnforcedBrowserLabsEnabled BrowserNetworkTimeQueriesEnabledBuiltInDnsClientEnabledCECPQ2Enabled'CaptivePortalAuthenticationIgnoresProxyChromeCleanupEnabledChromeCleanupReportingEnabledChromeOsLockOnIdleSuspendClickToCallEnabled"CloudManagementEnrollmentMandatory"CloudPolicyOverridesPlatformPolicyCloudUserPolicyMerge&CommandLineFlagSecurityWarningsEnabledComponentUpdatesEnabledDNSInterceptionChecksEnabled"DataLeakPreventionReportingEnabledDefaultBrowserSettingEnabled-DefaultSearchProviderContextMenuAccessAllowedDeveloperToolsDisabled&DeviceAllowMGSToStoreDisplayPropertiesDeviceDebugPacketCaptureAllowed'DeviceLocalAccountManagedSessionEnabled)DeviceLoginScreenPrimaryMouseButtonSwitch$DevicePciPeripheralDataAccessEnabledDevicePowerwashAllowedDeviceSystemWideTracingEnabledDisable3DAPIs DisableSafeBrowsingProceedAnywayDisableScreenshotsEasyUnlockAllowedEditBookmarksEnabledEmojiSuggestionEnabledEnableDeprecatedPrivetPrintingEnableOnlineRevocationChecksEnableSyncConsent$EnterpriseHardwarePlatformAPIEnabled,ExternalProtocolDialogShowAlwaysOpenCheckboxExternalStorageDisabledExternalStorageReadOnlyForceBrowserSigninForceEphemeralProfilesForceGoogleSafeSearchForceMaximizeOnFirstRunForceSafeSearchForceYouTubeSafetyModeFullscreenAlertEnabledFullscreenAllowed!GloballyScopeHTTPAuthCacheEnabledHardwareAccelerationModeEnabledHideWebStoreIconImportAutofillFormDataImportBookmarksImportHistoryImportHomepageImportSavedPasswordsImportSearchEngineIncognitoEnabledInsecureFormsWarningsEnabled%InsecurePrivateNetworkRequestsAllowedInstantTetheringAllowed IntensiveWakeUpThrottlingEnabledJavascriptEnabledLacrosAllowedLacrosSecondaryProfilesAllowedLockScreenMediaPlaybackEnabled!LoginDisplayPasswordButtonEnabled)ManagedGuestSessionPrivacyWarningsEnabledMediaRecommendationsEnabledMediaRouterCastAllowAllIPsMetricsReportingEnabledNTPCardsVisibleNTPCustomBackgroundEnabledNativeWindowOcclusionEnabledNearbyShareAllowedPaymentMethodQueryEnabledPdfAnnotationsEnabledPhoneHubAllowedPhoneHubNotificationsAllowedPhoneHubTaskContinuationAllowedPolicyAtomicGroupsEnabledPrimaryMouseButtonSwitchPromotionalTabsEnabledPromptForDownloadLocationQuicAllowedRendererCodeIntegrityEnabled,RequireOnlineRevocationChecksForLocalAnchorsRoamingProfileSupportEnabledSSLErrorOverrideAllowed$SafeBrowsingForTrustedSourcesEnabledSavingBrowserHistoryDisabledScreenCaptureAllowedScrollToTextFragmentEnabledSearchSuggestEnabled#SecondaryGoogleAccountSigninAllowed*SharedArrayBufferUnrestrictedAccessAllowedSharedClipboardEnabledShowAppsShortcutInBookmarkBarShowFullUrlsInAddressBarShowLogoutButtonInTraySignedHTTPExchangeEnabledSigninAllowedSigninInterceptionEnabledSitePerProcessSmartLockSigninAllowedSmsMessagesAllowedSpellCheckServiceEnabledSpellcheckEnabled$StartupBrowserWindowLaunchSuppressed$StricterMixedContentTreatmentEnabled#SuggestLogoutAfterClosingLastWindow&SuppressDifferentOriginSubframeDialogsSuppressUnsupportedOSWarningSyncDisabledTargetBlankImpliesNoOpenerTaskManagerEndProcessEnabledThirdPartyBlockingEnabledTouchVirtualKeyboardEnabledTranslateEnabledTripleDESEnabledUnifiedDesktopEnabledByDefault'UrlKeyedAnonymizedDataCollectionEnabledUserAgentClientHintsEnabledUserFeedbackAllowedVideoCaptureAllowedVmManagementCliAllowedVpnConfigAllowedWPADQuickCheckEnabledWebRtcAllowLegacyTLSProtocolsWebRtcEventLogCollectionAllowedWifiSyncAndroidAllowedWindowOcclusionEnabled   )jsonloadsr   datatyper   	REG_DWORD)nameedict_entriesboolss       :/usr/lib/python3/dist-packages/samba/gp/gp_chromium_ext.pyparse_entry_datar\     sb    '.LP^'E~ |zz*QVV,--	
4>>	!demvv{66M    c                     |j                   j                         rF|j                  j                  d      d   }|| vrg | |<   | |   j	                  t        ||             y |j                   }t        ||      | |<   y )N\)	valuename	isnumerickeynamesplitappendr\  )policiesrX  rW  s      r[  assign_entryrg  g  sm    {{yyt$R(xHTN.tQ78{{)$2r]  c                    i }i }dj                  | dg      }|D ]a  }d|j                  v r|j                  j                  |      rt	        ||       :|j                  j                  |       sVt	        ||       c ||fS )Nr_  Recommendedz
**delvals.)joinra  rc  
startswithrg  )sectionentriesmanagedrecommendedrecommended_sectionrX  s         r[  convert_pol_to_jsonrq  q  s    GK))Wm$<= %1;;&99 34a(YY!!'*!$% Kr]  c                   *    e Zd ZdZdZd Z	 ddZd Zy)gp_chromium_extz/etc/chromium/policies/managedz"/etc/chromium/policies/recommendedc                      y)NzGoogle/Chromium selfs    r[  __str__zgp_chromium_ext.__str__  s     r]  Nc           	         |Jt         j                  j                  |d      | _        t         j                  j                  |d      | _        t         j                  j                  | j                        s"t        j                  | j                  dd       t         j                  j                  | j                        s"t        j                  | j                  dd       |D ]  \  }}t        |       |v s|t        |          j                         D ]  \  }}	 t        j                  |       |dk(  r+t         j                  j                  | j                  d      }n/|dk(  r*t         j                  j                  | j                  d      }| j                  ||         |D ]
  }	|	j                  sd}
d}t         j                  j                  |	j                  |      }| j                  |      }|sSt!        |
|j"                        \  }}d	 }| j%                  t        j&                  |            }| j)                  |	j*                  d|||| j                         | j%                  t        j&                  |            }| j)                  |	j*                  d|||| j                          y # t        j                  j                  $ r | j                  |||       Y w xY w)
Nro  rn  i  T)modeexist_okzpolicies.jsonSoftware\Policies\Google\ChromeMACHINE/Registry.polc                 L   	 t        ddd|d      5 }t        j                  | |       t        j                  |j
                  d       t        j                  d|        |j
                  gcd d d        S # 1 sw Y   y xY w# t        $ r t        j                  d|        Y y w xY w)	Nzw+gp_Fz.json)rz  prefixdeletedirsuffixi  zWrote Chromium preferencesz$Failed to write Chromium preferences)	r   rR  dumposchmodrW  r   debugPermissionError)rf  locationfs      r[  applier_funcz:gp_chromium_ext.process_group_policy.<locals>.applier_func  s    ,/T%7<4<7>@ , DE IIh2HHQVVU3II&BHM$%FF8, , , + ,		"H"*,,s/   B AA5+	B 5A>:B >B B#"B#)r  pathrj  recommended_policies_pathmanaged_policies_pathexistsmakedirsstritemsrR  rS  unapplydecoderJSONDecodeErrorfile_sys_pathparserq  rm  generate_value_hashdumpsapplyrW  )rw  deleted_gpo_listchanged_gpo_list
policy_dirguidsettings	attributerf  fnamegporl  pol_filer  pol_confrn  ro  r  
value_hashs                     r[  process_group_policyz$gp_chromium_ext.process_group_policy  si   !-/WW\\*<I.KD*)+j))LD&ww~~d<<=KK66U!%'ww~~d889KK22!%'. 	=ND(4yH$+3CI+>+D+D+F ='Ix=

8, %5$&GGLL1O1O1@%BE&)3$&GGLL1K1K1@%BET9e<#=	=* $ 	HC  >1ww||C$5$5x@::d+':7;C;K;K(M$, "55djj6IJ


388Y
L"D$>$>@!55djj6MN


388]J&(F(FH9	H!  <<77 @T9h?@s   J880K,+K,c                 R   i }d}d}|j                   rt        j                  j                  |j                   |      }| j	                  |      }|s|S |j
                  D ]F  }|j                  j                  |      s|j                  ||j                  d|j                  <   H |S )Nr}  r|  r_  )
r  r  r  rj  r  rm  rc  rk  rT  ra  )rw  r  outputr  rl  r  r  rX  s           r[  rsopzgp_chromium_ext.rsop  s    )677<< 1 18<Dzz$'H%% I99''0BC&&Fqyy!++>?I r]  )N)__name__
__module____qualname__r  r  rx  r  r  ru  r]  r[  rs  rs  ~  s$    < D! )-?HBr]  rs  c                       e Zd ZdZdZd Zy)gp_chrome_extz /etc/opt/chrome/policies/managedz$/etc/opt/chrome/policies/recommendedc                      y)NzGoogle/Chromeru  rv  s    r[  rx  zgp_chrome_ext.__str__  s    r]  N)r  r  r  r  r  rx  ru  r]  r[  r  r    s    > Fr]  r  )r  rR  samba.gp.gpclassr   r   samba.dcerpcr   samba.commonr   samba.gp.util.loggingr   tempfiler   r\  rg  rq  rs  r  ru  r]  r[  <module>r     sJ   " 
  8  # % 'L\
3 Tj/ TlO r]  