Skip to content

Commit

Permalink
Major update to support transforms on loggers (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard authored Nov 13, 2022
1 parent ca36e22 commit 43be2d8
Show file tree
Hide file tree
Showing 36 changed files with 401 additions and 223 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*NOTE: The code before version 1.x is considered beta quality and is subject to breaking changes.*

`DNS-collector` acts as a passive high speed **aggregator, analyzer, transporter and logging** for your DNS messages, written in **Golang**. The DNS traffic can be collected and aggregated from simultaneously sources like DNStap streams, network interface or log files
and redirect them to several destinations with some transformation (filtering, sampling, privacy, ...).
and redirect them to several destinations with some transformations on it (filtering, sampling, privacy, ...).
DNS-collector also contains DNS parser with [`EDNS`](doc/dnsparser.md) support.

![overview](doc/overview.png)
Expand Down
2 changes: 1 addition & 1 deletion collectors/dns_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (d *DnsProcessor) Run(sendTo []chan dnsutils.DnsMessage) {
d.LogInfo("dns cached enabled: %t", d.cacheSupport)

// prepare enabled transformers
subprocessors := transformers.NewTransforms(d.config, d.logger, d.name)
subprocessors := transformers.NewTransforms(&d.config.IngoingTransformers, d.logger, d.name)

// read incoming dns message
d.LogInfo("running... waiting incoming dns message")
Expand Down
2 changes: 1 addition & 1 deletion collectors/dnstap_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (d *DnstapProcessor) Run(sendTo []chan dnsutils.DnsMessage) {
d.LogInfo("dns cached enabled: %t", d.config.Collectors.Dnstap.CacheSupport)

// prepare enabled transformers
subprocessors := transformers.NewTransforms(d.config, d.logger, d.name)
subprocessors := transformers.NewTransforms(&d.config.IngoingTransformers, d.logger, d.name)

// read incoming dns message
d.LogInfo("running... waiting incoming dns message")
Expand Down
2 changes: 1 addition & 1 deletion collectors/powerdns_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (d *PdnsProcessor) Run(sendTo []chan dnsutils.DnsMessage) {
pbdm := &powerdns_protobuf.PBDNSMessage{}

// prepare enabled transformers
subprocessors := transformers.NewTransforms(d.config, d.logger, d.name)
subprocessors := transformers.NewTransforms(&d.config.IngoingTransformers, d.logger, d.name)

// read incoming dns message
d.LogInfo("running... waiting incoming dns message")
Expand Down
2 changes: 1 addition & 1 deletion collectors/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *Tail) Run() {
}

// prepare enabled transformers
subprocessors := transformers.NewTransforms(c.config, c.logger, c.name)
subprocessors := transformers.NewTransforms(&c.config.IngoingTransformers, c.logger, c.name)

// init dns message
dm := dnsutils.DnsMessage{}
Expand Down
6 changes: 4 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ multiplexer:
- name: console
stdout:
mode: text
transforms:
normalize:
qname-lowercase: true

routes:
- from: [ tap ]
Expand Down Expand Up @@ -408,8 +411,7 @@ multiplexer:


################################################
# list of transformers
# transforms:
# list of transforms to apply on collectors or loggers
################################################

# # Use this option to protect user privacy
Expand Down
12 changes: 10 additions & 2 deletions dnscollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func main() {
// load config
cfg := make(map[string]interface{})
cfg["loggers"] = output.Params
cfg["outgoing-transformers"] = make(map[string]interface{})
for _, p := range output.Params {
p.(map[string]interface{})["enable"] = true
}
Expand All @@ -76,6 +77,12 @@ func main() {
subcfg := &dnsutils.Config{}
subcfg.SetDefault()

// add transformer
for k, v := range output.Transforms {
v.(map[string]interface{})["enable"] = true
cfg["outgoing-transformers"].(map[string]interface{})[k] = v
}

// copy global config
subcfg.Global = config.Global

Expand Down Expand Up @@ -132,7 +139,7 @@ func main() {
// load config
cfg := make(map[string]interface{})
cfg["collectors"] = input.Params
cfg["transformers"] = make(map[string]interface{})
cfg["ingoing-transformers"] = make(map[string]interface{})
for _, p := range input.Params {
p.(map[string]interface{})["enable"] = true
}
Expand All @@ -144,7 +151,7 @@ func main() {
// add transformer
for k, v := range input.Transforms {
v.(map[string]interface{})["enable"] = true
cfg["transformers"].(map[string]interface{})[k] = v
cfg["ingoing-transformers"].(map[string]interface{})[k] = v
}

// copy global config
Expand Down Expand Up @@ -172,6 +179,7 @@ func main() {
}
}

// here the multiplexer logic
// connect collectors between loggers
for _, routes := range config.Multiplexer.Routes {
var logwrks []dnsutils.Worker
Expand Down
167 changes: 90 additions & 77 deletions dnsutils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ func IsValidTLS(mode string) bool {
return false
}

type MultiplexTransformers struct {
Name string `yaml:"naame"`
Transforms map[string]interface{} `yaml:",inline"`
Params map[string]interface{} `yaml:",inline"`
}

type MultiplexInOut struct {
Name string `yaml:"name"`
Transforms map[string]interface{} `yaml:"transforms"`
Expand All @@ -45,6 +39,81 @@ type MultiplexRoutes struct {
Dst []string `yaml:"to,flow"`
}

type ConfigTransformers struct {
UserPrivacy struct {
Enable bool `yaml:"enable"`
AnonymizeIP bool `yaml:"anonymize-ip"`
MinimazeQname bool `yaml:"minimaze-qname"`
} `yaml:"user-privacy"`
Normalize struct {
Enable bool `yaml:"enable"`
QnameLowerCase bool `yaml:"qname-lowercase"`
} `yaml:"normalize"`
Filtering struct {
Enable bool `yaml:"enable"`
DropFqdnFile string `yaml:"drop-fqdn-file"`
DropDomainFile string `yaml:"drop-domain-file"`
KeepFqdnFile string `yaml:"keep-fqdn-file"`
KeepDomainFile string `yaml:"keep-domain-file"`
DropQueryIpFile string `yaml:"drop-queryip-file"`
KeepQueryIpFile string `yaml:"keep-queryip-file"`
DropRcodes []string `yaml:"drop-rcodes,flow"`
LogQueries bool `yaml:"log-queries"`
LogReplies bool `yaml:"log-replies"`
Downsample int `yaml:"downsample"`
} `yaml:"filtering"`
GeoIP struct {
Enable bool `yaml:"enable"`
DbCountryFile string `yaml:"mmdb-country-file"`
DbCityFile string `yaml:"mmdb-city-file"`
DbAsnFile string `yaml:"mmdb-asn-file"`
} `yaml:"geoip"`
Suspicious struct {
Enable bool `yaml:"enable"`
ThresholdQnameLen int `yaml:"threshold-qname-len"`
ThresholdPacketLen int `yaml:"threshold-packet-len"`
ThresholdSlow float64 `yaml:"threshold-slow"`
CommonQtypes []string `yaml:"common-qtypes,flow"`
UnallowedChars []string `yaml:"unallowed-chars,flow"`
ThresholdMaxLabels int `yaml:"threshold-max-labels"`
} `yaml:"suspicious"`
}

func (c *ConfigTransformers) SetDefault() {
c.Suspicious.Enable = false
c.Suspicious.ThresholdQnameLen = 100
c.Suspicious.ThresholdPacketLen = 1000
c.Suspicious.ThresholdSlow = 1.0
c.Suspicious.CommonQtypes = []string{"A", "AAAA", "TXT", "CNAME", "PTR",
"NAPTR", "DNSKEY", "SRV", "SOA", "NS", "MX", "DS"}
c.Suspicious.UnallowedChars = []string{"\"", "==", "/", ":"}
c.Suspicious.ThresholdMaxLabels = 10

c.UserPrivacy.Enable = false
c.UserPrivacy.AnonymizeIP = false
c.UserPrivacy.MinimazeQname = false

c.Normalize.Enable = false
c.Normalize.QnameLowerCase = false

c.Filtering.Enable = false
c.Filtering.DropFqdnFile = ""
c.Filtering.DropDomainFile = ""
c.Filtering.KeepFqdnFile = ""
c.Filtering.KeepDomainFile = ""
c.Filtering.DropQueryIpFile = ""
c.Filtering.DropRcodes = []string{}
c.Filtering.LogQueries = true
c.Filtering.LogReplies = true
c.Filtering.Downsample = 0

c.GeoIP.Enable = false
c.GeoIP.DbCountryFile = ""
c.GeoIP.DbCityFile = ""
c.GeoIP.DbAsnFile = ""
}

/* main configuration */
type Config struct {
Global struct {
TextFormat string `yaml:"text-format"`
Expand Down Expand Up @@ -108,45 +177,7 @@ type Config struct {
} `yaml:"pcap"`
} `yaml:"collectors"`

Transformers struct {
UserPrivacy struct {
Enable bool `yaml:"enable"`
AnonymizeIP bool `yaml:"anonymize-ip"`
MinimazeQname bool `yaml:"minimaze-qname"`
} `yaml:"user-privacy"`
Normalize struct {
Enable bool `yaml:"enable"`
QnameLowerCase bool `yaml:"qname-lowercase"`
} `yaml:"normalize"`
Filtering struct {
Enable bool `yaml:"enable"`
DropFqdnFile string `yaml:"drop-fqdn-file"`
DropDomainFile string `yaml:"drop-domain-file"`
KeepFqdnFile string `yaml:"keep-fqdn-file"`
KeepDomainFile string `yaml:"keep-domain-file"`
DropQueryIpFile string `yaml:"drop-queryip-file"`
KeepQueryIpFile string `yaml:"keep-queryip-file"`
DropRcodes []string `yaml:"drop-rcodes,flow"`
LogQueries bool `yaml:"log-queries"`
LogReplies bool `yaml:"log-replies"`
Downsample int `yaml:"downsample"`
} `yaml:"filtering"`
GeoIP struct {
Enable bool `yaml:"enable"`
DbCountryFile string `yaml:"mmdb-country-file"`
DbCityFile string `yaml:"mmdb-city-file"`
DbAsnFile string `yaml:"mmdb-asn-file"`
} `yaml:"geoip"`
Suspicious struct {
Enable bool `yaml:"enable"`
ThresholdQnameLen int `yaml:"threshold-qname-len"`
ThresholdPacketLen int `yaml:"threshold-packet-len"`
ThresholdSlow float64 `yaml:"threshold-slow"`
CommonQtypes []string `yaml:"common-qtypes,flow"`
UnallowedChars []string `yaml:"unallowed-chars,flow"`
ThresholdMaxLabels int `yaml:"threshold-max-labels"`
} `yaml:"suspicious"`
} `yaml:"transformers"`
IngoingTransformers ConfigTransformers `yaml:"ingoing-transformers"`

Loggers struct {
Stdout struct {
Expand Down Expand Up @@ -294,6 +325,8 @@ type Config struct {
} `yaml:"elasticsearch"`
} `yaml:"loggers"`

OutgoingTransformers ConfigTransformers `yaml:"outgoing-transformers"`

Multiplexer struct {
Collectors []MultiplexInOut `yaml:"collectors"`
Loggers []MultiplexInOut `yaml:"loggers"`
Expand Down Expand Up @@ -360,38 +393,8 @@ func (c *Config) SetDefault() {
c.Collectors.IngestPcap.DropReplies = false
c.Collectors.IngestPcap.DeleteAfter = false

// Transformers
c.Transformers.Suspicious.Enable = false
c.Transformers.Suspicious.ThresholdQnameLen = 100
c.Transformers.Suspicious.ThresholdPacketLen = 1000
c.Transformers.Suspicious.ThresholdSlow = 1.0
c.Transformers.Suspicious.CommonQtypes = []string{"A", "AAAA", "TXT", "CNAME", "PTR",
"NAPTR", "DNSKEY", "SRV", "SOA", "NS", "MX", "DS"}
c.Transformers.Suspicious.UnallowedChars = []string{"\"", "==", "/", ":"}
c.Transformers.Suspicious.ThresholdMaxLabels = 10

c.Transformers.UserPrivacy.Enable = false
c.Transformers.UserPrivacy.AnonymizeIP = false
c.Transformers.UserPrivacy.MinimazeQname = false

c.Transformers.Normalize.Enable = false
c.Transformers.Normalize.QnameLowerCase = false

c.Transformers.Filtering.Enable = false
c.Transformers.Filtering.DropFqdnFile = ""
c.Transformers.Filtering.DropDomainFile = ""
c.Transformers.Filtering.KeepFqdnFile = ""
c.Transformers.Filtering.KeepDomainFile = ""
c.Transformers.Filtering.DropQueryIpFile = ""
c.Transformers.Filtering.DropRcodes = []string{}
c.Transformers.Filtering.LogQueries = true
c.Transformers.Filtering.LogReplies = true
c.Transformers.Filtering.Downsample = 0

c.Transformers.GeoIP.Enable = false
c.Transformers.GeoIP.DbCountryFile = ""
c.Transformers.GeoIP.DbCityFile = ""
c.Transformers.GeoIP.DbAsnFile = ""
// Transformers for collectors
c.IngoingTransformers.SetDefault()

// Loggers
c.Loggers.Stdout.Enable = false
Expand Down Expand Up @@ -523,6 +526,10 @@ func (c *Config) SetDefault() {

c.Loggers.ElasticSearchClient.Enable = false
c.Loggers.ElasticSearchClient.URL = ""

// Transformers for loggers
c.OutgoingTransformers.SetDefault()

}

func (c *Config) GetServerIdentity() string {
Expand Down Expand Up @@ -583,3 +590,9 @@ func GetFakeConfig() *Config {
config.SetDefault()
return config
}

func GetFakeConfigTransformers() *ConfigTransformers {
config := &ConfigTransformers{}
config.SetDefault()
return config
}
2 changes: 1 addition & 1 deletion doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ multiplexer:
```
## Transformers

Some transformations can be done after the collect.
Some transformations can be done on collectors or loggers.

### Normalize

Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion doc/overview.drawio
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile host="app.diagrams.net" modified="2022-06-22T18:06:44.738Z" agent="5.0 (X11)" etag="TcZ8aJD9gEtu3iOVryzu" version="20.0.1" type="device"><diagram id="ufO1G3qEnvI_ADMoatvI" name="Page-1">5Vxte5o6GP41fpQLkhDCR61tt562607Xres3KlHZkDjEqfv1J1RQTAJiBdEze1294OHh7c79vCbaghfjxXXoTEZ3zKV+C+juogV7LQBsYvD/sWC5EpgGWgmGoeeuRMZG8Oj9oYlQT6Qzz6XTLcWIMT/yJtvCPgsC2o+2ZE4Ysvm22oD523edOEMqCR77ji9Lv3luNFpJialv5B+oNxyldzb05MjYSZUTwXTkuGyeEcHLFrwIGYtWW+PFBfVj7FJcVudd5RxdP1hIg6jMCd0/5pcxmL5Onr/dB8TpXP+wL9rJVX47/ix54eRho2WKQMhmgUvji+gt2J2PvIg+Tpx+fHTOh5zLRtHY53sG35xGIftJL5jPQi4JWMDVugPP91NRC8CBGf/FchZEGfnqw+Xym6WPScOILjKi5E2vKRvTKFxyleQoQAnqS2F/vhlEM+XYKDOAwE6ETkKc4fraG2z5RgLvHlDDfaA2dkMtoOo6lAz6eUPghP3EtvSKAMb2NsAm0EwJYkMJMbZS1cpBRgqQsc9v3H3lG8N4gyPjc0/Bwml6iN9pfVQaE45HtCfHU8x9bxjw3T5HmXJ5N0bX466lkxwYe64b30Y50ttmV8GIQR2VGDGkGrC6TMKs1yQGgwHoH88ksCH4HNPSgMIm4JFtAu+2iVs2HNK/zSCwCTXLLDNkRzUKSxouN5hGHILqA3MVcYBgTcCQyABaa1eThRDWxXgiQfgYOZE35WSbniaMGCENEgFHfU3PLJQKLkJ7zdrKsbQlLLmzuPI4eucCJLKIZpcDEhmaXheQhpxr3/ELnxMloWUeGUmzjV7neG68fOiPL5/w89eegdrpU2UQoy6v2pJdFkYjNmSB419upEL42OjcMjZJkPxBo2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XJ1ixtFd22okygdtpaWLN127YRBpjYRlLbbiZOSMn0c+9paETEpZfISJmcOxdd4qRdE9L8hYHYQsT12Yt6VrolV+uHFNAtdWGsYGhurWxAJOKSKYsztTJRrT6soBNXtEajuK3xwOY07N0/lm5suMHU9abRcZobVYwNkMeGwGZHZq+F+41RGEJ5nvKoMAEJpqfgNcalebRkUuV0x44KmLz2vXmkoBgUoaaTZmGSZ5i63kmQahsqpDfsptI67G9LTfddDqYET9GNym8x1FBR8WRPWGVrG5ph2puPQJuKclMgLMVE2y3cffV3ZqQ8g4V7vWfN6an85ZnmHYsc2xFu3g3Lq+gOXsRVT2hHVtOOWObQWa2s2dehHrTUhlThUPf1eqa130SXpF/UzZfPFpeVk3e2XrEZL7GVGm3rlNaW1tDW7D0NeAJMr2rG4S+gPSmclNqpD41DaC9NFFRDewRMTYcIEWCZBAP9uPkDlNs2j17w88BvOVYQGC1b8A6Q51kwsy684XYXVHVVMu2rDHb41yz+2Zi3X1BpT9+8QocrGMZksWpkJcfF1lasf9CF3GDa7qc/oFHYQlvd6qQ7ayIhEODhouEOCGqkZD3iV4/U1FcsCqwlSBxmoHJ76mIW+ifHY0AMzUKZAlL+aupxOd3IKoymOY1ASU4bx/o+XeFjZkj9EMbXHtHZCcZsy9Lshst+1Mzatmq6iudSBB9sFO8qB7Curkvzv18i6Nu4WD91hWr9/2HVzHc3P3G4Ut/8TiS8/A8=</diagram></mxfile>
<mxfile host="app.diagrams.net" modified="2022-11-13T06:31:27.699Z" agent="5.0 (X11)" etag="XESKpodHZSGLUGk0bACG" version="20.0.2" type="device"><diagram id="ufO1G3qEnvI_ADMoatvI" name="Page-1">7Vxte5o6GP41XtfOB7mAhAAftbbdetquXdut6zcqUdmQOMSq+/UnKCgk4cUKottxH0aehLc79/NK0hY4Gy8ufWsyuiE2dluqbC9aoNdSVUUxNPpfKFmuJUhV1oKh79jRoK3gwfmNI6EcSWeOjaepgQEhbuBM0sI+8TzcD1Iyy/fJPD1sQNz0XSfWEH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fSo3uLDne+8WX3KcDpNMo1k/8kt+pZ5P9awua4zmeJi1/CO9W2cRxCYmEwnARST0TxTUM1HAr9QxZJaIemP4vv13os03utnhPa7MqeRvaXh4C7CZLIw9q8aFI3Xc5atFboIyO7q3MlF6JlrejWjLv+QtxnlFFbvC3bp0VyRszTCXXqVbH8Q2hpRef+oXNO7HeypOCBuw5EBN1FWUx4orq//gbQ4qrf4QMlG897V5oG/LvLiiB+vXmyM9QXLKJrnyx9vDNlo/CiM4Z+bhJ4sLRo3FQWbyf7nxMHdR62JO21u/37dOnnZ/hVAcP4f</diagram></mxfile>
Binary file modified doc/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions loggers/dnstap.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/dmachard/go-dnscollector/dnsutils"
"github.com/dmachard/go-dnscollector/transformers"
"github.com/dmachard/go-dnstap-protobuf"
"github.com/dmachard/go-framestream"
"github.com/dmachard/go-logger"
Expand Down Expand Up @@ -83,6 +84,9 @@ func (o *DnstapSender) Stop() {
func (o *DnstapSender) Run() {
o.LogInfo("running in background...")

// prepare transforms
subprocessors := transformers.NewTransforms(&o.config.OutgoingTransformers, o.logger, o.name)

dt := &dnstap.Dnstap{}
frame := &framestream.Frame{}

Expand Down Expand Up @@ -147,6 +151,11 @@ LOOP:
select {
case dm := <-o.channel:

// apply tranforms
if subprocessors.ProcessMessage(&dm) == transformers.RETURN_DROP {
continue
}

dt.Reset()

t := dnstap.Dnstap_MESSAGE
Expand Down Expand Up @@ -240,6 +249,11 @@ LOOP:
o.LogInfo("closing tcp connection")
o.conn.Close()
}

o.LogInfo("run terminated")

// cleanup transformers
subprocessors.Reset()

o.done <- true
}
Loading

0 comments on commit 43be2d8

Please sign in to comment.