K6hDdZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZddlmZejd Zejd ZejeZd Zd Zd ZdZdZdZdZGddeZGdde Z!GddZ"dS)u  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.  If not, see . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see N)suppress)IntEnum)Path)ListOptional)importer)PatchmanConfigzcryptography.x509zpyasn1.codec.der.decoderzlicensing.patchman.coiz/etc/patchman/ca.crtz"/etc/patchman/license/patchman.crtz"/etc/patchman/license/patchman.keyz*https://{address}:{port}/v2/imunifyav_key/z1.3.6.1.4.1.44098.2.1.3cFeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdS)Featurezr Patchman functionality depending on the license. See patchman agent implementation for more details. r N)__name__ __module__ __qualname____doc__CoreCoreMalwareQuarantineCoreVulnerabilitiesPatchRulesMalwareScanRulesMalwareCleanEcommerceVulnerabilitiesScanEcommerceVulnerabilitiesPatchPluginVulnerabilitiesScanPluginVulnerabilitiesPatchScanningMultithreadedScanningRealtimePatchDependenciesWafJ/opt/imunify360/venv/lib/python3.11/site-packages/imav/patchman/license.pyr r 1sf D #$ $%! !!" CCCr*r ceZdZdS)PatchmanLicenseErrorN)rrrr)r*r+r-r-FsDr*r-ceZdZedZedeefdZedefdZ edZ ede e fdZ ede e fdZdS) LicensecNttSN)rLICENSE_CERT_FILEexistsclss r+ is_activezLicense.is_activeKs%&&--///r*returncg}|r?ttd5}t|}dddn #1swxYwYt d|jDdx}rt |j j \}}| }| tjt|dD]Y\}} | dkrNt!t"5| t|dddn #1swxYwYZt$d||S)zX Return the list of features available for the current patchman license rbNc3DK|]}|jjtk|VdSr1)oid dotted_stringFEATURES_EXTENSION_OID).0exts r+ z'License.get_features..Ys?w,0FFFFFFFr*r )start1zPatchman license features: %s)r6openr2x509load_pem_x509_certificatereadnext extensions asn1_decoderdecodevalueasBinaryappendr r enumerater ValueErrorloggerinfo) r5featuresfcertr? asn1_data_ bitstringposrKs r+ get_featureszLicense.get_featuresOs  ==?? :'.. @!55affhh?? @ @ @ @ @ @ @ @ @ @ @ @ @ @ @#  s : ,2239?CC 1%..00  ---"+IQ"?"?"?::JC||%j11::$OOGCLL999::::::::::::::: 3X>>>s#-A&&A*-A*#E  E E cBtj|vSr1)r r rYr4s r+has_clean_modezLicense.has_clean_modems(C,<,<,>,>>>r*cBtj|vSr1)r r&rYr4s r+has_realtime_enabledzLicense.has_realtime_enabledqs'3+;+;+=+===r*ctjddt}tjddt}tjddt}t j}|||tttj t||| 5}|j}|jd kr2|cd d d S|d kr d d d d St'd |jd#1swxYwYd S)zw Get imunify registration key from the Patchman license service. See LICENSING-84 for details. licensingca)defaultaddressport)cafile)certfilekeyfile)rbrc)contextNiz!Patchman license service returns z response)r get CA_ROOT_FILELICENSE_ADDRESS LICENSE_PORTsslcreate_default_contextload_verify_locationsload_cert_chainr2LICENSE_KEY_FILEurllibrequesturlopenIMUNIFY_KEY_URL_TEMPLATEformatstatusrFrJr-)r5rdrbrcrgresponserws r+_get_imunify_keyzLicense._get_imunify_keyus  #K|LLL $ O   !+v|LLL,..%%V%444&$    ^ # # $ + +G$ + G G$  _F#%%}}--//        3        'NHONNN           s8E E 3E  EEcKtj} tj|d|jdd{VS#t $r%}t d|Yd}~nd}~wwxYwdS)Ni,)timeoutzCan't get imunify key due to %s)asyncioget_event_loopwait_forrun_in_executorry ExceptionrPerror)r5loopexcs r+get_imunify_keyzLicense.get_imunify_keys%'' A )$$T3+?@@  A A A LL:C @ @ @ @ @ @ @ @ Ats4A A;A66A;N)rrr classmethodr6rr rYboolr[r]rstrryrr)r*r+r/r/Js00[0T'][:?t???[?>>[>#[: hsm   [   r*r/)#rr|loggingrmrr contextlibrenumrpathlibrtypingrrdefence360agent.utilsrimav.patchman.configr LazyImportrDrI getLoggerrrPrkrlrjr2rqrur=r rr-r/r)r*r+rs* !!!!!!!!******//////x.//"x"#=>>  8 $ $) % 87G2     g   *     9   SSSSSSSSSSr*