hdZddlZddlZddlZddlmZmZddlmZddl m Z m Z ddl m Z ddlmZmZddlmZdd lmZmZGd d e ZdS) 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) GeneratorUnion) MessageType) MessageSinkexpect) nice_iterator)MalwareScanTypeVulnerabilityHitStatus) ProcessOrder) MalwareScanVulnerabilityHitc eZdZejZdZe d dee e fde dzde e ddffdZ de ddfdZeejd ZdS) StoreVulnerabilitiesc KdSN)selfloops b/opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/plugins/store_vulnerabilities.py create_sinkz StoreVulnerabilities.create_sink&s  Npath_obj scan_typereturnc #Kt|tr|gn|}|tjkrt |Ed{VdS|D]y}t j|D]`}tj |}tj |rtj tj|tjt"jt"jgzkr|Vt+j|dz}dtj tj|tjt"jt"jgDEd{Vb{dS)z Return files that may already not be vulnerable, yet we still consider them such. For example, a vulnerable file might have been removed manually. Nz(/.*|\b)c3$K|] }|jV dSr) orig_file).0is r z.Ps8         r) isinstancestrr REALTIMEiterglobiglobospathrealpathisfiler selectwhererstatusin_r VULNERABLEREVERTEDfirstreescaperegexp)rrpaths target_pathr( scanned_dirs rget_outdated_entriesz)StoreVulnerabilities.get_outdated_entries)s)377E X 0 0 0E{{ " " " " " " " F  K ;//  w''--GNN4(((/11U(2*155 6 A 6 ?  UWWJJJJ"$)D//K"?K  !1!8!:!:!@!@,6==kJJ,377$:$E$:$C!"""           )   rsummaryc |dd}|dd}|d=|=|=||d|d}tj|dSdSdSdS)N file_patternsexclude_patternserrorr(type)r)popgetr8r delete_hits)rr9r;r<outdated_entriess r_delete_outdated_entriesz-StoreVulnerabilities._delete_outdated_entries]s OT:: ";;'94@@ KK (% (#8876? 9     ()9 : : : : : ) (%%((rc |K|ddr|ddStj|dd}|dd||dd|dDx}rt |23d{V\}}t j|j|d|d |d |d ||d d d|d d dtj  s6dSdS)Nr9startedresultsscanid)rGr(cfi|].\}}tj|ddd+||/S)hitsrmatches)r match)rfilenamedatas r z5StoreVulnerabilities.process_hits..vsL   $%d6l1oi&@AA d   rownerusersizehashrIrrJ timestamp) rGrOrPrQrRrr>rSr-) r@r rCitemsrr createrGr r/)rmessagescanrFrLrMs r process_hitsz!StoreVulnerabilities.process_hitsjsvy!%%i00 GI4F4N Fgi&8&BCCC 9  ! !& ) ) 5  ) )')*< = = =  "))"4":":"<"<    7  )6gmmoo(F(F       nh ';w-fff&fa3"6l1ok:1<     )G(F(F   sD9r)__name__ __module__ __qualname__r AFTER_STORE_SCANPROCESSING_ORDERr staticmethodrr"listrr8dictrCrrr rXrrrrr#s#4   !%11T "1:1 3d? #111\1f ; ; ; ; ; ; VK #$$%$rr)__doc__r%r'r2typingrr"defence360agent.contracts.messagesr!defence360agent.contracts.pluginsrrdefence360agent.utilsrimav.malwarelib.configr r imav.contracts.pluginsr imav.malwarelib.modelr r rrrrris* ########::::::AAAAAAAA//////JJJJJJJJ//////????????eeeee;eeeeer