From 9c8a677f137b6e7058185444e8e20923d99be84d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 8 Dec 2022 21:37:11 -0800 Subject: [PATCH] Remove now-useless `ShouldScan` --- BurnOutSharp/FileType/BFPK.cs | 9 --- BurnOutSharp/FileType/BZip2.cs | 9 --- BurnOutSharp/FileType/Executable.cs | 34 ----------- BurnOutSharp/FileType/GZIP.cs | 9 --- .../FileType/InstallShieldArchiveV3.cs | 9 --- BurnOutSharp/FileType/InstallShieldCAB.cs | 9 --- BurnOutSharp/FileType/MPQ.cs | 9 --- BurnOutSharp/FileType/MSI.cs | 9 --- BurnOutSharp/FileType/MicrosoftCAB.cs | 9 --- BurnOutSharp/FileType/PKZIP.cs | 22 ------- BurnOutSharp/FileType/PLJ.cs | 10 --- BurnOutSharp/FileType/RAR.cs | 14 ----- BurnOutSharp/FileType/SevenZip.cs | 9 --- BurnOutSharp/FileType/TapeArchive.cs | 12 ---- BurnOutSharp/FileType/Textfile.cs | 61 ------------------- BurnOutSharp/FileType/Valve.cs | 6 -- BurnOutSharp/FileType/XZ.cs | 9 --- BurnOutSharp/Interfaces/IScannable.cs | 7 --- 18 files changed, 256 deletions(-) diff --git a/BurnOutSharp/FileType/BFPK.cs b/BurnOutSharp/FileType/BFPK.cs index 17d06b1e..ddabae6f 100644 --- a/BurnOutSharp/FileType/BFPK.cs +++ b/BurnOutSharp/FileType/BFPK.cs @@ -14,15 +14,6 @@ namespace BurnOutSharp.FileType /// public class BFPK : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x42, 0x46, 0x50, 0x4b })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/BZip2.cs b/BurnOutSharp/FileType/BZip2.cs index 805f0bd3..b9fca270 100644 --- a/BurnOutSharp/FileType/BZip2.cs +++ b/BurnOutSharp/FileType/BZip2.cs @@ -13,15 +13,6 @@ namespace BurnOutSharp.FileType /// public class BZip2 : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x42, 0x52, 0x68 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/Executable.cs b/BurnOutSharp/FileType/Executable.cs index 831b34fe..5092b9c8 100644 --- a/BurnOutSharp/FileType/Executable.cs +++ b/BurnOutSharp/FileType/Executable.cs @@ -14,40 +14,6 @@ namespace BurnOutSharp.FileType /// public class Executable : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - // DOS MZ executable file format (and descendants) - if (magic.StartsWith(new byte?[] { 0x4d, 0x5a })) - return true; - - // Executable and Linkable Format - if (magic.StartsWith(new byte?[] { 0x7f, 0x45, 0x4c, 0x46 })) - return true; - - // Mach-O binary (32-bit) - if (magic.StartsWith(new byte?[] { 0xfe, 0xed, 0xfa, 0xce })) - return true; - - // Mach-O binary (32-bit, reverse byte ordering scheme) - if (magic.StartsWith(new byte?[] { 0xce, 0xfa, 0xed, 0xfe })) - return true; - - // Mach-O binary (64-bit) - if (magic.StartsWith(new byte?[] { 0xfe, 0xed, 0xfa, 0xcf })) - return true; - - // Mach-O binary (64-bit, reverse byte ordering scheme) - if (magic.StartsWith(new byte?[] { 0xcf, 0xfa, 0xed, 0xfe })) - return true; - - // Prefrred Executable File Format - if (magic.StartsWith(new byte?[] { 0x4a, 0x6f, 0x79, 0x21, 0x70, 0x65, 0x66, 0x66 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/GZIP.cs b/BurnOutSharp/FileType/GZIP.cs index c2bbf74c..c2aa86be 100644 --- a/BurnOutSharp/FileType/GZIP.cs +++ b/BurnOutSharp/FileType/GZIP.cs @@ -13,15 +13,6 @@ namespace BurnOutSharp.FileType /// public class GZIP : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x1f, 0x8b })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/InstallShieldArchiveV3.cs b/BurnOutSharp/FileType/InstallShieldArchiveV3.cs index 1389d8e0..909ee265 100644 --- a/BurnOutSharp/FileType/InstallShieldArchiveV3.cs +++ b/BurnOutSharp/FileType/InstallShieldArchiveV3.cs @@ -14,15 +14,6 @@ namespace BurnOutSharp.FileType /// public class InstallShieldArchiveV3 : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x13, 0x5D, 0x65, 0x8C })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/InstallShieldCAB.cs b/BurnOutSharp/FileType/InstallShieldCAB.cs index c1cd7c99..c723fcf1 100644 --- a/BurnOutSharp/FileType/InstallShieldCAB.cs +++ b/BurnOutSharp/FileType/InstallShieldCAB.cs @@ -13,15 +13,6 @@ namespace BurnOutSharp.FileType /// public class InstallShieldCAB : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x49, 0x53, 0x63 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/MPQ.cs b/BurnOutSharp/FileType/MPQ.cs index 4e362320..dfa50ff0 100644 --- a/BurnOutSharp/FileType/MPQ.cs +++ b/BurnOutSharp/FileType/MPQ.cs @@ -12,15 +12,6 @@ namespace BurnOutSharp.FileType /// public class MPQ : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x4d, 0x50, 0x51, 0x1a })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/MSI.cs b/BurnOutSharp/FileType/MSI.cs index 33fdf485..52dc5936 100644 --- a/BurnOutSharp/FileType/MSI.cs +++ b/BurnOutSharp/FileType/MSI.cs @@ -13,15 +13,6 @@ namespace BurnOutSharp.FileType /// public class MSI : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/MicrosoftCAB.cs b/BurnOutSharp/FileType/MicrosoftCAB.cs index 24b09c5a..05df5791 100644 --- a/BurnOutSharp/FileType/MicrosoftCAB.cs +++ b/BurnOutSharp/FileType/MicrosoftCAB.cs @@ -19,15 +19,6 @@ namespace BurnOutSharp.FileType /// Specification available at public class MicrosoftCAB : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x4d, 0x53, 0x43, 0x46 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/PKZIP.cs b/BurnOutSharp/FileType/PKZIP.cs index 92e66aa7..c25c75b1 100644 --- a/BurnOutSharp/FileType/PKZIP.cs +++ b/BurnOutSharp/FileType/PKZIP.cs @@ -13,28 +13,6 @@ namespace BurnOutSharp.FileType /// public class PKZIP : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - // PKZIP (Unknown) - if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x00, 0x00 })) - return true; - - // PKZIP - if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x03, 0x04 })) - return true; - - // PKZIP (Empty Archive) - if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x05, 0x06 })) - return true; - - // PKZIP (Spanned Archive) - if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x07, 0x08 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/PLJ.cs b/BurnOutSharp/FileType/PLJ.cs index d9c02740..6be5de0c 100644 --- a/BurnOutSharp/FileType/PLJ.cs +++ b/BurnOutSharp/FileType/PLJ.cs @@ -11,16 +11,6 @@ namespace BurnOutSharp.FileType /// public class PLJ : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - // https://www.iana.org/assignments/media-types/audio/vnd.everad.plj - if (magic.StartsWith(new byte?[] { 0xFF, 0x9D, 0x53, 0x4B })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/RAR.cs b/BurnOutSharp/FileType/RAR.cs index 26c31288..f9766613 100644 --- a/BurnOutSharp/FileType/RAR.cs +++ b/BurnOutSharp/FileType/RAR.cs @@ -13,20 +13,6 @@ namespace BurnOutSharp.FileType /// public class RAR : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - // RAR archive version 1.50 onwards - if (magic.StartsWith(new byte?[] { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 })) - return true; - - // RAR archive version 5.0 onwards - if (magic.StartsWith(new byte?[] { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/SevenZip.cs b/BurnOutSharp/FileType/SevenZip.cs index d35cc2b5..d7e9d921 100644 --- a/BurnOutSharp/FileType/SevenZip.cs +++ b/BurnOutSharp/FileType/SevenZip.cs @@ -13,15 +13,6 @@ namespace BurnOutSharp.FileType /// public class SevenZip : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/TapeArchive.cs b/BurnOutSharp/FileType/TapeArchive.cs index 96575545..4ba79a73 100644 --- a/BurnOutSharp/FileType/TapeArchive.cs +++ b/BurnOutSharp/FileType/TapeArchive.cs @@ -13,18 +13,6 @@ namespace BurnOutSharp.FileType /// public class TapeArchive : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 })) - return true; - - if (magic.StartsWith(new byte?[] { 0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/Textfile.cs b/BurnOutSharp/FileType/Textfile.cs index d9d9bd49..03e67eaa 100644 --- a/BurnOutSharp/FileType/Textfile.cs +++ b/BurnOutSharp/FileType/Textfile.cs @@ -12,67 +12,6 @@ namespace BurnOutSharp.FileType /// public class Textfile : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - return ShouldScan(magic, null); - } - - /// - /// Determine if a file signature or extension matches one of the expected values - /// - /// Byte array representing the file header - /// Extension for the file being checked - /// True if the signature is valid, false otherwise - public bool ShouldScan(byte[] magic, string extension) - { - // Rich Text File - if (magic.StartsWith(new byte?[] { 0x7b, 0x5c, 0x72, 0x74, 0x66, 0x31 })) - return true; - - // HTML - if (magic.StartsWith(new byte?[] { 0x3c, 0x68, 0x74, 0x6d, 0x6c })) - return true; - - // HTML and XML - if (magic.StartsWith(new byte?[] { 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45 })) - return true; - - // Microsoft Office File (old) - if (magic.StartsWith(new byte?[] { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 })) - return true; - - // InstallShield Compiled Rules - if (magic.StartsWith(new byte?[] { 0x61, 0x4C, 0x75, 0x5A })) - return true; - - // Windows Help File - if (magic.StartsWith(new byte?[] { 0x3F, 0x5F, 0x03, 0x00 })) - return true; - - // "Description in Zip" - if (string.Equals(extension?.TrimStart('.'), "diz", StringComparison.OrdinalIgnoreCase)) - return true; - - // Setup information - if (string.Equals(extension?.TrimStart('.'), "inf", StringComparison.OrdinalIgnoreCase)) - return true; - - // InstallShield Script - if (string.Equals(extension?.TrimStart('.'), "ins", StringComparison.OrdinalIgnoreCase)) - return true; - - // Generic textfile (no header) - if (string.Equals(extension?.TrimStart('.'), "txt", StringComparison.OrdinalIgnoreCase)) - return true; - - // XML (multiple headers possible) - if (string.Equals(extension?.TrimStart('.'), "xml", StringComparison.OrdinalIgnoreCase)) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/Valve.cs b/BurnOutSharp/FileType/Valve.cs index efafc75b..fba83142 100644 --- a/BurnOutSharp/FileType/Valve.cs +++ b/BurnOutSharp/FileType/Valve.cs @@ -13,12 +13,6 @@ namespace BurnOutSharp.FileType /// public class Valve : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - return Package.GetPackageType(magic) != PackageType.HL_PACKAGE_NONE; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/FileType/XZ.cs b/BurnOutSharp/FileType/XZ.cs index e15c86ab..df44620d 100644 --- a/BurnOutSharp/FileType/XZ.cs +++ b/BurnOutSharp/FileType/XZ.cs @@ -12,15 +12,6 @@ namespace BurnOutSharp.FileType /// public class XZ : IScannable { - /// - public bool ShouldScan(byte[] magic) - { - if (magic.StartsWith(new byte?[] { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00 })) - return true; - - return false; - } - /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { diff --git a/BurnOutSharp/Interfaces/IScannable.cs b/BurnOutSharp/Interfaces/IScannable.cs index d4d0a35a..5b2c6833 100644 --- a/BurnOutSharp/Interfaces/IScannable.cs +++ b/BurnOutSharp/Interfaces/IScannable.cs @@ -8,13 +8,6 @@ namespace BurnOutSharp.Interfaces /// internal interface IScannable { - /// - /// Determine if a file signature matches one of the expected values - /// - /// Byte array representing the file header - /// True if the signature is valid, false otherwise - bool ShouldScan(byte[] magic); - /// /// Scan a file for all internal protections ///