From e878b69fb37a796c1bc891bdf20f83b8f6649b43 Mon Sep 17 00:00:00 2001 From: Vincent Mihalkovic Date: Tue, 5 May 2026 09:33:25 +0200 Subject: [PATCH] Bump magic strength for C, C++, PHP, and Python to fix misdetection Backport of upstream commits ad925d3e and 41e0b8bc: Rebalance magic detection strengths so C files containing "for (function ..." are no longer misidentified as JavaScript, which caused fapolicyd to block systemtap probe compilation. Resolves: RHEL-153227 --- file-5.47-magic-strength.patch | 282 +++++++++++++++++++++++++++++++++ file.spec | 10 +- 2 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 file-5.47-magic-strength.patch diff --git a/file-5.47-magic-strength.patch b/file-5.47-magic-strength.patch new file mode 100644 index 0000000..66ab8e1 --- /dev/null +++ b/file-5.47-magic-strength.patch @@ -0,0 +1,282 @@ +From 41e0b8bc41140dbc7b2d7bc6409c090be2ad67b7 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas +Date: Fri, 30 May 2025 13:36:08 +0000 +Subject: [PATCH] Rebalance magic detection strengths: JS/HTML/C/C++/PHP/Python + +Combines two upstream commits adapted for file-5.45: + +1. ad925d3e - Reduce JavaScript strength from +30 to +20, bump HTML + from +15 to +30, so HTML beats JavaScript (PR/569). + +2. 41e0b8bc - Bump C, C++, PHP, Python strengths by +15 so C/Python + beat HTML and PHP beats C (PR/642). + +The net effect is: C files containing "for (function ..." are no longer +misidentified as JavaScript, which caused fapolicyd to block systemtap +probe compilation (RHEL-153227). + +Upstream-1: https://github.com/file/file/commit/ad925d3e47373f429a87c1ba9d9269f5c1ad757e +Upstream-2: https://github.com/file/file/commit/41e0b8bc41140dbc7b2d7bc6409c090be2ad67b7 +--- a/magic/Magdir/javascript ++++ b/magic/Magdir/javascript +@@ -19,49 +19,49 @@ + # JavaScript + # The strength is increased to beat the C++ & HTML rules + 0 search "use\x20strict" JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 search 'use\x20strict' JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex module(\\.|\\[["'])exports.*= JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex \^(const|var|let).*=.*require\\( JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex \^export\x20(function|class|default|const|var|let|async)\x20 JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex \\((async\x20)?function[(\x20] JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex \^(import|export).*\x20from\x20 JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex \^(import|export)\x20["']\\./ JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex \^require\\(["'] JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + 0 regex typeof.*[!=]== JavaScript source +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext js + + # React Native minified JavaScript + 0 search/128 __BUNDLE_START_TIME__= React Native minified JavaScript +-!:strength +30 ++!:strength +20 + !:mime application/javascript + !:ext bundle/jsbundle + +--- a/magic/Magdir/sgml ++++ b/magic/Magdir/sgml +@@ -53,11 +53,14 @@ + # avoid misdetection as JavaScript + 0 string/cWt \ HTML document text + !:mime text/html ++!:strength + 30 + 0 string/ct \