Page 1 sur 1

[RESOLU]Cisco Immunet antivirus

Publié : 23 oct. 2019 - 16:09
par nliaudat
Working sample to deploy and add exclusions for free Immunet antivirus

setup.py

Code : Tout sélectionner

# -*- coding: utf-8 -*-
from setuphelpers import *
#import time

uninstallkey = []

config_path = makepath(programfiles,'Immunet','local.xml')

def install():
    print('installing %s' % control.asrequirement())


    install_exe_if_needed("ImmunetSetup.exe",'/S',key='',min_version='7.0.0',accept_returncodes=[0,1638])



def uninstall():
    print('uninstalling %s' % control.asrequirement())
    #not a silent uninstaller => manual command
    run(r'"C:\Program Files\Immunet\7.0.0\uninstall.exe" /S /remove 1')

def session_setup():
    print('Session setup for %s' % control.asrequirement())

    #can be run under session setup cause user has permission to write
    update_config()


def update_package():
    print('Update package content from upstream binary sources')


def audit():
    print('Auditing %s' % control.asrequirement())



def update_config():

    import xml.etree.ElementTree as etree

    config = etree.parse(config_path)

    '''
<config>
  <exclusions>
   <info>
    <item>256|3|0|1|.dwg</item>
    <item>256|3|0|1|.dxf</item>
    <item>256|2|1|0|C:\Program Files (x86)\wapt\</item>
    <item>256|2|1|0|C:\powerplan</item>
    <item>256|1|0|0|toolbox.exe</item>
   </info>
  </exclusions>
  '''
    exclusions = config.find('exclusions/info')


    items = []

    dwg = dxf = wapt = need_write = False

    for item in exclusions.iter():
        #list all items
        if item.text:
            if len(item.text.split()) > 0:
                items.append(item.text)
        if item.text.find('.dwg') > 0: #dwg is found
            dwg = True
        if item.text.find('.dxf') > 0:
            dxf = True
        if item.text.find('wapt') > 0:
            wapt = True


    #print(items)

    if dwg == False :
        dwg = etree.SubElement(exclusions, 'item')
        dwg.text = '256|3|0|1|.dwg'
        print('add .dwg exclusion')
        need_write = True

    if dxf == False :
        dxf = etree.SubElement(exclusions, 'item')
        dxf.text = '256|3|0|1|.dxf'
        print('add .dxf exclusion')
        need_write = True

    if wapt == False :
        wapt = etree.SubElement(exclusions, 'item')
        wapt.text = '256|2|1|0|C:\\Program Files (x86)\\wapt\\'
        print('add wapt exclusion')
        need_write = True

    if need_write == True:
        config.write(config_path)


    '''
<scansettings>
    <clamav>
     <options>
      <ondemand>
       <scanarchives>1</scanarchives>
       <scanpacked>1</scanpacked>
      </ondemand>
     </options>
    </clamav>
    <tetra>
     <options>
      <ondemand>
       <scanarchives>1</scanarchives>
       <scanpacked>1</scanpacked>
      </ondemand>
     </options>
    </tetra>
   </scansettings>

  '''