From 0076a40be8163780b6e59f47e67c8261967128d7 Mon Sep 17 00:00:00 2001 From: Alex Chen Date: Tue, 14 Jul 2026 18:19:50 +0000 Subject: [PATCH] fix(cluecode): detect glued Author:Name C++ tags Normalize Author:Name without a space after the colon and match single mixed-case dotted names like Frankie.Chu. Fixes #4229 Signed-off-by: Alex Chen --- src/cluecode/copyrights.py | 13 +++++++++++++ .../data/authors/author_frankie_chu_cpp-tm1637.cpp | 2 ++ .../authors/author_frankie_chu_cpp-tm1637.cpp.yml | 9 +++++++++ 3 files changed, 24 insertions(+) create mode 100644 tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp create mode 100644 tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp.yml diff --git a/src/cluecode/copyrights.py b/src/cluecode/copyrights.py index 6d17467acf..7dcf8e2c07 100644 --- a/src/cluecode/copyrights.py +++ b/src/cluecode/copyrights.py @@ -428,6 +428,9 @@ def get_tokens(numbered_lines, splitter=re.compile(r'[\t =;]+').split): if TRACE_TOK: logger_debug(' get_tokens: preped line: ' + repr(line)) + # Author:Frankie.Chu -> Author: Frankie.Chu for AUTH + name tokenization + line = re.sub(r'(?i)\b(authors?|@authors?)(:)(?=\S)', r'\1\2 ', line) + for tok in splitter(line): # strip trailing quotes+comma if tok.endswith("',"): @@ -2227,6 +2230,10 @@ def build_detection_from_node( # proper noun with some separator and trailing comma (r'^[A-Z]+\.[A-Z][a-z]+,?$', 'NNP'), + # Mixed-case dotted name (Frankie.Chu). Not NNP: AUTHOR uses AUTH+NAME-DOT only. + # Exclude common org suffixes and license-prose glue tails (Assignment.This). + (r'^[A-Z][a-z0-9]+(?:\.(?!Org,?$|Com,?$|Net,?$|Edu,?$|Gov,?$|Inc,?$|Ltd,?$|Co,?$|This,?$|In,?$|All,?$|The,?$|Of,?$|And,?$|For,?$|By,?$|With,?$|From,?$|To,?$|As,?$|Or,?$|An,?$|At,?$|On,?$|Is,?$|Are,?$|Was,?$|Be,?$|If,?$|Not,?$|No,?$|Any,?$|Such,?$|That,?$|These,?$|Those,?$|When,?$|Where,?$|Which,?$|Who,?$|Will,?$|Shall,?$|May,?$|Can,?$|Must,?$|Should,?$|Would,?$|Could,?$|Rights,?$|Reserved,?$|Agreement,?$|Event,?$|Breach,?$|License,?$|Software,?$|Source,?$|Code,?$|File,?$|Files,?$|Notice,?$|Notices,?$|Subject,?$|Terms,?$|Conditions,?$|Section,?$|Clause,?$|Party,?$|Parties,?$)[A-Z][a-z0-9]+)+,?$', 'NAME-DOT'), + # proper noun with apostrophe ': D'Orleans, D'Arcy, T'so, Ts'o (r"^[A-Z][a-z]?'[A-Z]?[a-z]+[,\.]?$", 'NNP'), @@ -2552,6 +2559,8 @@ def build_detection_from_node( # NAME-YEAR starts or ends with a YEAR range NAME-YEAR: { +} #350 + NAME-YEAR: { +} #350.05 + NAME-YEAR: { } #350.06 COPYRIGHT: { } #350.1 @@ -2699,6 +2708,8 @@ def build_detection_from_node( # Companies COMPANY: {+ ? ?} #770 COMPANY: { } #780 + # NAME-DOT + company words only (not bare NAME-DOT) + COMPANY: { +} #780.1 COMPANY: {? } #790 COMPANY: { +} #800 @@ -3475,6 +3486,8 @@ def build_detection_from_node( # author (Panagiotis Tsirigotis) AUTHOR: { +} #author Foo Bar + AUTHOR: { } #author Frankie.Chu + # Author: Tim (xtimor@gmail.com) AUTHOR: { + +} #Author Foo joe@email.com diff --git a/tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp b/tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp new file mode 100644 index 0000000000..5bb8b7afb3 --- /dev/null +++ b/tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp @@ -0,0 +1,2 @@ +// Date:9 April,2012 +// Author:Frankie.Chu diff --git a/tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp.yml b/tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp.yml new file mode 100644 index 0000000000..126637455b --- /dev/null +++ b/tests/cluecode/data/authors/author_frankie_chu_cpp-tm1637.cpp.yml @@ -0,0 +1,9 @@ +what: + - authors + - authors_summary +authors: + - Frankie.Chu +authors_summary: + - value: Frankie.Chu + count: 1 +notes: Detect glued C++ Author:Name tags without space after colon (issue #4229)