Skip to content

Commit 3ef2361

Browse files
committed
Adopt GitHub Actions; Replace Tests.
Changelog excerpt: - Ditched external test frameworks in favour of GitHub Actions. Replaced existing tests. (More work needs to eventually be done towards tests. This will eventually happen at some point).
1 parent c5136d7 commit 3ef2361

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+123
-411
lines changed

.github/workflows/core.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: core
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.operating-system }}
8+
9+
strategy:
10+
matrix:
11+
operating-system: [ubuntu-latest]
12+
php-versions: ['7.2', '7.3', '7.4']
13+
name: PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Set up PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php-versions }}
22+
# See: https://github.com/shivammathur/setup-php/wiki
23+
# Ability to test phpMussel's lzf and rar support would be nice too, but those extensions aren't supported by any
24+
# version of shivammathur/setup-php yet. :-)
25+
extensions: pcre, apcu, bz2, curl, zip
26+
27+
- name: Validate composer.json and composer.lock
28+
run: composer validate
29+
30+
- name: Install dependencies
31+
run: composer install --prefer-dist --no-progress
32+
33+
- name: Run tests
34+
run: composer run-script --timeout=360 test

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
/vendor
2-
/vault/cache/*
3-
/vault/config.ini
4-
/vault/fe_assets/frontend.dat
5-
/vault/scan_log.txt
6-
/vault/scan_log_serialized.txt
7-
/vault/signatures/*
8-
!/vault/signatures/switch.dat

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
2525
### v3.1.0
2626

2727
[2020.11.20; Maikuolan]: Added partial support for detecting objects and files embedded within pdf files (due to the nature of how this has been implemented, for the purpose of scanning these embedded objects and files, phpMussel will regard pdf as an archive format; this is intentional).
28+
29+
[2020.11.26; Maikuolan]: Ditched external test frameworks in favour of GitHub Actions. Replaced existing tests. (More work needs to eventually be done towards tests. This will eventually happen at some point).

codeception.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

composer.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,19 @@
1616
"ext-pcre": "*"
1717
},
1818
"suggest": {
19+
"ext-apcu": "*",
1920
"ext-bz2": "*",
2021
"ext-curl": "*",
2122
"ext-lzf": "*",
2223
"ext-rar": "*",
2324
"ext-zip": "*"
2425
},
25-
"require-dev": {
26-
"codeception/codeception": "^2.3",
27-
"symfony/event-dispatcher": "3.4.28"
26+
"scripts": {
27+
"test": "@php tests.php"
2828
},
2929
"autoload": {
3030
"psr-4": {
3131
"phpMussel\\Core\\": "src/"
3232
}
33-
},
34-
"autoload-dev": {
35-
"psr-4": {
36-
"phpMussel\\Core\\Tests\\": "tests/"
37-
}
3833
}
3934
}

src/TarHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Tar handler (last modified: 2020.11.19).
11+
* This file: Tar handler (last modified: 2020.11.20).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -117,7 +117,7 @@ public function EntryIsEncrypted(): bool
117117
*
118118
* @return false Tar doesn't provide internal CRCs.
119119
*/
120-
public function EntryCRC()
120+
public function EntryCRC(): bool
121121
{
122122
return false;
123123
}

