{"id":390651,"date":"2024-12-12T06:12:33","date_gmt":"2024-12-12T06:12:33","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=390651"},"modified":"2024-12-12T06:12:33","modified_gmt":"2024-12-12T06:12:33","slug":"personalizzare-le-eccezioni-antivirus-in-linux","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/it\/script-hub\/personalizzare-le-eccezioni-antivirus-in-linux\/","title":{"rendered":"Guida IT: personalizzare le eccezioni antivirus con uno script Bash in Linux\u00a0"},"content":{"rendered":"<h2>Introduzione<\/h2>\n<p>Il mantenimento di informazioni accurate sullo stato dell&#8217;antivirus sui dispositivi \u00e8 fondamentale per i professionisti IT e i <a href=\"https:\/\/www.ninjaone.com\/it\/cos-e-un-msp\">provider di servizi gestiti (MSP)<\/a>. Tenere traccia delle versioni, degli stati e degli aggiornamenti dell&#8217;antivirus garantisce l&#8217;applicazione dei criteri di sicurezza e la protezione dei sistemi. Per gli ambienti Linux, l&#8217;automazione pu\u00f2 semplificare questo processo. Questo post presenta uno script Bash progettato per gestire le eccezioni antivirus sui dispositivi, offrendo ai team IT uno strumento pratico per mantenere le informazioni sulla sicurezza degli endpoint.<\/p>\n<h2>Contesto<\/h2>\n<p>Negli ambienti IT, in particolare per gli MSP che gestiscono un gran numero di dispositivi, lo stato dell&#8217;antivirus \u00e8 una metrica fondamentale. Tuttavia, spesso si verificano discrepanze tra lo stato effettivo del software antivirus su un dispositivo e come effettivamente appare negli strumenti di monitoraggio. Questo script consente ai professionisti IT di impostare o aggiornare manualmente le informazioni sull&#8217;antivirus, compresi nome, versione, stato operativo e stato di aggiornamento. Consentendo la personalizzazione o la rimozione delle eccezioni, semplifica la gestione della sicurezza degli endpoint negli ambienti che si affidano a strumenti come NinjaOne.<\/p>\n<h2>Lo script per personalizzare le eccezioni antivirus:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/env bash\r\n#\r\n# Description: Add an antivirus to the device details or override the existing antivirus information.\r\n# By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n# Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n# Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n# Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n# Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n# Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n# Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n# EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#\r\n# Preset Parameter: --antivirusName \"ReplaceMeWithYourDesiredName\"\r\n#   Name of the antivirus you would like to appear in the device details.\r\n#\r\n# Preset Parameter: --antivirusVersion \"1.0.2\"\r\n#   Specify the version number of the antivirus.\r\n#\r\n# Preset Parameter: --antivirusStatus \"Up-to-Date\"\r\n#   Specify whether the antivirus definitions are Up-to-Date, Out-of-Date, or Unknown.\r\n#\r\n# Preset Parameter: --antivirusState \"ON\"\r\n#   Specify the current status of the antivirus.\r\n#\r\n# Preset Parameter: --removeOverride\r\n#   Remove all existing overrides.\r\n#\r\n# Preset Parameter: --antivirusState\r\n#   Append or update an existing override.\r\n#\r\n# Preset Parameter: --help\r\n#\t\tDisplays a help menu.\r\n#\r\n# Release Notes: Initial Release\r\n\r\n# Initialize variables\r\n_arg_antivirusName=\r\n_arg_antivirusVersion=\r\n_arg_antivirusStatus=\r\n_arg_antivirusState=\r\n_arg_removeOverride=\"off\"\r\n_arg_append=\"off\"\r\n\r\n# Function to display help message\r\nprint_help() {\r\n  printf '\\n\\n%s\\n\\n' 'Usage: [--antivirusName|-n &lt;arg&gt;] [--antivirusVersion|-v &lt;arg&gt;] [--antivirusStatus|--status &lt;arg&gt;] [--antivirusState|--state &lt;arg&gt;] [--removeOverride|-r] [--append|-a] [--help|-h] '\r\n  printf '%s\\n' 'Preset Parameter: --antivirusName \"ReplaceMeWithYourDesiredName\"'\r\n  printf '\\t%s\\n' \"Name of the antivirus you would like to appear in the device details.\"\r\n  printf '%s\\n' 'Preset Parameter: --antivirusVersion \"1.0.2\"'\r\n  printf '\\t%s\\n' \"Specify the version number of the antivirus.\"\r\n  printf '%s\\n' 'Preset Parameter: --antivirusStatus \"Up-to-Date\"'\r\n  printf '\\t%s\\n' \"Specify whether the antivirus definitions are Up-to-Date, Out-of-Date, or Unknown.\"\r\n  printf '%s\\n' 'Preset Parameter: --antivirusState \"ON\"'\r\n  printf '\\t%s\\n' \"Specify the current status of the antivirus.\"\r\n  printf '%s\\n' 'Preset Parameter: --removeOverride'\r\n  printf '\\t%s\\n' \"Remove all existing overrides.\"\r\n  printf '%s\\n' 'Preset Parameter: --antivirusState'\r\n  printf '\\t%s\\n' \"Append or update an existing override.\"\r\n  printf '\\n%s\\n' 'Preset Parameter: --help'\r\n  printf '\\t%s\\n' \"Displays this help menu.\"\r\n}\r\n\r\n# Function to print an error message and exit\r\ndie() {\r\n  local _ret=\"${2:-1}\"\r\n  echo \"$1\" &gt;&amp;2\r\n  test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n  exit \"${_ret}\"\r\n}\r\n\r\n# Function to parse command line arguments\r\nparse_commandline() {\r\n  while test $# -gt 0; do\r\n    _key=\"$1\"\r\n    case \"$_key\" in\r\n    --antivirusName | --antivirusname | --name | -n)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the argument '$_key'.\" 1\r\n      _arg_antivirusName=$2\r\n      shift\r\n      ;;\r\n    --antivirusName=*)\r\n      _arg_antivirusName=\"${_key##--antivirusName=}\"\r\n      ;;\r\n    --antivirusVersion | --antivirusversion | --version | -v)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the argument '$_key'.\" 1\r\n      _arg_antivirusVersion=$2\r\n      shift\r\n      ;;\r\n    --antivirusVersion=*)\r\n      _arg_antivirusVersion=\"${_key##--antivirusVersion=}\"\r\n      ;;\r\n    --antivirusStatus | --antivirusstatus | --status)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the argument '$_key'.\" 1\r\n      _arg_antivirusStatus=$2\r\n      shift\r\n      ;;\r\n    --antivirusStatus=*)\r\n      _arg_antivirusStatus=\"${_key##--antivirusStatus=}\"\r\n      ;;\r\n    --antivirusState | --antivirusstate | --state)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the argument '$_key'.\" 1\r\n      _arg_antivirusState=$2\r\n      shift\r\n      ;;\r\n    --antivirusState=*)\r\n      _arg_antivirusState=\"${_key##--antivirusState=}\"\r\n      ;;\r\n    --removeOverride | --remove | -r)\r\n      _arg_removeOverride=\"on\"\r\n      ;;\r\n    --append | --Append | -a)\r\n      _arg_append=\"on\"\r\n      ;;\r\n    --help | -h)\r\n      _PRINT_HELP=yes die 0\r\n      ;;\r\n    *)\r\n      _PRINT_HELP=yes die \"[Error] Got an unexpected argument '$1'\" 1\r\n      ;;\r\n    esac\r\n    shift\r\n  done\r\n}\r\n\r\n# Parse the command line arguments\r\nparse_commandline \"$@\"\r\n\r\n# Replace commandline parameters with script form variables\r\nif [[ -n $avName ]]; then\r\n  _arg_antivirusName=\"$avName\"\r\nfi\r\nif [[ -n $avVersion ]]; then\r\n  _arg_antivirusVersion=\"$avVersion\"\r\nfi\r\nif [[ -n $avStatus ]]; then\r\n  _arg_antivirusStatus=\"$avStatus\"\r\nfi\r\nif [[ -n $avState ]]; then\r\n  _arg_antivirusState=\"$avState\"\r\nfi\r\nif [[ -n $append &amp;&amp; $append == \"true\" ]]; then\r\n  _arg_append=\"on\"\r\nfi\r\nif [[ -n $removeOverride &amp;&amp; $removeOverride == \"true\" ]]; then\r\n  _arg_removeOverride=\"on\"\r\nfi\r\n\r\n# Ensure that removing an override and adding\/updating an override are not done simultaneously\r\nif [[ $_arg_removeOverride == \"on\" &amp;&amp; (-n $_arg_antivirusName || -n $_arg_antivirusState || -n $_arg_antivirusStatus || -n $_arg_antivirusVersion || $_arg_append == \"on\") ]]; then\r\n  _PRINT_HELP=no die \"[Error] Cannot remove an override and add an override at the same time.\" 1\r\nfi\r\n\r\n# Check for required antivirus name and escape special characters if necessary\r\nreservedCharacters='[\\\"]'\r\nif [[ -z $_arg_antivirusName &amp;&amp; $_arg_removeOverride != \"on\" ]]; then\r\n  if [[ $_arg_append == \"on\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] Antivirus name was not given. The antivirus name is required when updating or adding a new override!\" 1\r\n  else\r\n    _PRINT_HELP=yes die \"[Error] Antivirus name was not given. Antivirus name, state, and status are required when adding a new override!\" 1\r\n  fi\r\nelif [[ -n $_arg_antivirusName &amp;&amp; $_arg_antivirusName =~ $reservedCharacters ]]; then\r\n  _arg_antivirusName=${_arg_antivirusName\/\/\\\\\/\\\\\\\\}\r\n  _arg_antivirusName=${_arg_antivirusName\/\/\\\"\/\\\\\\\"}\r\nfi\r\n\r\n# Check for required antivirus status\r\nif [[ -z $_arg_antivirusStatus &amp;&amp; $_arg_removeOverride != \"on\" &amp;&amp; $_arg_append != \"on\" ]]; then\r\n  _PRINT_HELP=yes die \"[Error] Antivirus status was not given. Antivirus name, state, and status are required!\" 1\r\nfi\r\n\r\n# Validate antivirus status\r\nif [[ -n $_arg_antivirusStatus &amp;&amp; $_arg_antivirusStatus != \"Up-to-Date\" &amp;&amp; $_arg_antivirusStatus != \"Out-of-Date\" &amp;&amp; $_arg_antivirusStatus != \"Unknown\" ]]; then\r\n  _PRINT_HELP=no die \"[Error] An invalid antivirus status of '$_arg_antivirusStatus' was given. Only the following statuses are valid. 'Up-to-Date', 'Out-of-Date', and 'Unknown'.\" 1\r\nfi\r\n\r\n# Check for required antivirus state\r\nif [[ -z $_arg_antivirusState &amp;&amp; $_arg_removeOverride != \"on\" &amp;&amp; $_arg_append != \"on\" ]]; then\r\n  _PRINT_HELP=yes die \"[Error] Antivirus state was not given. Antivirus name, state, and status are required!\" 1\r\nelse\r\n  _arg_antivirusState=$(echo \"$_arg_antivirusState\" | tr '[:lower:]' '[:upper:]')\r\nfi\r\n\r\n# Validate antivirus state\r\nif [[ -n $_arg_antivirusState &amp;&amp; $_arg_antivirusState != \"ON\" &amp;&amp; $_arg_antivirusState != \"OFF\" &amp;&amp; $_arg_antivirusState != \"EXPIRED\" &amp;&amp; $_arg_antivirusState != \"SNOOZED\" &amp;&amp; $_arg_antivirusState != \"UNKNOWN\" ]]; then\r\n  _PRINT_HELP=no die \"[Error] An invalid antivirus state of '$_arg_antivirusState' was given. Only the following states are valid. 'ON', 'OFF', 'EXPIRED', 'SNOOZED', and 'UNKNOWN'.\" 1\r\nfi\r\n\r\n# Validate antivirus version\r\nif [[ -n $_arg_antivirusVersion &amp;&amp; $_arg_antivirusVersion =~ [^0-9\\.] ]]; then\r\n  _PRINT_HELP=no die \"[Error] The antivirus version given '$_arg_antivirusVersion' contains an invalid character. Only the following characters are allowed. '0-9' and '.'\" 1\r\nfi\r\n\r\n# Check if the removeOverride flag is set to \"on\"\r\nif [[ $_arg_removeOverride == \"on\" ]]; then\r\n  echo \"Removing override as requested.\"\r\n  # Check if the override file exists\r\n  if [[ ! -f \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\" ]]; then\r\n    echo \"No override present.\"\r\n    exit 0\r\n  # Try to remove the override file and capture any error output\r\n  elif output=$(rm \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\" 2&gt;&amp;1); then\r\n    echo \"Succesfully removed override!\"\r\n    exit 0\r\n  # Print an error message if the removal fails\r\n  else\r\n    echo \"[Error] Failed to remove override!\"\r\n    echo \"[Error] $output\"\r\n  fi\r\nfi\r\n\r\n# Check if the customization directory exists\r\nif [[ ! -d \"\/opt\/NinjaRMMAgent\/programdata\/customization\" ]]; then\r\n  echo \"Creating customization folder at '\/opt\/NinjaRMMAgent\/programdata\/customization'.\"\r\n  # Try to create the customization directory and capture any error output\r\n  if output=$(mkdir \"\/opt\/NinjaRMMAgent\/programdata\/customization\" 2&gt;&amp;1); then\r\n    echo \"Folder created.\"\r\n  else\r\n    # Print an error message if the creation fails\r\n    echo \"[Error] Unable to create customization folder.\" &gt;&amp;2\r\n    echo \"[Error] $output\" &gt;&amp;2\r\n    exit 1\r\n  fi\r\nfi\r\n\r\n# Check if the append flag is set to \"on\" and the override JSON file exists\r\nif [[ $_arg_append == \"on\" &amp;&amp; -f \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\" ]]; then\r\n  # Extract antivirus names, versions, statuses and states from the JSON file\r\n  avNames=$(grep \"av_name\" \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\" | tr -s \" \" | sed s\/\\\"av_name\\\":\/\/g | sed -e 's\/^[[:space:]]*\/\/' | sed 's\/[\\\",]\/\/g' | sed -e 's\/[[:space:]]*$\/\/')\r\n  avVersions=$(grep \"av_version\" \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\" | tr -s \" \" | sed s\/\\\"av_version\\\":\/\/g | sed -e 's\/^[[:space:]]*\/\/' | sed 's\/[\\\",]\/\/g' | sed -e 's\/[[:space:]]*$\/\/')\r\n  avStatuses=$(grep \"av_status\" \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\" | tr -s \" \" | sed s\/\\\"av_status\\\":\/\/g | sed -e 's\/^[[:space:]]*\/\/' | sed 's\/[\\\",]\/\/g' | sed -e 's\/[[:space:]]*$\/\/')\r\n  avStates=$(grep \"av_state\" \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\" | tr -s \" \" | sed s\/\\\"av_state\\\":\/\/g | sed -e 's\/^[[:space:]]*\/\/' | sed 's\/[\\\",]\/\/g' | sed -e 's\/[[:space:]]*$\/\/')\r\n\r\n  # Find the line number of the existing antivirus entry with the given name\r\n  existingAV=$(echo \"$avNames\" | grep -n \"$_arg_antivirusName\" | sed 's\/:.*\/\/g')\r\n\r\n  # Determine the desired antivirus status\r\n  if [[ -n $_arg_antivirusStatus ]]; then\r\n    desiredStatus=$_arg_antivirusStatus\r\n  elif [[ -n $existingAV ]]; then\r\n    desiredStatus=$(echo \"$avStatuses\" | sed -n \"${existingAV}p\")\r\n  fi\r\n\r\n  # Determine the desired antivirus state\r\n  if [[ -n $_arg_antivirusState ]]; then\r\n    desiredState=$_arg_antivirusState\r\n  elif [[ -n $existingAV ]]; then\r\n    desiredState=$(echo \"$avStates\" | sed -n \"${existingAV}p\")\r\n  fi\r\n\r\n  # Check if both status and state are provided\r\n  if [[ -z $desiredStatus || -z $desiredState ]]; then\r\n    _PRINT_HELP=no die \"[Error] Antivirus state or status are missing from the override entry. Please provide both in addition to the antivirus name!\" 1\r\n  fi\r\n\r\n  # Update the existing antivirus entry if found\r\n  if [[ -n $existingAV ]]; then\r\n    echo \"Attempting to update override.\"\r\n\r\n    # Update antivirus version if provided\r\n    if [[ -n $_arg_antivirusVersion ]]; then\r\n      modified_json=$(awk -v target=\"$existingAV\" -v value=\"$_arg_antivirusVersion\" 'BEGIN { av_count = 1 }\r\n      \/av_version\/ { \r\n        if (av_count == target){ \r\n          sub( \/av_version.*\/ , \"av_version\\\":  \\\"\"value\"\\\",\" ) \r\n        }\r\n        av_count++\r\n      }{ print }' \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\")\r\n\r\n      if echo \"$modified_json\" &gt;\"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\"; then\r\n        echo \"Successfully updated the antivirus version!\"\r\n      else\r\n        echo \"[Error] Failed to update the antivirus version!\" &gt;&amp;2\r\n        exit 1\r\n      fi\r\n    fi\r\n\r\n    # Update antivirus status if provided\r\n    if [[ -n $_arg_antivirusStatus ]]; then\r\n      modified_json=$(awk -v target=\"$existingAV\" -v value=\"$_arg_antivirusStatus\" 'BEGIN { av_count = 1 }\r\n      \/av_status\/ { \r\n        if (av_count == target){ \r\n          sub( \/av_status.*\/ , \"av_status\\\":  \\\"\"value\"\\\",\" ) \r\n        }\r\n        av_count++\r\n      }{print}' \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\")\r\n\r\n      if echo \"$modified_json\" &gt;\"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\"; then\r\n        echo \"Successfully updated the override status!\"\r\n      else\r\n        echo \"[Error] Failed to update the override status!\" &gt;&amp;2\r\n        exit 1\r\n      fi\r\n    fi\r\n\r\n    # Update antivirus state if provided\r\n    if [[ -n $_arg_antivirusState ]]; then\r\n      modified_json=$(awk -v target=\"$existingAV\" -v value=\"$_arg_antivirusState\" 'BEGIN { av_count = 1 }\r\n      \/av_state\/ { \r\n        if (av_count == target){ \r\n          sub( \/av_state.*\/ , \"av_state\\\":  \\\"\"value\"\\\"\" ) \r\n        }\r\n        av_count++\r\n      }{print}' \"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\")\r\n\r\n      if echo \"$modified_json\" &gt;\"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\"; then\r\n        echo \"Successfully updated the override state!\"\r\n      else\r\n        echo \"[Error] Failed to update the override state!\" &gt;&amp;2\r\n        exit 1\r\n      fi\r\n    fi\r\n\r\n    exit\r\n  fi\r\n\r\n  # Print a message indicating that the script is attempting to append an override\r\n  echo \"Attempting to append override.\"\r\n  # Initialize a counter for indexing\r\n  i=1\r\n  # Initialize the JSON structure for antivirus overrides\r\n  avOverrides=\"{\r\n  \\\"av_override\\\": [\r\n\"\r\n  # Loop through each antivirus name\r\n  for avName in $avNames; do\r\n    # Extract the corresponding antivirus version, status and state for the current index\r\n    avVersion=$(echo \"$avVersions\" | sed -n \"${i}p\")\r\n    avStatus=$(echo \"$avStatuses\" | sed -n \"${i}p\")\r\n    avState=$(echo \"$avStates\" | sed -n \"${i}p\")\r\n\r\n    # Append the current antivirus entry to the JSON structure\r\n    avOverrides+=\"    {\r\n      \\\"av_name\\\":  \\\"${avName}\\\",\r\n      \\\"av_version\\\": \\\"${avVersion}\\\",\r\n      \\\"av_status\\\":  \\\"${avStatus}\\\",\r\n      \\\"av_state\\\": \\\"${avState}\\\"\r\n    },\r\n\"\r\n    # Increment the counter for the next iteration\r\n    i=$((i + 1))\r\n  done\r\n\r\n  # Close the JSON structure\r\n  avOverrides+=\"    {\r\n      \\\"av_name\\\":  \\\"${_arg_antivirusName}\\\",\r\n      \\\"av_version\\\": \\\"${_arg_antivirusVersion}\\\",\r\n      \\\"av_status\\\":  \\\"${_arg_antivirusStatus}\\\",\r\n      \\\"av_state\\\": \\\"${_arg_antivirusState}\\\"\r\n    }\r\n  ]\r\n}\r\n\"\r\n\r\n  # Attempt to write the JSON structure containing antivirus overrides to the specified file\r\n  if echo \"$avOverrides\" &gt;\"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\"; then\r\n    echo \"Succesfully added override.\"\r\n    exit\r\n  else\r\n    echo \"[Error] Failed to add override.\" &gt;&amp;2\r\n    exit 1\r\n  fi\r\nfi\r\n\r\n# Check if the antivirus state or status arguments are missing\r\nif [[ -z $_arg_antivirusState || -z $_arg_antivirusStatus ]]; then\r\n  _PRINT_HELP=no die \"[Error] Antivirus name, state and status are required when adding a new override!\" 1\r\nfi\r\n\r\n# Construct the JSON string for the antivirus override\r\nJSON_STRING=\"{\r\n  \\\"av_override\\\": [\r\n    {\r\n      \\\"av_name\\\":  \\\"${_arg_antivirusName}\\\",\r\n      \\\"av_version\\\":  \\\"${_arg_antivirusVersion}\\\",\r\n      \\\"av_status\\\":  \\\"${_arg_antivirusStatus}\\\",\r\n      \\\"av_state\\\":  \\\"${_arg_antivirusState}\\\"\r\n    }\r\n  ]\r\n}\r\n\"\r\n\r\n# Attempt to write the JSON string to the specified file\r\nif echo \"$JSON_STRING\" &gt;\"\/opt\/NinjaRMMAgent\/programdata\/customization\/av_override.json\"; then\r\n  # If the write operation is successful, print a success message\r\n  echo \"Succesfully created override.\"\r\nelse\r\n  # If the write operation fails, print an error message to standard error\r\n  echo \"[Error] Failed to create override.\" &gt;&amp;2\r\n  exit 1\r\nfi\r\n<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Risparmia tempo con gli oltre 300 script del Dojo NinjaOne.<\/p>\n<p>\u2192 <a class=\"waffle-rich-text-link\" href=\"https:\/\/www.ninjaone.com\/it\/prova-gratuita\/\">Accedi oggi stesso<\/a>.<\/p>\n<\/div>\n<h2>Analisi dettagliata dello script per personalizzare le eccezioni antivirus<\/h2>\n<p>Questo script automatizza l&#8217;aggiunta o l&#8217;aggiornamento delle eccezioni antivirus in un file di configurazione basato su JSON. Ecco come funziona passo per passo:<\/p>\n<p><strong>1. Inizializzazione dei parametri<\/strong><\/p>\n<p>a. Lo script per personalizzare le eccezioni antivirus inizia definendo le variabili per il nome dell&#8217;antivirus, la versione, lo stato e la condizione. Vengono inizializzati anche flag come &#8211;removeOverride e &#8211;append per gestire azioni specifiche.<\/p>\n<p><strong>2. Parsing della riga di comando<\/strong><\/p>\n<p>a. La funzione parse_commandline elabora gli argomenti forniti durante l&#8217;esecuzione dello script. Per esempio, &#8211;antivirusName &#8220;MyAntivirus&#8221; imposta il nome dell&#8217;antivirus.<\/p>\n<p><strong>3. Convalida<\/strong><\/p>\n<p>a. Lo script per personalizzare le eccezioni antivirus assicura che i parametri obbligatori siano forniti quando richiesto. Controlla gli stati validi (Aggiornato, Non aggiornato o Sconosciuto) e gli stati (ON, OFF, SCADUTO, SNOOZED o SCONOSCIUTO).<\/p>\n<p><strong>4. Rimozione delle eccezioni<\/strong><\/p>\n<p>a. Se il flag &#8211;removeOverride \u00e8 impostato, lo script cancella il file JSON di override esistente. Se non esiste un file di questo tipo, lo script termina.<\/p>\n<p><strong>5. Aggiunta o aggiornamento delle eccezioni<\/strong><\/p>\n<p>a. Quando si usa il flag &#8211;append, lo script per personalizzare le eccezioni antivirus controlla le voci esistenti nel file JSON. Aggiorna i dettagli di una voce antivirus esistente o ne aggiunge una nuova.<\/p>\n<p><strong>6. Scrittura delle eccezioni<\/strong><\/p>\n<p>a. Se il flag &#8211;append non \u00e8 impostato, lo script per personalizzare le eccezioni antivirus scrive una nuova struttura JSON con i dettagli antivirus specificati. Questa struttura viene salvata in una posizione designata.<\/p>\n<h2>Casi d&#8217;uso potenziali<\/h2>\n<h3>Scenario: un MSP che gestisce i dispositivi dei clienti<\/h3>\n<p>Immagina che un MSP stia monitorando i dispositivi di pi\u00f9 clienti. Un nuovo aggiornamento dell&#8217;antivirus causa ritardi nella sincronizzazione dello stato con lo strumento di monitoraggio. Distribuendo questo script per personalizzare le eccezioni antivirus sui dispositivi interessati, l&#8217;MSP pu\u00f2 temporaneamente annullare lo stato, contrassegnando l&#8217;antivirus come &#8220;aggiornato&#8221; e &#8220;attivo&#8221;, assicurando che i rapporti di conformit\u00e0 rimangano accurati fino alla risoluzione del problema.<\/p>\n<h2>Confronti<\/h2>\n<p>Altri metodi per gestire lo stato dell&#8217;antivirus includono la modifica manuale del file JSON o l&#8217;affidamento a strumenti integrati nelle piattaforme di monitoraggio e gestione remota (RMM). Rispetto alle modifiche manuali, questo script per personalizzare le eccezioni antivirus riduce gli errori umani e velocizza il processo. A differenza degli strumenti specifici per piattaforma, offre flessibilit\u00e0 per gli ambienti Linux in cui tali integrazioni potrebbero non esistere.<\/p>\n<h2>Domande frequenti<\/h2>\n<ul>\n<li><strong>Questo script per personalizzare le eccezioni antivirus pu\u00f2 funzionare con tutti i software antivirus?<\/strong><br \/>\nLo script per personalizzare le eccezioni antivirus non interagisce direttamente con i software antivirus, ma modifica il file JSON che contiene le eccezioni, rendendolo indipendente rispetto alle specifiche soluzioni antivirus.<\/li>\n<li><strong>Cosa succede se lo eseguo senza gli argomenti richiesti?<\/strong><br \/>\nLo script per personalizzare le eccezioni antivirus fornisce messaggi di errore dettagliati e istruzioni d&#8217;uso per guidare la corretta esecuzione.<\/li>\n<li><strong>Come posso annullare le modifiche apportate da questo script per personalizzare le eccezioni antivirus?<\/strong><br \/>\nUsa il flag &#8211;removeOverride per cancellare il file di configurazione dell&#8217;eccezione.<\/li>\n<li><strong>Posso usare questo script per personalizzare le eccezioni antivirus su sistemi non Linux?<\/strong><br \/>\nQuesto script per personalizzare le eccezioni antivirus stato progettato per gli ambienti Linux, in quanto si basa su Bash e sui percorsi dei file di Linux.<\/li>\n<\/ul>\n<h2>Implicazioni<\/h2>\n<p>L&#8217;uso efficace di questo script per personalizzare le eccezioni antivirus garantisce una rappresentazione accurata degli stati antivirus sui vari dispositivi. In questo modo si riducono i falsi positivi o negativi nel monitoraggio della sicurezza, rafforzando la cybersecurity dell&#8217;organizzazione. Tuttavia, l&#8217;uso improprio o l&#8217;impostazione di eccezioni non valide potrebbero portare a discrepanze, e questo sottolinea la necessit\u00e0 di una gestione attenta.<\/p>\n<h2>Raccomandazioni<\/h2>\n<ul>\n<li>Testa sempre lo script per personalizzare le eccezioni antivirus su un dispositivo non di produzione per verificarne il comportamento.<\/li>\n<li>Utilizza convenzioni di denominazione chiare e coerenti per le soluzioni antivirus per evitare conflitti.<\/li>\n<li>Documenta le eccezioni applicate ai dispositivi per riferimento futuro.<\/li>\n<li>Limita l&#8217;accesso a questo script per personalizzare le eccezioni antivirus per evitare modifiche non autorizzate.<\/li>\n<\/ul>\n<h2>Considerazioni finali<\/h2>\n<p>Questo script per personalizzare le eccezioni antivirus \u00e8 un esempio di come l&#8217;automazione migliori l&#8217;<a href=\"https:\/\/www.ninjaone.com\/it\/efficienza-it\">efficienza<\/a> e l&#8217;accuratezza della gestione IT. Per gli utenti di NinjaOne o di piattaforme RMM simili, l&#8217;utilizzo di strumenti come questo script insieme a funzioni avanzate di gestione degli endpoint garantisce una solida postura di sicurezza. NinjaOne semplifica la visibilit\u00e0 e la gestione degli endpoint, fornendo una piattaforma unificata per snellire le operazioni IT e affrontare con precisione problemi come le eccezioni antivirus.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4211],"use_cases":[4272],"class_list":["post-390651","script_hub","type-script_hub","status-publish","hentry","script_hub_category-linux","use_cases-manutenzione"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub\/390651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/comments?post=390651"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/media?parent=390651"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/operating_system?post=390651"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/use_cases?post=390651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}