gj dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZGdd ZGd d eZGd d eZdS)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)Path)Optional)Core) snake_casecReZdZdZddZdZdZedZedZ dS) RevisiumTempFiletxtNcr|ttjnt||_||_dSN)rrTMPDIRtempdirmode)selfrrs S/opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/utils/revisium.py__init__zRevisiumTempFile.__init__&s-,3OtDK(((g  c$d|jttjdz|jfz}|j|z |_|jrF|jtj t|j|j|S)Nz%s_%d.%sgcA)r) nameinttimeextr_pathrtouchoschmodstr)rfilenames r __enter__zRevisiumTempFile.__enter__*szC d0B,C,CTX NN\H, 9 6 J      HS__49 5 5 5 5 rctt5|jddddS#1swxYwYdSr )rFileNotFoundErrorrunlink)r_s r__exit__zRevisiumTempFile.__exit__2s ' ( (  J                       s<AAc*t|jSr )rrrs rrzRevisiumTempFile.filename6s4:rc4t|jjSr )r __class____name__r&s rrzRevisiumTempFile.name:s$.1222r)NN) r) __module__ __qualname__rrrr$propertyrrrrr r #s C   X33X333rr ceZdZdZdZdS)RevisiumJsonFilejsonc|j5}tj|cdddS#1swxYwYdSr )ropenr0load)rfs rreadzRevisiumJsonFile.readBs Z__   !9Q<<                  s ;??N)r)r*r+rr5r-rrr/r/?s( C     rr/c@eZdZdZedeefdZdZdS)RevisiumCSVFilecsvvaluecP|r|}|dvr|dkSn|dS|S)N)truefalser;)lower)r9 low_values r_convert_booleanz RevisiumCSVFile._convert_booleanJsB   I--- F**. ]2 rcjd5}d|D}tj|gd}fd|DcdddS#1swxYwYdS)z Reads a CSV file and returns its contents as a list of dictionaries. The file must be read in binary mode and decoded manually to preserve the original line ending and carriage return characters. rbcg|];}|tjtjz(RevisiumCSVFile.read..\sU   -//8::r)r4edstr) fieldnamescPg|]"}fd|D#S)cFi|]\}}|||Sr )r@)rIfieldr9rs r z3RevisiumCSVFile.read...gs=$u(40077(((r)items)rIrowrs rrKz(RevisiumCSVFile.read..fsT  (+ rN)rr2r8 DictReader)rr4contentsreaders` rr5zRevisiumCSVFile.readTsZ__T " " a  H^%C%C%CF "                   s2AA"AN) r)r*r+r staticmethodrrr@r5r-rrr7r7GsQ C \rr7)__doc__r8r0rrFr contextlibrpathlibrtypingr defence360agent.contracts.configrdefence360agent.utilsrr r/r7r-rrrbs * 111111,,,,,,333333338     '   &&&&&&&&&&&r