tests.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
// Suppress unexpected errors from output and exit early as a failure when encountered.
3+
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
4+
exit(1);
5+
});
6+
7+
// Need this to find the package's own files (since it isn't installing itself).
8+
spl_autoload_register(function ($Class) {
9+
$Class = explode('\\', $Class, 3);
10+
$Count = count($Class);
11+
if ($Count !== 3 || $Class[0] !== 'phpMussel' || $Class[1] !== 'Core') {
12+
return;
13+
}
14+
$Class = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $Class[2]);
15+
$Try = __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $Class . '.php';
16+
if (is_readable($Try)) {
17+
require $Try;
18+
}
19+
});
20+
21+
$Autoloader = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
22+
if (!is_readable($Autoloader)) {
23+
exit(2);
24+
}
25+
require $Autoloader;
26+
27+
// Path to all tests data.
28+
$TestsPath = __DIR__ . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR;
29+
30+
// Fetch the signatures needed for testing the scanner.
31+
$ZipObj = new \ZipArchive();
32+
if ($ZipObj->open($TestsPath . 'signatures.zip') === TRUE) {
33+
$ZipObj->extractTo($TestsPath . 'signatures' . DIRECTORY_SEPARATOR);
34+
$ZipObj->close();
35+
unset($ZipObj);
36+
$SigPath = $TestsPath . 'signatures';
37+
} else {
38+
exit(3);
39+
}
40+
41+
$Samples = $TestsPath . 'samples';
42+
43+
$Config = $TestsPath . 'phpmussel.yml';
44+
if (!is_readable($Config) || !is_readable($Samples) || !is_readable($SigPath)) {
45+
exit(4);
46+
}
47+
48+
$Loader = new \phpMussel\Core\Loader($Config, '', '', $SigPath);
49+
$Scanner = new \phpMussel\Core\Scanner($Loader);
50+
51+
// Expected results from scanning the phpMussel test samples.
52+
$Expected = [
53+
'1043d8e6c0deb7f7264952a163cbfe9f724251064f9c9d2ccbb3996ea79ebe1c:20882:pdf_standard_testfile.pdf' => 'Detected phpMussel-Testfile.PDF.Standard (pdf_standard_testfile.pdf)!',
54+
'14fb5b708076142cf38131ccc3827ff0a0ff28db1ee5db4583432cadafc8a4bf:658:ole_testfile.bin' => 'Detected phpMussel-Testfile.OLE.Standard (ole_testfile.bin)!',
55+
'4b4e349e8103d105b8dd0f5fce5ec9be0b263d203597e87abf3644089aea095f:19:hash_testfile_md5.txt' => 'Detected phpMussel-Testfile.HASH.MD5 (hash_testfile_md5.txt)!',
56+
'8b4413ceca5ba8b33f1af7d1ce82a108f26be2e3de9241ca9969ea47214a180a:5632:pe_sectional_testfile.exe' => 'Detected phpMussel-Testfile.PE.Sectional (pe_sectional_testfile.exe)!',
57+
'8e39388e6e605902d1192aecc5ea77f9a62547eb164562266c0060cf52cb6ec9:653:general_standard_testfile.txt' => 'Detected phpMussel-Testfile.General.Standard (general_standard_testfile.txt)!',
58+
'a00178f9d85e56c8067c5d6c234a48afd6631c9e3c90fe0717f4b7330360ef3b:5632:exe_standard_testfile.exe' => 'Detected phpMussel-Testfile.EXE.Standard (exe_standard_testfile.exe)!',
59+
'bf059f3112049d7299f9dc39397fe721c560e790611bfdc163adadbebb4e9ca9:13:hello.txt' => '',
60+
'c845b950f38399ae7fe4b3107cab5b46ac7c3e184dddfec97d4d164c00cb584a:491:coex_testfile.rtf' => 'Detected phpMussel-Testfile.CoEx (coex_testfile.rtf)!',
61+
'c8ff1888b2802f8824a59191d4ad0a7f5261840541044ca5313fd4ca0962063b:20:hash_testfile_sha1.txt' => 'Detected phpMussel-Testfile.HASH.SHA1 (hash_testfile_sha1.txt)!',
62+
'd188d46c87f2174c78ed4aaf8b0d24bfafc684c789df36572110355f59443ff7:632:graphics_standard_testfile.gif' => 'Detected phpMussel-Testfile.Graphics.Standard (graphics_standard_testfile.gif)!',
63+
'd1e1ec9461e107beee203d2c7f909d0dab026046a89d5b9a84bece02b5b93ca9:31662:swf_standard_testfile.swf' => 'Detected phpMussel-Testfile.SWF.Standard (swf_standard_testfile.swf)!',
64+
'd45d5d9df433aefeacaece6162b835e6474d6fcb707d24971322ec429707c58f:185:encrypted.zip' => 'Detected encrypted archive; Encrypted archives not permitted (encrypted.zip)!',
65+
'dcacac499064454218823fbabff7e09b5b011c0c877ee6f215f35bffb195b6e9:654:ascii_standard_testfile.txt' => 'Detected phpMussel-Testfile.ASCII.Standard (ascii_standard_testfile.txt)!',
66+
'f90054161ed9c4ffcda720769cb1c563eb0fd0e770004db352c4e225522e9a93:22:hash_testfile_sha256.txt' => 'Detected phpMussel-Testfile.HASH.SHA256 (hash_testfile_sha256.txt)!',
67+
'fbb49f897c8f8310f6c5ecacbd541d6873b18c7119ba71688d1bcdd3d7ea98fe:1488:html_standard_testfile.html' => 'Detected phpMussel-Testfile.HTML.Standard (html_standard_testfile.html)!',
68+
];
69+
70+
// Test scanning against the standard phpMussel test samples.
71+
$Actual = $Scanner->scan($Samples, 3);
72+
ksort($Actual);
73+
if ($Actual !== $Expected) {
74+
exit(5);
75+
}
76+
77+
restore_error_handler();
78+
79+
// All tests passed.
80+
exit(0);

tests/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/_data/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)