From 9fb4d907ffd029c6251daf7c9adbf0e0596ded58 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 23 Oct 2024 14:13:06 +0200 Subject: [PATCH] parser-common: allow `::` in source file paths It is used as a separator in file names of perl man pages. Resolves: https://issues.redhat.com/browse/OSH-687 --- src/lib/parser-common.hh | 3 +- .../0131-unicontrol-perl-man-page-args.txt | 1 + .../0131-unicontrol-perl-man-page-stdin.txt | 39 ++++ .../0131-unicontrol-perl-man-page-stdout.txt | 186 ++++++++++++++++++ tests/csgrep/CMakeLists.txt | 1 + 5 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 tests/csgrep/0131-unicontrol-perl-man-page-args.txt create mode 100644 tests/csgrep/0131-unicontrol-perl-man-page-stdin.txt create mode 100644 tests/csgrep/0131-unicontrol-perl-man-page-stdout.txt diff --git a/src/lib/parser-common.hh b/src/lib/parser-common.hh index f1aac24a..2e8cdc31 100644 --- a/src/lib/parser-common.hh +++ b/src/lib/parser-common.hh @@ -29,7 +29,8 @@ #define RE_CHECKER_NAME_MISRA "(?:MISRA C(?:\\+\\+)?-[0-9]+ (?:Directive|Rule) [0-9.-]+)" #define RE_CHECKER_NAME RE_CHECKER_NAME_SA "|" RE_CHECKER_NAME_CERT "|" RE_CHECKER_NAME_MISRA -#define RE_PATH_LOCAL "[^:]+" +// the `::` separators are used in file names of perl man pages +#define RE_PATH_LOCAL "[^:]+(?:::[A-Za-z][^:]+)*" #define RE_PATH_URL "http(?:s)?://[^:]+(?::[0-9]+)?[^:]+" #define RE_PATH RE_PATH_LOCAL "|" RE_PATH_URL diff --git a/tests/csgrep/0131-unicontrol-perl-man-page-args.txt b/tests/csgrep/0131-unicontrol-perl-man-page-args.txt new file mode 100644 index 00000000..7df3c951 --- /dev/null +++ b/tests/csgrep/0131-unicontrol-perl-man-page-args.txt @@ -0,0 +1 @@ +--mode=json diff --git a/tests/csgrep/0131-unicontrol-perl-man-page-stdin.txt b/tests/csgrep/0131-unicontrol-perl-man-page-stdin.txt new file mode 100644 index 00000000..373e6318 --- /dev/null +++ b/tests/csgrep/0131-unicontrol-perl-man-page-stdin.txt @@ -0,0 +1,39 @@ +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:655: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:657: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:658: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:659: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:655: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:657: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:658: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:659: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:952: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:953: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:956: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:957: warning: bidirectional control characters: ['\u202b', '\u202c'] + +Error: UNICONTROL_WARNING: +/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:958: warning: bidirectional control characters: ['\u202b', '\u202c'] + diff --git a/tests/csgrep/0131-unicontrol-perl-man-page-stdout.txt b/tests/csgrep/0131-unicontrol-perl-man-page-stdout.txt new file mode 100644 index 00000000..35dcba1a --- /dev/null +++ b/tests/csgrep/0131-unicontrol-perl-man-page-stdout.txt @@ -0,0 +1,186 @@ +{ + "defects": [ + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod", + "line": 655, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod", + "line": 657, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod", + "line": 658, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod", + "line": 659, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod", + "line": 655, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod", + "line": 657, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod", + "line": 658, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod", + "line": 659, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm", + "line": 952, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm", + "line": 953, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm", + "line": 956, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm", + "line": 957, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + }, + { + "checker": "UNICONTROL_WARNING", + "tool": "unicontrol", + "key_event_idx": 0, + "events": [ + { + "file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm", + "line": 958, + "event": "warning", + "message": "bidirectional control characters: ['\\u202b', '\\u202c']", + "verbosity_level": 0 + } + ] + } + ] +} diff --git a/tests/csgrep/CMakeLists.txt b/tests/csgrep/CMakeLists.txt index 8e622442..233d5749 100644 --- a/tests/csgrep/CMakeLists.txt +++ b/tests/csgrep/CMakeLists.txt @@ -172,3 +172,4 @@ test_csgrep("0125-sarif-parser-bom" ) test_csgrep("0126-cov-parser-imp-flag" ) test_csgrep("0127-cov-writer-noloc" ) test_csgrep("0128-cov-parser-noloc" ) +test_csgrep("0131-unicontrol-perl-man-page" )