From 83ea5d5d68515a8966cd50962e1b4e44dbb473f9 Mon Sep 17 00:00:00 2001 From: Daniel Salzman Date: Thu, 27 Sep 2012 15:02:37 +0200 Subject: [PATCH] Added tests for INCLUDE directive refs #2041 @10h --- src/zscanner/NOTES | 10 +- src/zscanner/file_loader.c | 20 +-- src/zscanner/scanner.h | 2 +- src/zscanner/scanner_body.rl | 77 +++++----- src/zscanner/scanner_functions.c | 52 +++++-- src/zscanner/scanner_functions.h | 7 +- src/zscanner/test/run_tests.sh | 19 ++- src/zscanner/test/tests/00_general.out | 1 - src/zscanner/test/tests/01_owner.out | 1 - src/zscanner/test/tests/02_class.out | 1 - src/zscanner/test/tests/03_rrttl.out | 1 - src/zscanner/test/tests/04-0_ORIGIN.out | 1 - src/zscanner/test/tests/04-1_ORIGIN.out | 1 - src/zscanner/test/tests/04-2_ORIGIN.out | 1 - src/zscanner/test/tests/04-3_ORIGIN.out | 1 - src/zscanner/test/tests/04-4_ORIGIN.out | 1 - src/zscanner/test/tests/04-5_ORIGIN.out | 1 - src/zscanner/test/tests/04-6_ORIGIN.out | 1 - src/zscanner/test/tests/04-7_ORIGIN.out | 1 - src/zscanner/test/tests/04-8_ORIGIN.out | 1 - src/zscanner/test/tests/04-9_ORIGIN.out | 1 - src/zscanner/test/tests/05-0_TTL.out | 1 - src/zscanner/test/tests/05-1_TTL.out | 1 - src/zscanner/test/tests/05-2_TTL.out | 1 - src/zscanner/test/tests/05-3_TTL.out | 1 - src/zscanner/test/tests/05-4_TTL.out | 1 - src/zscanner/test/tests/06-0_INCLUDE.in | 30 ++++ src/zscanner/test/tests/06-0_INCLUDE.out | 140 ++++++++++++++++++ src/zscanner/test/tests/06-1_INCLUDE.in | 6 + src/zscanner/test/tests/06-1_INCLUDE.out | 2 + src/zscanner/test/tests/06-2_INCLUDE.in | 6 + src/zscanner/test/tests/06-2_INCLUDE.out | 2 + src/zscanner/test/tests/06-3_INCLUDE.in | 6 + src/zscanner/test/tests/06-3_INCLUDE.out | 2 + src/zscanner/test/tests/06-4_INCLUDE.in | 6 + src/zscanner/test/tests/06-4_INCLUDE.out | 2 + src/zscanner/test/tests/06-5_INCLUDE.in | 5 + src/zscanner/test/tests/06-5_INCLUDE.out | 2 + src/zscanner/test/tests/06-6_INCLUDE.in | 5 + src/zscanner/test/tests/06-6_INCLUDE.out | 4 + src/zscanner/test/tests/06-7_INCLUDE.in | 5 + src/zscanner/test/tests/06-7_INCLUDE.out | 4 + src/zscanner/test/tests/06-8_INCLUDE.in | 5 + src/zscanner/test/tests/06-8_INCLUDE.out | 12 ++ src/zscanner/test/tests/10_A.out | 1 - src/zscanner/test/tests/11_AAAA.out | 1 - src/zscanner/test/tests/12_TXT.in | 1 + src/zscanner/test/tests/12_TXT.out | 7 +- src/zscanner/test/tests/13_SPF.out | 1 - src/zscanner/test/tests/14_NS.out | 1 - src/zscanner/test/tests/15_CNAME.out | 1 - src/zscanner/test/tests/16_PTR.out | 1 - src/zscanner/test/tests/17_DNAME.out | 1 - src/zscanner/test/tests/18_MX.out | 1 - src/zscanner/test/tests/19_AFSDB.out | 1 - src/zscanner/test/tests/20_RT.out | 1 - src/zscanner/test/tests/21_KX.out | 1 - src/zscanner/test/tests/22_HINFO.out | 1 - src/zscanner/test/tests/23_MINFO.out | 1 - src/zscanner/test/tests/24_RP.out | 1 - src/zscanner/test/tests/25_SOA.out | 1 - src/zscanner/test/tests/includes/include1 | 9 ++ src/zscanner/test/tests/includes/include2 | 6 + .../{06_INCLUDE.in => includes/include3} | 0 src/zscanner/test/tests/includes/include4 | 1 + src/zscanner/test/tests/includes/include5 | 1 + src/zscanner/test/tests/includes/include6 | 1 + 67 files changed, 380 insertions(+), 111 deletions(-) create mode 100644 src/zscanner/test/tests/06-0_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-0_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-1_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-1_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-2_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-2_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-3_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-3_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-4_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-4_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-5_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-5_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-6_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-6_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-7_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-7_INCLUDE.out create mode 100644 src/zscanner/test/tests/06-8_INCLUDE.in create mode 100644 src/zscanner/test/tests/06-8_INCLUDE.out create mode 100644 src/zscanner/test/tests/includes/include1 create mode 100644 src/zscanner/test/tests/includes/include2 rename src/zscanner/test/tests/{06_INCLUDE.in => includes/include3} (100%) create mode 100644 src/zscanner/test/tests/includes/include4 create mode 100644 src/zscanner/test/tests/includes/include5 create mode 100644 src/zscanner/test/tests/includes/include6 diff --git a/src/zscanner/NOTES b/src/zscanner/NOTES index 43c623143..96f484ae8 100644 --- a/src/zscanner/NOTES +++ b/src/zscanner/NOTES @@ -2,8 +2,14 @@ - the class IN is supported only (CLASS12345 notation is not supported too) - domain names can contain alphanumeric, '-', '_' and '/' characters - \x and \DDD notations are allowed in domain names and text strings only -- @ can be used instead of domain names anywhere +- @ can be used instead of domain names anywhere (excluding directives) +- included file can contain include directive +- relative file path is relative to parent zone file +- blank zone file causes error (same rule is for included zone files) +- included file can contain include directive (BEWARE of recursion) - the line numbers of multiline records are the numbers of the last lines with appropriate record parts - items parts lengths must be multiples of 2 for HEX, 4 for base64 and 8 for base32hex blocks (but DHCID example from RFC is more general!) - NSEC3 hash is with padding (but RFC 5155 section 3.3 says "unpadded") -- date version of timestamp in RRSIG is limited to the end of the year 2105 (for better checking of 32bit integer) \ No newline at end of file +- date version of timestamp in RRSIG is limited to the end of the year 2105 (for better checking of 32bit integer) +- directive $INCLUDE is allowed in included zone files +- algorithm and certificate mnemonics aren't supported \ No newline at end of file diff --git a/src/zscanner/file_loader.c b/src/zscanner/file_loader.c index 6a99b1ba6..83aaa328e 100644 --- a/src/zscanner/file_loader.c +++ b/src/zscanner/file_loader.c @@ -38,7 +38,7 @@ static int load_settings(file_loader_t *fl) // Creating name for zone defaults. settings_name = malloc(strlen(fl->file_name) + 100); - sprintf(settings_name, "ZONE DEFAULTS (%s)", fl->file_name); + sprintf(settings_name, "ZONE DEFAULTS <%s>", fl->file_name); // Temporary scanner for zone settings. settings_scanner = scanner_create(settings_name); @@ -120,7 +120,7 @@ file_loader_t* file_loader_create(const char *file_name, if (ret > 0) { fl->settings_length = ret; } else { - printf("Error in zone setttings!\n"); + printf("FL:Error in zone setttings!\n"); file_loader_free(fl); return NULL; } @@ -158,19 +158,19 @@ int file_loader_process(file_loader_t *fl) // Getting file information. if (fstat(fl->fd, &file_stat) == -1) { - printf("Fstat error!\n"); + printf("FL:Fstat error!\n"); return -1; } // Check for directory. if (S_ISDIR(file_stat.st_mode)) { - printf("Given zone file is a directory!\n"); + printf("FL:Given zone file is a directory!\n"); return -1; } // Check for empty file. if (file_stat.st_size == 0) { - printf("Empty zone file!\n"); + printf("FL:Empty zone file!\n"); return -1; } @@ -187,7 +187,7 @@ int file_loader_process(file_loader_t *fl) ret = load_settings(fl); if (ret != 0) { - printf("Zone defaults error!\n"); + printf("FL:Zone defaults error!\n"); return -1; } @@ -223,13 +223,13 @@ int file_loader_process(file_loader_t *fl) block_start_position); if (data == MAP_FAILED) { - printf("Mmap error!\n"); + printf("FL:Mmap error!\n"); return -1; } // Check for sufficient block overlapping. if (fl->scanner->token_shift > overlapping_size) { - printf("Insufficient block overlapping!\n"); + printf("FL:Insufficient block overlapping!\n"); return -1; }; @@ -250,14 +250,14 @@ int file_loader_process(file_loader_t *fl) // Zone file block unmapping. if (munmap(data, block_end_position - block_start_position) == -1) { - printf("Error file munmapping!\n"); + printf("FL:Error file munmapping!\n"); return -1; } } // Check for scanner return. if (ret != 0) { - printf("Zone processing has stopped with %"PRIu64" errors!\n", + printf("FL:Zone processing has stopped with %"PRIu64" errors!\n", fl->scanner->error_counter); return -1; } diff --git a/src/zscanner/scanner.h b/src/zscanner/scanner.h index cdc4a79bb..64c65a0a4 100644 --- a/src/zscanner/scanner.h +++ b/src/zscanner/scanner.h @@ -121,7 +121,7 @@ struct scanner { /*!< Auxiliary buffer length. */ uint32_t buffer_length; - char include_filename[MAX_RDATA_LENGTH]; + char include_filename[MAX_RDATA_LENGTH + 1]; /*!< Bitmap window blocks. */ window_t windows[BITMAP_WINDOWS]; diff --git a/src/zscanner/scanner_body.rl b/src/zscanner/scanner_body.rl index e1fe2db36..7c4ba8ed2 100644 --- a/src/zscanner/scanner_body.rl +++ b/src/zscanner/scanner_body.rl @@ -249,6 +249,17 @@ ) $!_r_owner_error; # END + # BEGIN - domain name in record data processing + action _r_dname_init { + s->dname = rdata_tail; + } + action _r_dname_exit { + rdata_tail += s->dname_tmp_length; + } + + r_dname = dname >_r_dname_init %_r_dname_exit; + # END + # BEGIN - Number processing action _number_digit { // Overflow check: 10*(s->number64) + fc - ASCII_0 <= UINT64_MAX @@ -586,7 +597,6 @@ zone_origin_ := (sep . absolute_dname >_zone_origin_init . rest) $!_zone_origin_error %_zone_origin_exit %_ret . newline; - zone_origin = all_wchar ${ fhold; fcall zone_origin_; }; # END @@ -595,15 +605,17 @@ rdata_tail = s->r_data; } action _incl_filename_exit { - if (rdata_tail <= rdata_stop) { - *rdata_tail = 0; // Ending filename string. - strcpy((char*)(s->include_filename), (char*)(s->r_data)); - rdata_tail = s->r_data; // Initialization of origin if not present! - *rdata_tail = 0; - } else { - SCANNER_WARNING(ZSCANNER_ETEXT_OVERFLOW); + *rdata_tail = 0; // Ending filename string. + strcpy((char*)(s->include_filename), (char*)(s->r_data)); + + // Check for correct string copy. + if (strlen(s->include_filename) != rdata_tail - s->r_data) { + SCANNER_ERROR(ZSCANNER_EBAD_INCLUDE_FILENAME); fhold; fgoto err_line; } + + // For detection whether origin is not present. + s->dname = NULL; } action _incl_filename_error { SCANNER_ERROR(ZSCANNER_EBAD_INCLUDE_FILENAME); @@ -611,15 +623,10 @@ } action _incl_origin_init { - rdata_tail = s->r_data; + s->dname = s->r_data; } action _incl_origin_exit { - if (rdata_tail <= rdata_stop) { - *rdata_tail = 0; // Ending origin string. - } else { - SCANNER_WARNING(ZSCANNER_ETEXT_OVERFLOW); - fhold; fgoto err_line; - } + s->r_data_length = s->dname_tmp_length; } action _incl_origin_error { SCANNER_ERROR(ZSCANNER_EBAD_INCLUDE_ORIGIN); @@ -630,18 +637,21 @@ char text_origin[MAX_DNAME_LENGTH]; // Origin conversion from wire to text form. - if (s->r_data[0] == 0) { // Use current origin. - wire_dname_to_text(s->zone_origin, - s->zone_origin_length, - text_origin); + if (s->dname == NULL) { // Use current origin. + wire_dname_to_str(s->zone_origin, + s->zone_origin_length, + text_origin); } else { // Use specified origin. - strcpy(text_origin, (char *)(s->r_data)); + wire_dname_to_str(s->r_data, + s->r_data_length, + text_origin); } - if (s->include_filename[0] != '/') { // File name is in relative form. + if (s->include_filename[0] != '/') { // Relative file path.. // Get absolute path of the current zone file. if (realpath(s->file_name, (char*)(s->buffer)) != NULL) { - char *full_current_zone_file_name = strdup((char*)(s->buffer)); + char *full_current_zone_file_name = + strdup((char*)(s->buffer)); // Creating full include file name. sprintf((char*)(s->buffer), "%s/%s", @@ -680,11 +690,13 @@ } } - include_file_ := (sep . text >_incl_filename_init %_incl_filename_exit - $!_incl_filename_error . - (sep . text >_incl_origin_init %_incl_origin_exit - $!_incl_origin_error)? . rest - ) %_include_exit %_ret newline; + include_file_ := + (sep . text >_incl_filename_init %_incl_filename_exit + $!_incl_filename_error . + (sep . absolute_dname >_incl_origin_init %_incl_origin_exit + $!_incl_origin_error + )? . rest + ) %_include_exit %_ret newline; include_file = all_wchar ${ fhold; fcall include_file_; }; # END @@ -736,17 +748,6 @@ r_ttl = time %_r_ttl_exit; # END - # BEGIN - domain name in record data processing - action _r_dname_init { - s->dname = rdata_tail; - } - action _r_dname_exit { - rdata_tail += s->dname_tmp_length; - } - - r_dname = dname >_r_dname_init %_r_dname_exit; - # END - # BEGIN - IPv4 and IPv6 address processing action _addr_init { s->buffer_length = 0; diff --git a/src/zscanner/scanner_functions.c b/src/zscanner/scanner_functions.c index 5e4e2fb05..42fba3716 100644 --- a/src/zscanner/scanner_functions.c +++ b/src/zscanner/scanner_functions.c @@ -17,6 +17,7 @@ #include "zscanner/scanner_functions.h" #include +#include #include "common/errcode.h" #include "common/descriptor_new.h" @@ -755,24 +756,45 @@ int date_to_timestamp(uint8_t *buff, uint32_t *timestamp) return KNOT_EOK; } -void wire_dname_to_text(const uint8_t *dname, - const uint32_t dname_length, - char *text_dname) +int wire_dname_to_str(const uint8_t *data, + const uint32_t data_len, + char *text) { - uint32_t label_length = 0, i = 0, j = 0; + uint32_t i = 0, text_len = 0; - for (i = 0; i < dname_length; i++) { - if (label_length == 0) { - label_length = dname[i]; - if (i > 0) { // Ignore first byte with length. - text_dname[j++] = '.'; - } + if (data == NULL || data_len == 0 || text == NULL) { + return -1; + } + + uint8_t label_len = data[0]; + + // Loop over data characters. + for (i = 1; i < data_len; i++) { + // Replace label length with dot. + if (label_len == 0) { + label_len = data[i]; + text[text_len++] = '.'; continue; } - text_dname[j++] = (char)dname[i]; - label_length--; + + // Just in case use \123 notation. + text[text_len++] = '\\'; + text[text_len++] = (data[i] / 100) + ASCII_0; + text[text_len++] = (data[i] / 10) % 10 + ASCII_0; + text[text_len++] = (data[i] ) % 10 + ASCII_0; + + label_len--; } - text_dname[j] = 0; + + // Add trailing dot for root domain. + if (data_len == 1 && label_len == 0) { + text[text_len++] = '.'; + } + + // Ending text string. + text[text_len] = 0; + + return KNOT_EOK; } uint8_t loc64to8(uint64_t number) @@ -805,8 +827,8 @@ static uint32_t get_dname_length(const uint8_t *data, if (dname_len > data_len) { return 0; } - - label_len = data[dname_len] & 63; + + label_len = data[dname_len]; } dname_len++; // Last label length byte. diff --git a/src/zscanner/scanner_functions.h b/src/zscanner/scanner_functions.h index efaf22051..03ddd3123 100644 --- a/src/zscanner/scanner_functions.h +++ b/src/zscanner/scanner_functions.h @@ -36,6 +36,7 @@ extern const uint8_t ascii_to_lower[]; extern const uint8_t digit_to_num[]; +// Transformation arrays for Hex encoding. extern const uint8_t first_hex_to_num[]; extern const uint8_t second_hex_to_num[]; @@ -63,9 +64,9 @@ extern const uint8_t eighth_base32hex_to_num[]; int date_to_timestamp(uint8_t *buff, uint32_t *timestamp); -void wire_dname_to_text(const uint8_t *dname, - const uint32_t dname_length, - char *text_dname); +int wire_dname_to_str(const uint8_t *data, + const uint32_t data_len, + char *text); uint8_t loc64to8(uint64_t number); diff --git a/src/zscanner/test/run_tests.sh b/src/zscanner/test/run_tests.sh index 3e57f252b..b2bcbe238 100755 --- a/src/zscanner/test/run_tests.sh +++ b/src/zscanner/test/run_tests.sh @@ -1,16 +1,21 @@ -#!/bin/bash +#!/bin/sh -mkdir /tmp/tests +TESTS_DIR="./tests" +OUTS_DIR="/tmp/zscanner_tests" +TEST_BIN="../../unittests-zscanner -m 2" + +mkdir -p ${OUTS_DIR}/${TESTS_DIR} +cp -r ${TESTS_DIR}/includes ${OUTS_DIR} separation="=========================================================" echo $separation -for file in `/usr/bin/find ./tests/ -name "*.in" | /usr/bin/sort`; do - fileout=`echo "$file" | /bin/sed 's/.in/.out/'` - ../../unittests-zscanner -m 2 . $file > /tmp/$fileout - /bin/sed --in-place 's/Zone processing has stopped.*//' /tmp/$fileout +for file in `find $TESTS_DIR -name "*.in" | sort`; do + fileout=`echo "$file" | sed 's/.in/.out/'` + $TEST_BIN . $file > ${OUTS_DIR}/$fileout + sed --in-place '/FL:/d' ${OUTS_DIR}/$fileout echo $fileout - diff /tmp/$fileout $fileout + diff ${OUTS_DIR}/$fileout $fileout echo $separation done diff --git a/src/zscanner/test/tests/00_general.out b/src/zscanner/test/tests/00_general.out index e237de7d5..c9c6a43e4 100644 --- a/src/zscanner/test/tests/00_general.out +++ b/src/zscanner/test/tests/00_general.out @@ -66,4 +66,3 @@ RDATA=00 ------ ERROR=ZSCANNER_ELEFT_PARENTHESIS ------ - diff --git a/src/zscanner/test/tests/01_owner.out b/src/zscanner/test/tests/01_owner.out index 00a65c69c..99d93bb66 100644 --- a/src/zscanner/test/tests/01_owner.out +++ b/src/zscanner/test/tests/01_owner.out @@ -122,4 +122,3 @@ WARNG=ZSCANNER_EDNAME_OVERFLOW ------ WARNG=ZSCANNER_EDNAME_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/02_class.out b/src/zscanner/test/tests/02_class.out index 1f57b4cb0..6002cc3f4 100644 --- a/src/zscanner/test/tests/02_class.out +++ b/src/zscanner/test/tests/02_class.out @@ -14,4 +14,3 @@ WARNG=ZSCANNER_EUNSUPPORTED_TYPE ------ WARNG=ZSCANNER_EUNSUPPORTED_TYPE ------ - diff --git a/src/zscanner/test/tests/03_rrttl.out b/src/zscanner/test/tests/03_rrttl.out index b3d7f0f45..bdc0b6e35 100644 --- a/src/zscanner/test/tests/03_rrttl.out +++ b/src/zscanner/test/tests/03_rrttl.out @@ -98,4 +98,3 @@ WARNG=ZSCANNER_ENUMBER32_OVERFLOW ------ WARNG=ZSCANNER_EBAD_TIME_UNIT ------ - diff --git a/src/zscanner/test/tests/04-0_ORIGIN.out b/src/zscanner/test/tests/04-0_ORIGIN.out index b606204f4..48bda7962 100644 --- a/src/zscanner/test/tests/04-0_ORIGIN.out +++ b/src/zscanner/test/tests/04-0_ORIGIN.out @@ -84,4 +84,3 @@ RDATA=00 ------ ERROR=ZSCANNER_EBAD_ORIGIN ------ - diff --git a/src/zscanner/test/tests/04-1_ORIGIN.out b/src/zscanner/test/tests/04-1_ORIGIN.out index 5c96ccf8a..43d27c37a 100644 --- a/src/zscanner/test/tests/04-1_ORIGIN.out +++ b/src/zscanner/test/tests/04-1_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_ORIGIN ------ - diff --git a/src/zscanner/test/tests/04-2_ORIGIN.out b/src/zscanner/test/tests/04-2_ORIGIN.out index 5c96ccf8a..43d27c37a 100644 --- a/src/zscanner/test/tests/04-2_ORIGIN.out +++ b/src/zscanner/test/tests/04-2_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_ORIGIN ------ - diff --git a/src/zscanner/test/tests/04-3_ORIGIN.out b/src/zscanner/test/tests/04-3_ORIGIN.out index d715c7d27..16950a81d 100644 --- a/src/zscanner/test/tests/04-3_ORIGIN.out +++ b/src/zscanner/test/tests/04-3_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_REST ------ - diff --git a/src/zscanner/test/tests/04-4_ORIGIN.out b/src/zscanner/test/tests/04-4_ORIGIN.out index 60be9b591..f30b92943 100644 --- a/src/zscanner/test/tests/04-4_ORIGIN.out +++ b/src/zscanner/test/tests/04-4_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_NUMBER ------ - diff --git a/src/zscanner/test/tests/04-5_ORIGIN.out b/src/zscanner/test/tests/04-5_ORIGIN.out index 60be9b591..f30b92943 100644 --- a/src/zscanner/test/tests/04-5_ORIGIN.out +++ b/src/zscanner/test/tests/04-5_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_NUMBER ------ - diff --git a/src/zscanner/test/tests/04-6_ORIGIN.out b/src/zscanner/test/tests/04-6_ORIGIN.out index d715c7d27..16950a81d 100644 --- a/src/zscanner/test/tests/04-6_ORIGIN.out +++ b/src/zscanner/test/tests/04-6_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_REST ------ - diff --git a/src/zscanner/test/tests/04-7_ORIGIN.out b/src/zscanner/test/tests/04-7_ORIGIN.out index d715c7d27..16950a81d 100644 --- a/src/zscanner/test/tests/04-7_ORIGIN.out +++ b/src/zscanner/test/tests/04-7_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_REST ------ - diff --git a/src/zscanner/test/tests/04-8_ORIGIN.out b/src/zscanner/test/tests/04-8_ORIGIN.out index 9b403fb61..ee4139a93 100644 --- a/src/zscanner/test/tests/04-8_ORIGIN.out +++ b/src/zscanner/test/tests/04-8_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_ELABEL_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/04-9_ORIGIN.out b/src/zscanner/test/tests/04-9_ORIGIN.out index 5ce9097e7..2ed0a4c1a 100644 --- a/src/zscanner/test/tests/04-9_ORIGIN.out +++ b/src/zscanner/test/tests/04-9_ORIGIN.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EDNAME_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/05-0_TTL.out b/src/zscanner/test/tests/05-0_TTL.out index 184c101a4..5e87bb039 100644 --- a/src/zscanner/test/tests/05-0_TTL.out +++ b/src/zscanner/test/tests/05-0_TTL.out @@ -90,4 +90,3 @@ RDATA=00 ------ ERROR=ZSCANNER_EBAD_NUMBER ------ - diff --git a/src/zscanner/test/tests/05-1_TTL.out b/src/zscanner/test/tests/05-1_TTL.out index f9b034a51..bbdc638fc 100644 --- a/src/zscanner/test/tests/05-1_TTL.out +++ b/src/zscanner/test/tests/05-1_TTL.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_ENUMBER32_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/05-2_TTL.out b/src/zscanner/test/tests/05-2_TTL.out index f9b034a51..bbdc638fc 100644 --- a/src/zscanner/test/tests/05-2_TTL.out +++ b/src/zscanner/test/tests/05-2_TTL.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_ENUMBER32_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/05-3_TTL.out b/src/zscanner/test/tests/05-3_TTL.out index f9b034a51..bbdc638fc 100644 --- a/src/zscanner/test/tests/05-3_TTL.out +++ b/src/zscanner/test/tests/05-3_TTL.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_ENUMBER32_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/05-4_TTL.out b/src/zscanner/test/tests/05-4_TTL.out index 924d3316a..d0a0c651b 100644 --- a/src/zscanner/test/tests/05-4_TTL.out +++ b/src/zscanner/test/tests/05-4_TTL.out @@ -1,3 +1,2 @@ ERROR=ZSCANNER_EBAD_TIME_UNIT ------ - diff --git a/src/zscanner/test/tests/06-0_INCLUDE.in b/src/zscanner/test/tests/06-0_INCLUDE.in new file mode 100644 index 000000000..4641ae165 --- /dev/null +++ b/src/zscanner/test/tests/06-0_INCLUDE.in @@ -0,0 +1,30 @@ +$ORIGIN . +$TTL 1 + +; OK +0. NS @ + +$INCLUDE ./includes/include1 ; Relative path without origin +1. NS @ + +$INCLUDE "./includes/include2" . ; Quoted filename and the simplest origin +2. NS @ + +$INCLUDE ./includes/include\050 tld. ; Simple origin +3. NS @ + +$INCLUDE \./includes/include2 _a_.-b-c-./d/. ; Slashed character in file name, allowed characters in origin +4. NS @ + +$INCLUDE ./includes/include2 \0320\ \\\"\.\@\*.tld. ; Origin with special chars +5. NS @ + +$INCLUDE /tmp/zscanner_tests/includes/include2 ; Absolute path without origin +6. NS @ + +$INCLUDE /tmp/zscanner_tests/includes/include2 tld. ; Absolute path with origin +7. NS @ + +; KO +$INCLUDE ; Empty parameters + diff --git a/src/zscanner/test/tests/06-0_INCLUDE.out b/src/zscanner/test/tests/06-0_INCLUDE.out new file mode 100644 index 000000000..44ef30edd --- /dev/null +++ b/src/zscanner/test/tests/06-0_INCLUDE.out @@ -0,0 +1,140 @@ +OWNER=013000 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=016100 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=016105746c64316100 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=05746C64316100 +------ +OWNER=016105746c64316200 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=05746C64316200 +------ +OWNER=013100 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=016200 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=00 +------ +OWNER=016205746c64316100 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=05746C64316100 +------ +OWNER=013200 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=016203746c6400 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=03746C6400 +------ +OWNER=016205746c64316100 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=05746C64316100 +------ +OWNER=013300 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=0162035f615f052d622d632d032f642f00 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=035F615F052D622D632D032F642F00 +------ +OWNER=016205746c64316100 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=05746C64316100 +------ +OWNER=013400 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=0162082030205c222e402a03746c6400 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=082030205C222E402A03746C6400 +------ +OWNER=016205746c64316100 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=05746C64316100 +------ +OWNER=013500 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=016200 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=00 +------ +OWNER=016205746c64316100 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=05746C64316100 +------ +OWNER=013600 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +OWNER=016203746c6400 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=03746C6400 +------ +OWNER=016205746c64316100 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=05746C64316100 +------ +OWNER=013700 +CLASS=0001 +RRTTL=00000001 +RTYPE=0002 +RDATA=00 +------ +ERROR=ZSCANNER_EBAD_INCLUDE_FILENAME +------ diff --git a/src/zscanner/test/tests/06-1_INCLUDE.in b/src/zscanner/test/tests/06-1_INCLUDE.in new file mode 100644 index 000000000..699ad7641 --- /dev/null +++ b/src/zscanner/test/tests/06-1_INCLUDE.in @@ -0,0 +1,6 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE ./includes/include1 a ; Origin is not FQD + diff --git a/src/zscanner/test/tests/06-1_INCLUDE.out b/src/zscanner/test/tests/06-1_INCLUDE.out new file mode 100644 index 000000000..25883e7fd --- /dev/null +++ b/src/zscanner/test/tests/06-1_INCLUDE.out @@ -0,0 +1,2 @@ +ERROR=ZSCANNER_EBAD_INCLUDE_ORIGIN +------ diff --git a/src/zscanner/test/tests/06-2_INCLUDE.in b/src/zscanner/test/tests/06-2_INCLUDE.in new file mode 100644 index 000000000..f32385532 --- /dev/null +++ b/src/zscanner/test/tests/06-2_INCLUDE.in @@ -0,0 +1,6 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE ./includes/include1 % ; Bad origin + diff --git a/src/zscanner/test/tests/06-2_INCLUDE.out b/src/zscanner/test/tests/06-2_INCLUDE.out new file mode 100644 index 000000000..25883e7fd --- /dev/null +++ b/src/zscanner/test/tests/06-2_INCLUDE.out @@ -0,0 +1,2 @@ +ERROR=ZSCANNER_EBAD_INCLUDE_ORIGIN +------ diff --git a/src/zscanner/test/tests/06-3_INCLUDE.in b/src/zscanner/test/tests/06-3_INCLUDE.in new file mode 100644 index 000000000..0e4a5c13e --- /dev/null +++ b/src/zscanner/test/tests/06-3_INCLUDE.in @@ -0,0 +1,6 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE /tmp/zscanner_tests/ ; Given file is a directory + diff --git a/src/zscanner/test/tests/06-3_INCLUDE.out b/src/zscanner/test/tests/06-3_INCLUDE.out new file mode 100644 index 000000000..6a45d67c1 --- /dev/null +++ b/src/zscanner/test/tests/06-3_INCLUDE.out @@ -0,0 +1,2 @@ +ERROR=ZSCANNER_EUNPROCESSED_INCLUDE +------ diff --git a/src/zscanner/test/tests/06-4_INCLUDE.in b/src/zscanner/test/tests/06-4_INCLUDE.in new file mode 100644 index 000000000..118546e24 --- /dev/null +++ b/src/zscanner/test/tests/06-4_INCLUDE.in @@ -0,0 +1,6 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE /tmp/zscanner_tests/_ ; File doesn't exist + diff --git a/src/zscanner/test/tests/06-4_INCLUDE.out b/src/zscanner/test/tests/06-4_INCLUDE.out new file mode 100644 index 000000000..2d4fff27e --- /dev/null +++ b/src/zscanner/test/tests/06-4_INCLUDE.out @@ -0,0 +1,2 @@ +ERROR=ZSCANNER_EUNOPENED_INCLUDE +------ diff --git a/src/zscanner/test/tests/06-5_INCLUDE.in b/src/zscanner/test/tests/06-5_INCLUDE.in new file mode 100644 index 000000000..1d658120c --- /dev/null +++ b/src/zscanner/test/tests/06-5_INCLUDE.in @@ -0,0 +1,5 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE ./includes/include3 ; Blank include file diff --git a/src/zscanner/test/tests/06-5_INCLUDE.out b/src/zscanner/test/tests/06-5_INCLUDE.out new file mode 100644 index 000000000..6a45d67c1 --- /dev/null +++ b/src/zscanner/test/tests/06-5_INCLUDE.out @@ -0,0 +1,2 @@ +ERROR=ZSCANNER_EUNPROCESSED_INCLUDE +------ diff --git a/src/zscanner/test/tests/06-6_INCLUDE.in b/src/zscanner/test/tests/06-6_INCLUDE.in new file mode 100644 index 000000000..cbfda6493 --- /dev/null +++ b/src/zscanner/test/tests/06-6_INCLUDE.in @@ -0,0 +1,5 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE ./includes/include4 ; Include file contains warning diff --git a/src/zscanner/test/tests/06-6_INCLUDE.out b/src/zscanner/test/tests/06-6_INCLUDE.out new file mode 100644 index 000000000..80f23edb1 --- /dev/null +++ b/src/zscanner/test/tests/06-6_INCLUDE.out @@ -0,0 +1,4 @@ +WARNG=ZSCANNER_EBAD_RDATA +------ +ERROR=ZSCANNER_EUNPROCESSED_INCLUDE +------ diff --git a/src/zscanner/test/tests/06-7_INCLUDE.in b/src/zscanner/test/tests/06-7_INCLUDE.in new file mode 100644 index 000000000..24deef71f --- /dev/null +++ b/src/zscanner/test/tests/06-7_INCLUDE.in @@ -0,0 +1,5 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE ./includes/include5 ; Include file contains error diff --git a/src/zscanner/test/tests/06-7_INCLUDE.out b/src/zscanner/test/tests/06-7_INCLUDE.out new file mode 100644 index 000000000..c94b02fb9 --- /dev/null +++ b/src/zscanner/test/tests/06-7_INCLUDE.out @@ -0,0 +1,4 @@ +ERROR=ZSCANNER_EBAD_NUMBER +------ +ERROR=ZSCANNER_EUNPROCESSED_INCLUDE +------ diff --git a/src/zscanner/test/tests/06-8_INCLUDE.in b/src/zscanner/test/tests/06-8_INCLUDE.in new file mode 100644 index 000000000..c856668a7 --- /dev/null +++ b/src/zscanner/test/tests/06-8_INCLUDE.in @@ -0,0 +1,5 @@ +$ORIGIN . +$TTL 1 + +; KO +$INCLUDE ./includes/include6 ; Include file contains include diff --git a/src/zscanner/test/tests/06-8_INCLUDE.out b/src/zscanner/test/tests/06-8_INCLUDE.out new file mode 100644 index 000000000..5f18a939d --- /dev/null +++ b/src/zscanner/test/tests/06-8_INCLUDE.out @@ -0,0 +1,12 @@ +OWNER=016200 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=00 +------ +OWNER=016205746c64316100 +CLASS=0001 +RRTTL=00000E10 +RTYPE=0002 +RDATA=05746C64316100 +------ diff --git a/src/zscanner/test/tests/10_A.out b/src/zscanner/test/tests/10_A.out index fe8c650c8..c36823c14 100644 --- a/src/zscanner/test/tests/10_A.out +++ b/src/zscanner/test/tests/10_A.out @@ -54,4 +54,3 @@ WARNG=ZSCANNER_EBAD_HEX_RDATA ------ WARNG=ZSCANNER_EBAD_RDATA_LENGTH ------ - diff --git a/src/zscanner/test/tests/11_AAAA.out b/src/zscanner/test/tests/11_AAAA.out index 0aaa27182..c4006bf3c 100644 --- a/src/zscanner/test/tests/11_AAAA.out +++ b/src/zscanner/test/tests/11_AAAA.out @@ -66,4 +66,3 @@ WARNG=ZSCANNER_EBAD_HEX_RDATA ------ WARNG=ZSCANNER_EBAD_RDATA_LENGTH ------ - diff --git a/src/zscanner/test/tests/12_TXT.in b/src/zscanner/test/tests/12_TXT.in index 336899b72..36519ff70 100644 --- a/src/zscanner/test/tests/12_TXT.in +++ b/src/zscanner/test/tests/12_TXT.in @@ -11,6 +11,7 @@ $TTL 1 @ TXT "" "test1" "\255" test2 ; Array of text strings @ TXT "" "" "" ; Array of blank strings @ TXT first \# "\#" ; Array with special string +@ TXT \0320\ \\\"\.\@\*.tld. ; Special domain as a string @ TXT " !\"#$%&'()*+,-./0123456789:;<=>?@" ; First part of all printables @ TXT "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" ; Second part of all printables @ TXT "abcdefghijklmnopqrstuvwxyz{|}~" ; Third part of all printables diff --git a/src/zscanner/test/tests/12_TXT.out b/src/zscanner/test/tests/12_TXT.out index 61d37c270..ba573eda2 100644 --- a/src/zscanner/test/tests/12_TXT.out +++ b/src/zscanner/test/tests/12_TXT.out @@ -56,6 +56,12 @@ OWNER=00 CLASS=0001 RRTTL=00000001 RTYPE=0010 +RDATA=0D2030205C222E402A2E746C642E +------ +OWNER=00 +CLASS=0001 +RRTTL=00000001 +RTYPE=0010 RDATA=21202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F40 ------ OWNER=00 @@ -126,4 +132,3 @@ WARNG=ZSCANNER_EBAD_TEXT ------ WARNG=ZSCANNER_EITEM_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/13_SPF.out b/src/zscanner/test/tests/13_SPF.out index b6276abfb..273e92e83 100644 --- a/src/zscanner/test/tests/13_SPF.out +++ b/src/zscanner/test/tests/13_SPF.out @@ -30,4 +30,3 @@ RDATA=00 ------ WARNG=ZSCANNER_EBAD_RDATA ------ - diff --git a/src/zscanner/test/tests/14_NS.out b/src/zscanner/test/tests/14_NS.out index d648331cc..08c0104c5 100644 --- a/src/zscanner/test/tests/14_NS.out +++ b/src/zscanner/test/tests/14_NS.out @@ -144,4 +144,3 @@ WARNG=ZSCANNER_EBAD_HEX_RDATA ------ WARNG=ZSCANNER_EBAD_RDATA_LENGTH ------ - diff --git a/src/zscanner/test/tests/15_CNAME.out b/src/zscanner/test/tests/15_CNAME.out index ef047a0c5..a5411265c 100644 --- a/src/zscanner/test/tests/15_CNAME.out +++ b/src/zscanner/test/tests/15_CNAME.out @@ -30,4 +30,3 @@ RDATA=00 ------ WARNG=ZSCANNER_EBAD_RDATA ------ - diff --git a/src/zscanner/test/tests/16_PTR.out b/src/zscanner/test/tests/16_PTR.out index d38ad13a4..d98329620 100644 --- a/src/zscanner/test/tests/16_PTR.out +++ b/src/zscanner/test/tests/16_PTR.out @@ -30,4 +30,3 @@ RDATA=00 ------ WARNG=ZSCANNER_EBAD_RDATA ------ - diff --git a/src/zscanner/test/tests/17_DNAME.out b/src/zscanner/test/tests/17_DNAME.out index c54396e7c..ee6797248 100644 --- a/src/zscanner/test/tests/17_DNAME.out +++ b/src/zscanner/test/tests/17_DNAME.out @@ -30,4 +30,3 @@ RDATA=00 ------ WARNG=ZSCANNER_EBAD_RDATA ------ - diff --git a/src/zscanner/test/tests/18_MX.out b/src/zscanner/test/tests/18_MX.out index def6ecebc..50b1b7008 100644 --- a/src/zscanner/test/tests/18_MX.out +++ b/src/zscanner/test/tests/18_MX.out @@ -66,4 +66,3 @@ WARNG=ZSCANNER_EBAD_HEX_RDATA ------ WARNG=ZSCANNER_EBAD_RDATA_LENGTH ------ - diff --git a/src/zscanner/test/tests/19_AFSDB.out b/src/zscanner/test/tests/19_AFSDB.out index 6e68424f9..957abc704 100644 --- a/src/zscanner/test/tests/19_AFSDB.out +++ b/src/zscanner/test/tests/19_AFSDB.out @@ -30,4 +30,3 @@ RDATA=0001 00 ------ WARNG=ZSCANNER_EBAD_NUMBER ------ - diff --git a/src/zscanner/test/tests/20_RT.out b/src/zscanner/test/tests/20_RT.out index 42253c76f..490ab2aba 100644 --- a/src/zscanner/test/tests/20_RT.out +++ b/src/zscanner/test/tests/20_RT.out @@ -30,4 +30,3 @@ RDATA=0001 00 ------ WARNG=ZSCANNER_EBAD_NUMBER ------ - diff --git a/src/zscanner/test/tests/21_KX.out b/src/zscanner/test/tests/21_KX.out index ed0a0bf6b..1c5f323e9 100644 --- a/src/zscanner/test/tests/21_KX.out +++ b/src/zscanner/test/tests/21_KX.out @@ -30,4 +30,3 @@ RDATA=0001 00 ------ WARNG=ZSCANNER_EBAD_NUMBER ------ - diff --git a/src/zscanner/test/tests/22_HINFO.out b/src/zscanner/test/tests/22_HINFO.out index 5453a975d..66863ef8f 100644 --- a/src/zscanner/test/tests/22_HINFO.out +++ b/src/zscanner/test/tests/22_HINFO.out @@ -92,4 +92,3 @@ WARNG=ZSCANNER_EBAD_REST ------ WARNG=ZSCANNER_EITEM_OVERFLOW ------ - diff --git a/src/zscanner/test/tests/23_MINFO.out b/src/zscanner/test/tests/23_MINFO.out index 981d3d9a9..026a7d232 100644 --- a/src/zscanner/test/tests/23_MINFO.out +++ b/src/zscanner/test/tests/23_MINFO.out @@ -52,4 +52,3 @@ WARNG=ZSCANNER_EBAD_HEX_RDATA ------ WARNG=ZSCANNER_EBAD_RDATA_LENGTH ------ - diff --git a/src/zscanner/test/tests/24_RP.out b/src/zscanner/test/tests/24_RP.out index 471d8137a..0565c7df9 100644 --- a/src/zscanner/test/tests/24_RP.out +++ b/src/zscanner/test/tests/24_RP.out @@ -30,4 +30,3 @@ RDATA=00 00 ------ WARNG=ZSCANNER_EBAD_RDATA ------ - diff --git a/src/zscanner/test/tests/25_SOA.out b/src/zscanner/test/tests/25_SOA.out index ab155e331..0833c68b7 100644 --- a/src/zscanner/test/tests/25_SOA.out +++ b/src/zscanner/test/tests/25_SOA.out @@ -82,4 +82,3 @@ WARNG=ZSCANNER_EBAD_HEX_RDATA ------ WARNG=ZSCANNER_EBAD_RDATA_LENGTH ------ - diff --git a/src/zscanner/test/tests/includes/include1 b/src/zscanner/test/tests/includes/include1 new file mode 100644 index 000000000..9de185968 --- /dev/null +++ b/src/zscanner/test/tests/includes/include1 @@ -0,0 +1,9 @@ +$TTL 1 + +a NS @ + +$ORIGIN tld1a. +a NS @ + +$ORIGIN tld1b. +a NS @ diff --git a/src/zscanner/test/tests/includes/include2 b/src/zscanner/test/tests/includes/include2 new file mode 100644 index 000000000..1e14e9601 --- /dev/null +++ b/src/zscanner/test/tests/includes/include2 @@ -0,0 +1,6 @@ +$TTL 1H + +b NS @ + +$ORIGIN tld1a. +b NS @ diff --git a/src/zscanner/test/tests/06_INCLUDE.in b/src/zscanner/test/tests/includes/include3 similarity index 100% rename from src/zscanner/test/tests/06_INCLUDE.in rename to src/zscanner/test/tests/includes/include3 diff --git a/src/zscanner/test/tests/includes/include4 b/src/zscanner/test/tests/includes/include4 new file mode 100644 index 000000000..7e8d5e29e --- /dev/null +++ b/src/zscanner/test/tests/includes/include4 @@ -0,0 +1 @@ +a NS ; Missing data diff --git a/src/zscanner/test/tests/includes/include5 b/src/zscanner/test/tests/includes/include5 new file mode 100644 index 000000000..ac98e01b6 --- /dev/null +++ b/src/zscanner/test/tests/includes/include5 @@ -0,0 +1 @@ +$TTL x ; Bad number diff --git a/src/zscanner/test/tests/includes/include6 b/src/zscanner/test/tests/includes/include6 new file mode 100644 index 000000000..b5e8cb84b --- /dev/null +++ b/src/zscanner/test/tests/includes/include6 @@ -0,0 +1 @@ +$INCLUDE include2 ; Include in include