From 76d22afbf34a60be8b91c7a2ca5f698a63420278 Mon Sep 17 00:00:00 2001 From: Caleb Mazalevskis Date: Wed, 9 Aug 2017 02:38:01 +0800 Subject: [PATCH] v0.1.0 --- Changelog.txt | 16 ++++++++++++++++ _docs/readme.en.md | 6 +++--- sigtool.php | 12 +++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 Changelog.txt diff --git a/Changelog.txt b/Changelog.txt new file mode 100644 index 0000000..fc07f05 --- /dev/null +++ b/Changelog.txt @@ -0,0 +1,16 @@ +SigTool Changelog. + +=== VERSIONING GUIDELINES === +SigTool adheres to the SemVer guidelines for versioning. + +Versioning guidelines for SemVer can be found at: http://www.semver.org/ + +=== Changes made since last versioned release === + +(none) + +=== Version/Release 0.1.0 === +FIRST TAGGED RELEASE. + +Caleb M (Maikuolan), +8th August 2017. diff --git a/_docs/readme.en.md b/_docs/readme.en.md index 49bd264..f275a2f 100644 --- a/_docs/readme.en.md +++ b/_docs/readme.en.md @@ -80,12 +80,12 @@ clamav_swf_regex.db | Targets SWF files; Works with raw data; Signatures can con - __db__: Standard signature files (these are extracted from the `.ndb` signature files contained by `daily.cvd` and `main.cvd`). Signature files that work directly with file content use this extension. - __fdb__: Filename signature files (the ClamAV signatures database formerly supported filename signatures, but doesn't anymore; SigTool doesn't generate any signature files using this extension; maintained due to continued usefulness for phpMussel). Signature files that work with filenames use this extension. - __hdb__: Hash signature files (these are extracted from the `.hdb` signature files contained by `daily.cvd` and `main.cvd`). Signature files that work with file hashes use this extension. -- __htdb__: HTML signature files (these are extracted from the `.ndb` signature files contained by `daily.cvd` and `main.cvd`). Signature files that work with HTML content use this extension. +- __htdb__: HTML signature files (these are extracted from the `.ndb` signature files contained by `daily.cvd` and `main.cvd`). Signature files that work with HTML-normalised content use this extension. - __mdb__: PE sectional signature files (these are extracted from the `.mdb` signature files contained by `daily.cvd` and `main.cvd`). Signature files that work with PE sectional metadata use this extension. - __medb__: PE extended signature files (this is a homebrew format created for phpMussel, and has nothing to do with the ClamAV signatures database; SigTool doesn't generate any signature files using this extension; these are written manually for the `phpMussel/Signatures` repository). Signature files that work with PE metadata (other than PE sectional metadata) use this extension. -- __ndb__: Normalised signature files (these are extracted from the `.ndb` signature files contained by `daily.cvd` and `main.cvd`). Signature files that work with normalised file content use this extension. +- __ndb__: Normalised signature files (these are extracted from the `.ndb` signature files contained by `daily.cvd` and `main.cvd`). Signature files that work with ANSI-normalised file content use this extension. - __udb__: URL signature files (this is a homebrew format created for phpMussel, and has nothing to do with the ClamAV signatures database; SigTool doesn't *currently* generate any signature files using this extension, although this may change in the future; currently, these are written manually for the `phpMussel/Signatures` repository). Signature files that work with URLs use this extension. -- __ldb__: Logical signature files (these will *eventually*, for a future SigTool version, be extracted from the `.ldb` signature files contained by `daily.cvd` and `main.cvd`, but aren't supported by SigTool or phpMussel). Signature files that work with various logical rules use this extension. +- __ldb__: Logical signature files (these will *eventually*, for a future SigTool version, be extracted from the `.ldb` signature files contained by `daily.cvd` and `main.cvd`, but aren't yet supported by SigTool or phpMussel). Signature files that work with various logical rules use this extension. --- diff --git a/sigtool.php b/sigtool.php index 2a7b403..f6b25d3 100644 --- a/sigtool.php +++ b/sigtool.php @@ -1,6 +1,6 @@ . @@ -16,7 +16,7 @@ class SigTool { /** Script version. */ - public $Ver = '0.0.4-ALPHA'; + public $Ver = '0.1.0'; /** Script user agent. */ public $UA = 'SigTool v%s (https://github.com/phpMussel/SigTool)'; @@ -394,7 +394,7 @@ public function fixPath($Path) { /** L10N. */ $L10N = [ 'Help' => - " SigTool v0.0.4-ALPHA (last modified: 2017.08.08).\n" . + " SigTool v0.1.0 (last modified: 2017.08.08).\n" . " Generates signatures for phpMussel using main.cvd and daily.cvd from ClamAV.\n\n" . " Syntax:\n" . " \$ php sigtool.php [arguments]\n" . @@ -664,6 +664,9 @@ public function fixPath($Path) { $RemSize -= $SigTool->SafeReadSize; $FileData = fread($Handle, $SigTool->SafeReadSize) . $FileData; } + if ($RemSize < 1 && substr($FileData, -1, 1) !== "\n" && ($EoF = strrpos($FileData, "\n")) !== false) { + $FileData = substr($FileData, 0, $EoF) . "\n"; + } fclose($Handle); echo $L10N['Done']; } @@ -679,6 +682,9 @@ public function fixPath($Path) { /** Apply shorthand to signature names and remove any unwanted lines. */ $SigTool->shorthand($FileData); + /** Remove erroneous lines. */ + $FileData = preg_replace('~^(?!phpMussel|\n)[^\x1A\n]+$\n~im', '', $FileData); + /** Write to file. */ if (!is_resource($Handle = fopen($SigTool->fixPath(__DIR__ . '/' . $Set[4]), 'wb'))) { $Terminate();