From 473387b2551341e2ce29f9009432d63b9b403af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerry=20Lundstr=C3=B6m?= Date: Wed, 5 Dec 2018 17:31:10 +0100 Subject: [PATCH] LGTM, README, packages, scan-build - Add LGTM and fix alerts - `README.md`: Update dependencies and install instructions - Remove `ports/dsc-collector` as we don't maintain it - Add GeoIP to packages - Update `pcap-thread` to v4.0.0 - Update `pcap_layers` with fixes for `scan-build` warnings - Fix `scan-build` warnings --- .lgtm.yml | 14 +++++++++ Makefile.am | 2 +- README.md | 56 +++++++++++++++++++++++++++-------- debian/control | 2 +- ports/dsc-collector/Makefile | 25 ---------------- ports/dsc-collector/distinfo | 3 -- ports/dsc-collector/pkg-descr | 13 -------- rpm/dsc.spec | 1 + src/config_hooks.c | 7 +++-- src/dns_message.c | 4 +-- src/dns_protocol.c | 2 +- src/ext/base64.c | 4 +-- src/pcap-thread | 2 +- src/pcap.c | 4 +-- src/pcap_layers | 2 +- 15 files changed, 73 insertions(+), 68 deletions(-) create mode 100644 .lgtm.yml delete mode 100644 ports/dsc-collector/Makefile delete mode 100644 ports/dsc-collector/distinfo delete mode 100644 ports/dsc-collector/pkg-descr diff --git a/.lgtm.yml b/.lgtm.yml new file mode 100644 index 00000000..ca3df969 --- /dev/null +++ b/.lgtm.yml @@ -0,0 +1,14 @@ +extraction: + cpp: + prepare: + packages: + - build-essential + - automake + - autoconf + - libtool + - libpcap-dev + - libgeoip-dev + configure: + command: + - ./autogen.sh + - ./configure diff --git a/Makefile.am b/Makefile.am index ff2a73e7..395541ec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,6 +8,6 @@ SUBDIRS = src cron dist_doc_DATA = README.md CHANGES LICENSE UPGRADE.md -EXTRA_DIST = m4 doc ports autogen.sh .clang-format fmt.sh +EXTRA_DIST = m4 doc autogen.sh .clang-format fmt.sh test: check diff --git a/README.md b/README.md index c889c96e..f97aa6cb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DNS Statistics Collector -[![Build Status](https://travis-ci.org/DNS-OARC/dsc.svg?branch=develop)](https://travis-ci.org/DNS-OARC/dsc) [![Coverity Scan Build Status](https://scan.coverity.com/projects/8773/badge.svg)](https://scan.coverity.com/projects/dns-oarc-dsc) +[![Build Status](https://travis-ci.org/DNS-OARC/dsc.svg?branch=develop)](https://travis-ci.org/DNS-OARC/dsc) [![Coverity Scan Build Status](https://scan.coverity.com/projects/8773/badge.svg)](https://scan.coverity.com/projects/dns-oarc-dsc) [![Total alerts](https://img.shields.io/lgtm/alerts/g/DNS-OARC/dsc.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/DNS-OARC/dsc/alerts/) DNS Statistics Collector (DSC) is a tool used for collecting and exploring statistics from busy DNS servers. It uses a distributed architecture with @@ -21,37 +21,67 @@ Issues should be reported here: Mailinglist: - https://lists.dns-oarc.net/mailman/listinfo/dsc -# Install +## Dependencies -Following build tools are needed, example for Debian/Ubuntu. +`dsc` requires a couple of libraries beside a normal C compiling +environment with autoconf, automake and libtool. +`dsc` has a non-optional dependency on the PCAP library and optional +dependency on the GeoIP library (for the `asn` and `country` indexer). + +To install the dependencies under Debian/Ubuntu: +``` +apt-get install -y libpcap-dev libproc-pid-file-perl +``` + +To install the dependencies under CentOS (with EPEL enabled): ``` -sudo apt-get install build-essential automake autoconf +yum install -y libpcap-devel perl-Proc-PID-File ``` -Following dependencies are needed, example for Debian/Ubuntu. +To install the dependencies under FreeBSD 10+ using `pkg`: +``` +pkg install -y libpcap p5-Proc-PID-File +``` +To install the dependencies under OpenBSD 5+ using `pkg_add`: ``` -sudo apt-get install libpcap-dev libproc-pid-file-perl +pkg_add p5-Proc-PID-File ``` -If you are installing from the GitHub repository you need to initialize the -submodule first and generate configure. +NOTE: It is recommended to install the PCAP library from source/ports on +OpenBSD since the bundled version is an older and modified version. + +## Building from source tarball + +The source tarball from DNS-OARC comes prepared with `configure`: ``` -git submodule update --init -./autogen.sh +tar zxvf dsc-version.tar.gz +cd dsc-version +./configure [options] +make +make install ``` -Now you can compile with optional options and install. +## Building from Git repository + +If you are building `dsc` from it's Git repository you will first need +to initiate the Git submodules that exists and later create autoconf/automake +files, this will require a build environment with autoconf, automake and +libtool to be installed. ``` -./configure [options ... ] +git clone https://github.com/DNS-OARC/dsc.git +cd dsc +git submodule update --init +./autogen.sh +./configure [options] make make install ``` -# Puppet +## Puppet John Bond at ICANN DNS Engineering team has developed a puppet module for DSC, the module and code can be found here: diff --git a/debian/control b/debian/control index e4c93545..885ddc2a 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: net Priority: optional Maintainer: Jerry Lundström Build-Depends: debhelper (>= 8.0.0), build-essential, automake, autoconf, - libpcap-dev, libproc-pid-file-perl, netbase + libpcap-dev, libproc-pid-file-perl, netbase, libgeoip-dev Standards-Version: 3.9.4 Homepage: https://www.dns-oarc.net/oarc/data/dsc Vcs-Git: https://github.com/DNS-OARC/dsc.git diff --git a/ports/dsc-collector/Makefile b/ports/dsc-collector/Makefile deleted file mode 100644 index e86e018f..00000000 --- a/ports/dsc-collector/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# New ports collection makefile for: dnstop -# Date created: 31 October 2002 -# Whom: fenner -# -# $FreeBSD: ports/dns/dnstop/Makefile,v 1.19 2009/02/01 06:42:44 beech Exp $ - -PORTNAME= dsc -PKGNAMESUFFIX= -collector -PORTVERSION= 200910191526 -CATEGORIES= dns -MASTER_SITES= http://dns.measurement-factory.com/tools/dsc/download/ - -MAINTAINER= wessels@dns-oarc.net -COMMENT= Captures and analyzes DNS traffic - -BUILD_DEPENDS= ${SITE_PERL}/Proc/PID/File.pm:${PORTSDIR}/devel/p5-Proc-PID-File - - -#GNU_CONFIGURE= yes -WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}/collector - -post-install: - ${INSTALL_SCRIPT} ${WRKSRC}/dsc/dsc.sh ${PREFIX}/etc/rc.d/dsc - -.include diff --git a/ports/dsc-collector/distinfo b/ports/dsc-collector/distinfo deleted file mode 100644 index d4fc2215..00000000 --- a/ports/dsc-collector/distinfo +++ /dev/null @@ -1,3 +0,0 @@ -MD5 (dsc-200910191526.tar.gz) = 9fb238701d2c6b53cf0df0c35fa4e7fd -SHA256 (dsc-200910191526.tar.gz) = 933dc533e84997edbc3b74683cd46aa3ad54490c03888c04e36a9c978086f653 -SIZE (dsc-200910191526.tar.gz) = 1237484 diff --git a/ports/dsc-collector/pkg-descr b/ports/dsc-collector/pkg-descr deleted file mode 100644 index 35239a86..00000000 --- a/ports/dsc-collector/pkg-descr +++ /dev/null @@ -1,13 +0,0 @@ -dsc is a system for collecting and exploring statistics from busy -DNS servers. It currently has two major components: collector and -presenter - -The collector process uses libpcap to receive DNS messages sent and -received on a network interface. It may run on the same machine -as the DNS server, or on another system connected to a switch -configured with port mirroring. A configuration file defines some -number of datasets and other options. Datasets are dumped to disk -every 60 seconds as XML files. A cron job copies the XML files to -a separate server for archiving and further processing. - -WWW: http://dns.measurement-factory.com/tools/dsc/ diff --git a/rpm/dsc.spec b/rpm/dsc.spec index 84c2f613..bc04ca4d 100644 --- a/rpm/dsc.spec +++ b/rpm/dsc.spec @@ -11,6 +11,7 @@ URL: https://www.dns-oarc.net/oarc/data/dsc Source0: %{name}_%{version}.orig.tar.gz BuildRequires: libpcap-devel +BuildRequires: GeoIP-devel BuildRequires: perl BuildRequires: perl(Proc::PID::File) BuildRequires: autoconf diff --git a/src/config_hooks.c b/src/config_hooks.c index ad642e45..224396b5 100644 --- a/src/config_hooks.c +++ b/src/config_hooks.c @@ -73,6 +73,9 @@ int no_wait_interval = 0; int pt_timeout = 100; int drop_ip_fragments = 0; +extern int ip_local_address(const char*, const char*); +extern void pcap_set_match_vlan(int); + int open_interface(const char* interface) { dsyslogf(LOG_INFO, "Opening interface %s", interface); @@ -94,7 +97,6 @@ int set_bpf_program(const char* s) int add_local_address(const char* s, const char* m) { - extern int ip_local_address(const char*, const char*); dsyslogf(LOG_INFO, "adding local address %s%s%s", s, m ? " mask " : "", m ? m : ""); return ip_local_address(s, m); } @@ -202,8 +204,7 @@ int set_bpf_vlan_tag_byte_order(const char* which) int set_match_vlan(const char* s) { - extern void pcap_set_match_vlan(int); - int i; + int i; dsyslogf(LOG_INFO, "match_vlan %s", s); i = atoi(s); if (0 == i && 0 != strcmp(s, "0")) diff --git a/src/dns_message.c b/src/dns_message.c index 1282b883..55f5efd4 100644 --- a/src/dns_message.c +++ b/src/dns_message.c @@ -369,7 +369,7 @@ int add_qname_filter(const char* name, const char* pat) regerror(x, r, errbuf, 512); dsyslogf(LOG_ERR, "regcomp: %s", errbuf); } - fl = md_array_filter_list_append(fl, md_array_create_filter(name, qname_filter, r)); + (void)md_array_filter_list_append(fl, md_array_create_filter(name, qname_filter, r)); return 1; } @@ -495,5 +495,5 @@ void dns_message_init(void) fl = md_array_filter_list_append(fl, md_array_create_filter("chaos-class", chaos_class_filter, 0)); fl = md_array_filter_list_append(fl, md_array_create_filter("priming-query", priming_query_filter, 0)); fl = md_array_filter_list_append(fl, md_array_create_filter("servfail-only", servfail_filter, 0)); - fl = md_array_filter_list_append(fl, md_array_create_filter("authentic-data-only", ad_filter, 0)); + (void)md_array_filter_list_append(fl, md_array_create_filter("authentic-data-only", ad_filter, 0)); } diff --git a/src/dns_protocol.c b/src/dns_protocol.c index ff6aba42..ac0ebf8e 100644 --- a/src/dns_protocol.c +++ b/src/dns_protocol.c @@ -128,7 +128,7 @@ grok_question(const u_char* buf, int len, off_t offset, char* qname, unsigned sh if (0 != x) return 0; if ('\0' == *qname) { - *qname = '.'; + *qname = '.'; *(qname + 1) = 0; } /* XXX remove special characters from QNAME */ diff --git a/src/ext/base64.c b/src/ext/base64.c index 9b0c9a04..4638e5b3 100644 --- a/src/ext/base64.c +++ b/src/ext/base64.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan + * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -61,7 +61,7 @@ base64_encode(const void *data, int size, char **str) if (p == NULL) return -1; q = (const unsigned char *) data; - i = 0; + // i = 0; for (i = 0; i < size;) { c = q[i++]; c *= 256; diff --git a/src/pcap-thread b/src/pcap-thread index 30237827..9b6d7c61 160000 --- a/src/pcap-thread +++ b/src/pcap-thread @@ -1 +1 @@ -Subproject commit 30237827117187554be29135d075c0aa6c80040a +Subproject commit 9b6d7c612992337716bafbe1ceab0d7af7a1f91e diff --git a/src/pcap.c b/src/pcap.c index 199bbfa0..32ed06aa 100644 --- a/src/pcap.c +++ b/src/pcap.c @@ -579,7 +579,7 @@ pcap_tcp_handler(const struct tcphdr* tcp, int len, void* udata) if (debug_flag > 1) { char* p = label; - *p = 0; + *p = 0; inXaddr_ntop(&key.src_ip_addr, p, 128); p += strlen(p); p += snprintf(p, 32, ":%d ", key.sport); @@ -744,7 +744,7 @@ void handle_raw(const u_char* pkt, int len, void* userdata); #endif void handle_ether(const u_char* pkt, int len, void* userdata); #ifdef DLT_LINUX_SLL -void handle_linux_sll(const u_char * pkt, int len, void *userdata); +void handle_linux_sll(const u_char* pkt, int len, void* userdata); #endif static void diff --git a/src/pcap_layers b/src/pcap_layers index cd623d5a..b331f098 160000 --- a/src/pcap_layers +++ b/src/pcap_layers @@ -1 +1 @@ -Subproject commit cd623d5a1aa23ecc0f015fdc49e3837e8b551fbf +Subproject commit b331f0985d5488ca0584fa7451082b1cbdfdfd77