{
    "code_name": "nmap_scan",
    "unique_prefix": "NMAP",
    "enabled": true,    
    "data_source":  "script",
    "data_filters": [
        {
            "compare_column" : "ForeignKey",
            "compare_operator" : "==",
            "compare_field_id": "txtMacFilter",
            "compare_js_template": "'{value}.toString()'", 
            "compare_use_quotes": true 
        }
    ],
    "show_ui": true,
    "localized": ["display_name", "description", "icon"],
    "display_name" : [{
        "language_code":"en_us",
        "string" : "Services & Ports (NMAP)"
    },
    {
        "language_code":"es_es",
        "string" : "Servicios & Puertos (NMAP)"
    }],
    "icon":[{
        "language_code":"en_us",
        "string" : "<i class=\"fa-solid fa-satellite-dish\"></i>"
    },
	{
        "language_code":"es_es",
        "string" : "<i class=\"fa-solid fa-satellite-dish\"></i>"
    }],     
    "description": [{
        "language_code":"en_us",
        "string" : "This plugin shows all services discovered by NMAP scans."
    },
	{
        "language_code":"es_es",
        "string" : "Este complemento muestra todos los servicios descubiertos por escaneos NMAP."
    }],
    "params" : [
        {
            "name"              : "ips",
            "type"              : "sql",
            "value"             : "SELECT dev_LastIP from DEVICES",
            "timeoutMultiplier" : true
        },
        {
            "name"              : "macs",
            "type"              : "sql",
            "value"             : "SELECT dev_MAC from DEVICES"            
        },
        {
            "name"              : "timeout",
            "type"              : "setting",
            "value"             : "NMAP_RUN_TIMEOUT"
        },
        {
            "name"              : "args",
            "type"              : "setting",
            "value"             : "NMAP_ARGS",
            "base64"            : true
        }
    ],  
    "database_column_definitions":
    [          
        {
            "column": "Index",
            "css_classes": "col-sm-2",
            "show": false,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "N/A"
                }]
        } ,
        {
            "column": "Plugin",
            "css_classes": "col-sm-2",
            "show": false,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "N/A"
                }]
        },
        {
            "column": "Object_PrimaryID",
            "css_classes": "col-sm-2",
            "show": true,
            "type": "device_name_mac",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "Device name"
                },
		        {
                "language_code":"es_es",
                "string" : "Nombre del dispositivo"
                }]
        },
        {
            "column": "Object_SecondaryID",
            "css_classes": "col-sm-2",
            "show": true,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "Port"
                },
	   	        {
                "language_code":"es_es",
                "string" : "Puerto"
                }]
        } ,
        {
            "column": "DateTimeCreated",
            "css_classes": "col-sm-2",
            "show": true,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "Created"
                },
	    	    {
                "language_code":"es_es",
                "string" : "Creado"
                }]
        },
        {
            "column": "DateTimeChanged",
            "css_classes": "col-sm-2",
            "show": false,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "Changed"
                },
	    	    {
                "language_code":"es_es",
                "string" : "Cambiado"
                }]
        },
        {
            "column": "Watched_Value1",
            "css_classes": "col-sm-1",
            "show": true,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "State"
                },
	    	    {
                "language_code":"es_es",
                "string" : "Estado"
                }]
        },
        {
            "column": "Watched_Value2",
            "css_classes": "col-sm-1",
            "show": true,
            "type": "label",            
            "default_value":"",
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "Service"
                },
                {
                "language_code":"es_es",
                "string" : "Servicio"
                }]
        },        
        {
            "column": "Watched_Value3",
            "css_classes": "col-sm-1",
            "show": true,
            "type": "regex.url_http_https",            
            "default_value":"",
            "options": [
                {
                    "type": "regex",
                    "param": "([\\d.:]+)"
                }          
            ],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "HTTP/s links"
                },
	    	    {
                "language_code":"es_es",
                "string" : "Enlaces HTTP/s"
                }]
        } ,
        {
            "column": "Watched_Value4",
            "css_classes": "col-sm-2",
            "show": false,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "N/A"
                },
	    	    {
                "language_code":"es_es",
                "string" : "N/A"
                }]
        } ,       
        {
            "column": "Extra",
            "css_classes": "col-sm-1",
            "show": false,
            "type": "label",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "Extra"
                },
	    	    {
                "language_code":"es_es",
                "string" : "Extra"
                }]
        },       
        {
            "column": "UserData",
            "css_classes": "col-sm-3",
            "show": true,
            "type": "textbox_save",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "User data"
                },
	    	    {
                "language_code":"es_es",
                "string" : "Datos de usuario"
                }]
        },       
        {
            "column": "ForeignKey",
            "css_classes": "col-sm-2",
            "show": false,
            "type": "device_mac",            
            "default_value":"",
            "options": [],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "MAC"
                },
	    	{
                "language_code":"es_es",
                "string" : "MAC"
                }]
        },        
        {
            "column": "Status",
            "css_classes": "col-sm-1",
            "show": true,
            "type": "replace",            
            "default_value":"",
            "options": [
                {
                    "equals": "watched-not-changed",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-square-check'></i><div></div>"
                },
                {
                    "equals": "watched-changed",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-triangle-exclamation'></i></div>"
                },
                {
                    "equals": "new",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-circle-plus'></i></div>"
                },
                {
                    "equals": "missing-in-last-scan",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-question'></i></div>"
                }
            ],
            "localized": ["name"],
            "name":[{
                "language_code":"en_us",
                "string" : "Status"
                },
				{
                "language_code":"es_es",
                "string" : "Estado"
                }]
        }            
    ],
    "settings":[
    {
        "function": "RUN",            
        "type": "text.select",            
        "default_value":"disabled",
        "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"],
        "localized": ["name", "description"],
        "name" :[{
            "language_code":"en_us",
            "string" : "When to run"
        },
        {
            "language_code":"es_es",
            "string" : "Cuando ejecutar"
        }],
        "description": [{
            "language_code":"en_us",
            "string" : "Enable a regular Nmap scan on your network on all devices. The scheduling settings can be found below. If you select <code>once</code> Nmap is run only once on start for the time specified in <a href=\"#NMAP_TIMEOUT\"><code>NMAP_TIMEOUT</code> setting</a>."
        },
        {
            "language_code":"es_es",
            "string" : "Habilite un escaneo regular de Nmap en su red en todos los dispositivos. Los ajustes de programación se pueden encontrar a continuación. Si selecciona <code>una vez</code>, Nmap se ejecuta solo una vez al inicio durante el tiempo especificado en la configuración de <a href=\"#NMAP_TIMEOUT\"><code>NMAP_TIMEOUT</code></a>"
        }]
    },
    {
        "function": "CMD",
        "type": "text",
        "default_value":"python3 /home/pi/pialert/front/plugins/nmap_scan/script.py ips={ips} macs={macs} timeout={timeout} args={args}",
        "options": [],
        "localized": ["name", "description"],
        "name" : [{
            "language_code":"en_us",
            "string" : "SQL to run"
        },
        {
            "language_code":"es_es",
            "string" : "Consulta SQL"
        }],
        "description": [{
            "language_code":"en_us",
            "string" : "This calls the script responsible for executing the NMAP scan."
        },
	{
            "language_code":"es_es",
            "string" : "Esto llama al script responsable de ejecutar el escaneo NMAP."
        }		
        ]
    },
    {
        "function": "ARGS",
        "type": "text",
        "default_value":"-p -10000",
        "options": [],
        "localized": ["name", "description"],
        "name" : [{
            "language_code":"en_us",
            "string" : "Arguments"
        },
        {
            "language_code":"es_es",
            "string" : "Argumentos"
        }],
        "description": [
            {
                "language_code":"en_us",
                "string" : "Arguments used to run the Nmap scan. Be careful to specify <a href=\"https://linux.die.net/man/1/nmap\" target=\"_blank\">the arguments</a> correctly. For example <code>-p -10000</code> scans ports from 1 to 10000."
            },
            {
                "language_code":"es_es",
                "string" : "Argumentos utilizados para ejecutar el análisis de Nmap. Tenga cuidado de especificar <a href=\"https://linux.die.net/man/1/nmap\" target=\"_blank\">los argumentos</a> correctamente. Por ejemplo, <code>-p -10000</code> escanea los puertos del 1 al 10000."
            }
        ]
    },
    {
        "function": "RUN_SCHD",
        "type": "text",
        "default_value":"0 2 * * *",
        "options": [],
        "localized": ["name", "description"],
        "name" : [{
            "language_code":"en_us",
            "string" : "Schedule"
        },
        {
            "language_code":"es_es",
            "string" : "Schedule"
        }],
        "description": [{
            "language_code":"en_us",
            "string" : "Only enabled if you select <code>schedule</code> in the <a href=\"#NMAP_RUN\"><code>NMAP_RUN</code> setting</a>. Make sure you enter the schedule in the correct cron-like format."
        },
        {
            "language_code":"es_es",
            "string" : "Solo está habilitado si selecciona <code>programar</code> en la configuración de <a href=\"#NMAP_RUN\"><code>NMAP_RUN</code></a>. Asegúrese de ingresar el cronograma en el formato tipo cron correcto."
        }]
    },
    {
        "function": "RUN_TIMEOUT",
        "type": "integer",
        "default_value": 30,
        "options": [],
        "localized": ["name", "description"],
        "name": [
            {
            "language_code": "en_us",
            "string": "Run timeout"
            },
            {
            "language_code": "es_es",
            "string": "Tiempo límite de ejecución"
            }		
        ],
        "description": [
            {
            "language_code": "en_us",
            "string": "Max run time per device in seconds."
            },
            {
            "language_code": "es_es",
            "string": "Tiempo máximo de ejecución por dispositivo en segundos."
            }		
        ]
        },
        {
            "function": "WATCH",
            "type": "text.multiselect",
            "default_value":["Watched_Value1"],
            "options": ["Watched_Value1","Watched_Value2","Watched_Value3","Watched_Value4"],
            "localized": ["name", "description"],
            "name" :[{
                "language_code":"en_us",
                "string" : "Watched"
            },
            {
                "language_code":"es_es",
                "string" : "Visto"
            }] ,
            "description":[{
                "language_code":"en_us",
                "string" : "Send a notification if selected values change. Use <code>CTRL + Click</code> to select/deselect. <ul> <li><code>Watched_Value1</code> is service type (e.g.: http, ssh)</li><li><code>Watched_Value2</code> is Status (open or closed)</li><li><code>Watched_Value3</code> unused </li><li><code>Watched_Value4</code> unused </li></ul>"
            },
            {
                "language_code":"es_es",
                "string" : "Envíe una notificación si los valores seleccionados cambian. Utilice <code>CTRL + clic</code> para seleccionar/deseleccionar. <ul> <li><code>Watched_Value1</code> es el tipo de servicio (p. ej., http, ssh)</li><li><code>Watched_Value2</code> es el estado (abierto o cerrado)</li> <li><code>Watched_Value3</code> no utilizado </li><li><code>Watched_Value4</code> no utilizado </li></ul>"
            }] 
        },
        {
            "function": "REPORT_ON",
            "type": "text.multiselect",
            "default_value":["new","watched-changed"],
            "options": ["new","watched-changed","watched-not-changed"],
            "localized": ["name", "description"],
            "name" :[{
                "language_code":"en_us",
                "string" : "Report on"
            },
            {
                "language_code":"es_es",
                "string" : "Informar sobre"
            }] ,
            "description":[{
                "language_code":"en_us",
                "string" : "Send a notification only on these statuses. <code>new</code> means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. <code>watched-changed</code> means that selected <code>Watched_ValueN</code> columns changed."
            },
            {
                "language_code":"es_es",
                "string" : "Envíe una notificación solo en estos estados. <code>new</code> significa que se descubrió un nuevo objeto único (combinación única de PrimaryId y SecondaryId). <code>watched-changed</code> significa que seleccionó <code>Watched_ValueN Las columnas </code> cambiaron."
            }] 
        }
    ]
}
