projectdiscovery / nuclei

Nuclei is a fast, customizable vulnerability scanner powered by the global security community and built on a simple YAML-based DSL, enabling collaboration to tackle trending vulnerabilities on the internet. It helps you find vulnerabilities in your applications, APIs, networks, DNS, and cloud configurations.
https://docs.projectdiscovery.io/tools/nuclei
MIT License
20.58k stars 2.5k forks source link

IP is not optional when Host is informed. validate:"required_without=IP" doesn't work #4927

Open jacksoncastilho opened 7 months ago

jacksoncastilho commented 7 months ago

I'm trying reporting Nuclei output to elasticsearch, but the following error occurred. The IP should be optional if the Host is informed

elasticsearch.go (lines: 24 and 26)

21  // Options contains necessary options required for elasticsearch communication
22  type Options struct {
23      // Host is the hostname of the elasticsearch instance
24      Host string yaml:"host" validate:"required_without=IP"
25      // IP for elasticsearch instance
26      IP string yaml:"ip" validate:"required,ip"

issue-tracker-config.yaml

# elasticsearch contains configuration options for elasticsearch exporter
elasticsearch:
# Host is the hostname of the elasticsearch instance
  host: example.com
# IP for elasticsearch instance
  #ip: 127.0.0.1
# Port is the port of elasticsearch instance
  port: 9200
# IndexName is the name of the elasticsearch index
  index-name: nuclei
# SSL enables ssl for elasticsearch connection
  ssl: true 
# SSLVerification disables SSL verification for elasticsearch
  ssl-verification: false
# Username for the elasticsearch instance
  username: elastic                                                                                                    
# Password is the password for elasticsearch instance
  password: changeme

Terminal

➜  ~ nuclei -u example-target.com -rc issue-tracker-config.yaml           

                     __     _
   ____  __  _______/ /__  (_)
  / __ \/ / / / ___/ / _ \/ /
 / / / / /_/ / /__/ /  __/ /
/_/ /_/\__,_/\___/_/\___/_/   v3.2.2

                projectdiscovery.io

[FTL] Could not create runner: could not parse reporting config file: validation failed for these fields: Options.ElasticsearchExporter.IP: required
jacksoncastilho commented 7 months ago

But if I enter the IP, It works