From 7d707f7f370c31f3d9841415c1458a2d21640a15 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Fri, 3 Mar 2023 12:56:37 -0500 Subject: [PATCH] TagsCheck: handle license exception in grouping A valid license exception which is in a grouping is reported as invalid. This is due to the trailing ')' being included in the regex. The following license: (GPL-2.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0) AND MIT returns: W: invalid-license-exception Qt-GPL-exception-1.0) Adjust the license_exception_regex to exclude trailing parenthesis. Fixes: https://bugzilla.redhat.com/2175241 --- rpmlint/checks/TagsCheck.py | 2 +- .../valid-exception-in-grouping-1.0-1.src.rpm | Bin 0 -> 6615 bytes test/test_tags.py | 12 ++++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/source/valid-exception-in-grouping-1.0-1.src.rpm diff --git a/rpmlint/checks/TagsCheck.py b/rpmlint/checks/TagsCheck.py index ad9a35f22..923538ba4 100644 --- a/rpmlint/checks/TagsCheck.py +++ b/rpmlint/checks/TagsCheck.py @@ -21,7 +21,7 @@ leading_space_regex = re.compile(r'^\s+') pkg_config_regex = re.compile(r'^/usr/(?:lib\d*|share)/pkgconfig/') license_regex = re.compile(r'\(([^)]+)\)|\s(?:and|or|AND|OR)\s') -license_exception_regex = re.compile(r'(\S+)\s(?:WITH|with)\s(\S+)') +license_exception_regex = re.compile(r'(\S+)\s(?:WITH|with)\s([^)]+)') invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE) # () are here for grouping purpose in the regexp tag_regex = re.compile(r'^((?:Auto(?:Req|Prov|ReqProv)|Build(?:Arch(?:itectures)?|Root)|(?:Build)?Conflicts|(?:Build)?(?:Pre)?Requires|Copyright|(?:CVS|SVN)Id|Dist(?:ribution|Tag|URL)|DocDir|(?:Build)?Enhances|Epoch|Exclu(?:de|sive)(?:Arch|OS)|Group|Icon|License|Name|No(?:Patch|Source)|Obsoletes|Packager|Patch\d*|Prefix(?:es)?|Provides|(?:Build)?Recommends|Release|RHNPlatform|Serial|Source\d*|(?:Build)?Suggests|Summary|(?:Build)?Supplements|(?:Bug)?URL|Vendor|Version)(?:\([^)]+\))?:)\s*\S', re.IGNORECASE) diff --git a/test/source/valid-exception-in-grouping-1.0-1.src.rpm b/test/source/valid-exception-in-grouping-1.0-1.src.rpm new file mode 100644 index 0000000000000000000000000000000000000000..c74b2f048a8d45b224df143f7a77f75d21eba87c GIT binary patch literal 6615 zcmeI0d2AF_9LL`tYB?^B-%10R)j40whud2@sEvN(e{fwp7bu1rdSz`?U{56EX2$capc?{mk$8uHT!T zO}@?RE*$j{;vt@?RwPUVtj1x9R5%_Bgkyoqs(5uG9IFh3f?^;<{`K;Z`~IHu)`mt8 zzxMzknOop{E;RgJ2bu{}cLBX08eWj==?02Cw4Hs8pnhl(&Od=df0BR({e2ffG5#7f z=0>O><#FLNZ2X)5L=W4w;@L>^zu8P5Up_i?76xW4_I8Ru^}yPUCJu)l}i1I6(VbN-UYv3?jo z1B&CH;(Qhq@_kvH&$q{YLy+^yJ^W4rekTc$3YJU>ZoEn;4LdBBWJ1cS6sCn!lLRX! z+%Zapa7?g-+g9m+>IA<4>Qy#H<5h`C;TQ|1SUhIMEXPVkf-#nY_2QB@RQ!2cC{58I z8B#Q+G$4UD8;?b%3uR-4zwr2yiejNW6~LQ!R*P2dP+`>Q0^x~q1pzsbAF-;Fj8w!a z6`rk*M8NH3RYFcGIwLO;x8pTICmziuMOKt0$)r>&k<1=3g4I~jM1*08K!@rYQe$W@ zXv*z%*4DM{XLX2$43(KwQcT-6Ma6Yw$5v%ma&%GBsVkX^tDDS}R9m*0?nunF3`eDs zEXk@ZiS6SN0Tx5B!TYiGUZ(~RK}T#=iD)Ej56O>56ICpkWVA3GVWV*iLkW-Joq}*B z95CFIgJMtte_IJ^Z9caW4Cz6zyQ$}7-ne*_31u-RMRUAq)I* znOeO18DdDcWs@nkLJbQ}&$1O6z|=z;(;QWnMb)xI$xAG z)&9rT+IjyI~m zI<4P=#ixevY{(e&(PCwPgVICVT>WM(yE1)N;PA<}A34)oUcI;DHb*|?ESzvLYgN;! zf!&V`-b8BmvSiuRHN6+qe3dbHLSe6U^ZM3D2cK9| zxwGlSxr-h0mkOP;b}j!pFzE8;ik7~OlRs$~pnN}9oV9oH&nFfY6%RjPpKWdFfA#Fm f-9H}c^;`3rX{W~zTe@S*l@7<2XFs