Skip to content

Commit fbc3614

Browse files
authored
Release 1.4.1 (#93)
2 parents 57df987 + dd4e488 commit fbc3614

15 files changed

+225
-73
lines changed

CHANGELOG.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Changelog
22

3-
### 1.4.0 ###
4-
* **English**
5-
* Option to provide a custom key for the Google Safe Browsing API
6-
* Scan files of parent theme if a child theme is active
7-
* Verify checksums of WP core files (integrated functionality from _Checksum Verifier_ plugin)
8-
* Ability to enable _Safe Browsing_ and _Checksum Verifier_ as cronjob without Theme scan
9-
* **Deutsch**
10-
* Möglichkeit einen eigenen Schlüssel für die Google Safe Browsing API zu verwenden
11-
* Dateien des übergeordneten Themes scannen, falls ein Child-Theme aktiv ist
12-
* Verifiziere Prüfsummen der WP Core Dateien (Funktionalität des _Checksum Verifier_ Plugins integriert)
13-
* Möglichkeit _Safe Browsing_ und _Checksum Verifier_ als Cronjob ohne Theme-Scan zu aktivieren
3+
### 1.4.1 ###
4+
* Fix some spelling mistakes and correct translations (#85)
5+
* Fix file name sanitization in manual theme scan causing errors to be not shown in the admin area (#88, #89)
6+
* Fix theme file collection for child themes with duplicate names (#86)
7+
* Consider all levels in theme file check instead of one only (#87, #90)
8+
* Support translations in old WordPress versions (#91)
149

10+
### 1.4.0 ###
11+
* Option to provide a custom key for the Google Safe Browsing API (#69)
12+
* Scan files of parent theme if a child theme is active (#1, #62)
13+
* Verify checksums of WP core files (integrated functionality from _Checksum Verifier_ plugin (#5, #56)
14+
* Allow to enable _Safe Browsing_ and _Checksum Verifier_ as cronjob without theme scan (#66)
15+
* Update code style check and add build script (#68)
1516

1617
### 1.3.10 ###
1718
* **English**

README.md

+21-22
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,28 @@
22
* Contributors: pluginkollektiv
33
* Tags: antivirus, malware, scanner, phishing, safe browsing, vulnerability
44
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW
5-
* Requires at least: 4.6
5+
* Requires at least: 4.1
66
* Requires PHP: 5.2
77
* Tested up to: 5.6
8-
* Stable tag: 1.4.0
8+
* Stable tag: 1.4.1
99
* License: GPLv2 or later
1010
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

1212
Security plugin to protect your blog or website against exploits and spam injections.
1313

1414
## Description ##
15-
*AntiVirus for WordPress* is a easy-to-use, safe tool to harden your WordPress site against exploits, malware and spam injections.
16-
You can configure *AntiVirus* to perform an automated daily scan of your theme files. If the plugin happens to detect any suspicious code injections, it will send out a notification to a previously configured e-mail address.
15+
*AntiVirus* is an easy-to-use, safe tool to harden your WordPress site against exploits, malware and spam injections.
16+
You can configure *AntiVirus* to perform an automated daily scan of your theme files. If the plugin detects any suspicious code injections, it will send out a notification to a previously configured e-mail address.
1717

1818
In case your WordPress site has been hacked, *AntiVirus* will help you to become aware of the problem very quickly in order for you to take immediate action.
1919

2020
### Features ###
21-
* Virus alert in the admin bar
22-
* Cleaning up after plugin removal
23-
* Daily scan with email notifications
24-
* Theme template checks
25-
* Whitelist solution: Mark suspected cases as "no virus"
26-
* Manual check of template files with alerts on suspected cases
21+
* Scan for suspicious code in the theme files (daily scan with email notifications and manual scan) with an option to mark detected cases as false positive
22+
* Checksum verification for WordPress Core files
2723
* Optional: Google Safe Browsing for malware and phishing monitoring.
2824

25+
A complete documentation is available on the [AntiVirus website](https://antivirus.pluginkollektiv.org/documentation/).
26+
2927
### Support ###
3028
* Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/antivirus)
3129
* We don’t handle support via e-mail, Twitter, GitHub issues etc.
@@ -38,23 +36,24 @@ In case your WordPress site has been hacked, *AntiVirus* will help you to become
3836

3937
### Credits ###
4038
* Author: [Sergej Müller](https://sergejmueller.github.io/)
41-
* Maintainers: [pluginkollektiv](http://pluginkollektiv.org/)
42-
43-
44-
## Frequently Asked Questions ##
39+
* Maintainers: [pluginkollektiv](https://pluginkollektiv.org)
4540

46-
### Will AntiVirus protect my site from being hacked? ###
47-
Not literally "protect from". The plugin’s purpose is to *detect* any "hack" that has already happened and enable you to take immediate action upon it.
48-
49-
A complete documentation is available on the [AntiVirus website](https://antivirus.pluginkollektiv.org/documentation/).
5041

5142
## Changelog ##
5243

44+
### 1.4.1 ###
45+
* Fix some spelling mistakes and correct translations (#85)
46+
* Fix file name sanitization in manual theme scan causing errors to be not shown in the admin area (#88, #89)
47+
* Fix theme file collection for child themes with duplicate names (#86)
48+
* Consider all levels in theme file check instead of one only (#87, #90)
49+
* Support translations in old WordPress versions (#91)
50+
5351
### 1.4.0 ###
54-
* Option to provide a custom key for the Google Safe Browsing API
55-
* Scan files of parent theme if a child theme is active
56-
* Verify checksums of WP core files (integrated functionality from _Checksum Verifier_ plugin)
57-
* Ability to enable _Safe Browsing_ and _Checksum Verifier_ as cronjob without Theme scan
52+
* Option to provide a custom key for the Google Safe Browsing API (#69)
53+
* Scan files of parent theme if a child theme is active (#1, #62)
54+
* Verify checksums of WP core files (integrated functionality from _Checksum Verifier_ plugin (#5, #56)
55+
* Allow to enable _Safe Browsing_ and _Checksum Verifier_ as cronjob without theme scan (#66)
56+
* Update code style check and add build script (#68)
5857

5958
### 1.3.10 ###
6059
* Updated PayPal link for donations

antivirus.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
* Text Domain: antivirus
99
* License: GPLv2 or later
1010
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
11-
* Version: 1.4.0
12-
*
13-
* [](http://coderisk.com/wp/plugin/antivirus/RIPS-x1EDAuZC-C)
11+
* Version: 1.4.1
1412
*
1513
* @package AntiVirus
1614
*/

inc/class-antivirus-checkinternals.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private static function _php_match_pattern() {
165165
*
166166
* @return array|bool An array of matched lines or false on failure.
167167
*/
168-
private static function _check_file_line( $line = '', $num ) {
168+
private static function _check_file_line( $line, $num ) {
169169
// Trim value.
170170
$line = trim( (string) $line );
171171

inc/class-antivirus-checksumverifier.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function verify_files() {
3636
esc_html__( 'Checksum Verifier Alert', 'antivirus' ),
3737
sprintf(
3838
"%s:\r\n\r\n- %s",
39-
esc_html__( 'Official checksums do not match for the following files', 'antivirus' ),
39+
esc_html__( 'Checksums do not match for the following files', 'antivirus' ),
4040
implode( "\r\n- ", $matches )
4141
)
4242
);

inc/class-antivirus-safebrowsing.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function check_safe_browsing() {
4444
array(
4545
'client' => array(
4646
'clientId' => 'wpantivirus',
47-
'clientVersion' => '1.4.0',
47+
'clientVersion' => '1.4.1',
4848
),
4949
'threatInfo' => array(
5050
'threatTypes' => array(
@@ -92,8 +92,8 @@ public static function check_safe_browsing() {
9292
// Invalid request (most likely invalid key) or expired/exceeded key.
9393
$mail_body = sprintf(
9494
"%s\r\n\r\n%s",
95-
esc_html__( 'Checking yout site against the Google Safe Browsing API has failed.', 'antivirus' ),
96-
esc_html__( 'This does not mean that your site has been infected, but that the status could not be determinined.', 'antivirus' )
95+
esc_html__( 'Checking your site against the Google Safe Browsing API has failed.', 'antivirus' ),
96+
esc_html__( 'This does not mean that your site has been infected, but that the status could not be determined.', 'antivirus' )
9797
);
9898

9999
// Add (sanitized) error message, if available.
@@ -109,12 +109,12 @@ public static function check_safe_browsing() {
109109
if ( $custom_key ) {
110110
$mail_body .= sprintf(
111111
"\r\n%s",
112-
esc_html__( 'Please check if your API key is correct and its limit not exceeded. If everything is correct and the error persists for the next requests, please contact the Plugin support.', 'antivirus' )
112+
esc_html__( 'Please check if your API key is correct and its limit not exceeded. If everything is correct and the error persists for the next requests, please contact the plugin support.', 'antivirus' )
113113
);
114114
} else {
115115
$mail_body .= sprintf(
116116
"\r\n%s",
117-
esc_html__( 'This might be due to an exceeded rate limit on the shared API key. To ensure this does not happen please consider providing your own key using the Plugin settings page.', 'antivirus' )
117+
esc_html__( 'This might be due to an exceeded rate limit on the shared API key. To ensure this does not happen please provide your own key using the settings page.', 'antivirus' )
118118
);
119119
}
120120

inc/class-antivirus.php

+11-18
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public static function init() {
4444
// Save the plugin basename.
4545
self::$base = plugin_basename( ANTIVIRUS_FILE );
4646

47+
// Load translations. Required due to support for WP versions before 4.6.
48+
load_plugin_textdomain( 'antivirus' );
49+
4750
// Register the daily cronjob.
4851
add_action( 'antivirus_daily_cronjob', array( __CLASS__, 'do_daily_cronjob' ) );
4952

@@ -393,7 +396,7 @@ private static function _get_theme_data( $theme ) {
393396
// Extract data.
394397
$name = $theme->get( 'Name' );
395398
$slug = $theme->get_stylesheet();
396-
$files = $theme->get_files( 'php', 1 );
399+
$files = array_values( $theme->get_files( 'php', -1 ) );
397400

398401
// Append parent's data, if we got a child theme.
399402
$parent = self::_get_theme_data( $theme->parent() );
@@ -520,7 +523,7 @@ public static function get_ajax_response() {
520523

521524
case 'check_theme_file':
522525
if ( ! empty( $_POST['_theme_file'] ) ) {
523-
$theme_file = sanitize_file_name( wp_unslash( $_POST['_theme_file'] ) );
526+
$theme_file = filter_var( wp_unslash( $_POST['_theme_file'] ), FILTER_SANITIZE_STRING );
524527
$lines = AntiVirus_CheckInternals::check_theme_file( $theme_file );
525528
if ( $lines ) {
526529
foreach ( $lines as $num => $line ) {
@@ -719,12 +722,12 @@ public static function show_admin_menu() {
719722

720723
<p class="description">
721724
<?php
722-
/* translators: Link for transparency report in english */
725+
/* translators: Link for transparency report */
723726
$start_tag = sprintf( '<a href="%s">', esc_attr__( 'https://transparencyreport.google.com/safe-browsing/search?hl=en', 'antivirus' ) );
724727
$end_tag = '</a>';
725728
echo wp_kses(
726-
/* translators: First placeholder (%s) starting link tag to transparency report, second placeholder closing link tag */
727-
sprintf( __( 'Diagnosis and notification in suspicion case. For more details read %1$s the transparency report %2$s.', 'antivirus' ), $start_tag, $end_tag ),
729+
/* translators: First placeholder (%1$s) starting link tag to transparency report, second placeholder (%2$s) closing link tag */
730+
sprintf( __( 'Diagnosis and notification in suspicion case. For more details read %1$sthe transparency report%2$s.', 'antivirus' ), $start_tag, $end_tag ),
728731
array( 'a' => array( 'href' => array() ) )
729732
);
730733
?>
@@ -752,13 +755,11 @@ public static function show_admin_menu() {
752755
<label for="av_checksum_verifier">
753756
<input type="checkbox" name="av_checksum_verifier" id="av_checksum_verifier"
754757
value="1" <?php checked( self::_get_option( 'checksum_verifier' ), 1 ); ?> />
755-
<?php esc_html_e( 'Checksum verification of WP core files', 'antivirus' ); ?>
758+
<?php esc_html_e( 'Checksum verification of WordPress core files', 'antivirus' ); ?>
756759
</label>
757760

758761
<p class="description">
759-
<?php
760-
esc_html_e( 'Matches checksums of all WordPress core files against the values provided by the official API.', 'antivirus' );
761-
?>
762+
<?php esc_html_e( 'Matches checksums of all WordPress core files against the values provided by the official API.', 'antivirus' ); ?>
762763
</p>
763764
</fieldset>
764765

@@ -772,7 +773,7 @@ class="regular-text"
772773
placeholder="<?php esc_attr_e( 'Email address for notifications', 'antivirus' ); ?>" />
773774

774775
<p class="description">
775-
<?php esc_html_e( 'If the field is empty, the blog admin will be notified', 'antivirus' ); ?>
776+
<?php esc_html_e( 'If the field is empty, the blog admin will be notified.', 'antivirus' ); ?>
776777
</p>
777778
</fieldset>
778779
</td>
@@ -792,14 +793,6 @@ class="regular-text"
792793
?>
793794
&bull;
794795
<?php
795-
printf(
796-
'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
797-
esc_attr__( 'https://wordpress.org/plugins/antivirus/faq/', 'antivirus' ),
798-
esc_html__( 'FAQ', 'antivirus' )
799-
);
800-
?>
801-
&bull;
802-
<?php
803796
printf(
804797
'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
805798
'https://antivirus.pluginkollektiv.org/documentation/',

phpcs.xml

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0"?>
22
<ruleset name="AntiVirus">
3-
<description>Sniffs for the coding standards of the plugin</description>
3+
<description>Sniffs for the coding standards of the plugin</description>
44

5-
<arg value="psvn"/>
6-
<arg name="colors"/>
5+
<arg value="psvn"/>
6+
<arg name="colors"/>
77

8-
<!-- Files to sniff -->
9-
<file>antivirus.php</file>
10-
<file>inc</file>
8+
<!-- Files to sniff -->
9+
<file>antivirus.php</file>
10+
<file>inc</file>
1111
<file>tests</file>
1212

13-
<!-- Extend from WPCS ruleset -->
14-
<config name="minimum_supported_wp_version" value="4.6"/>
15-
<rule ref="WordPress"/>
13+
<!-- Extend from WPCS ruleset -->
14+
<config name="minimum_supported_wp_version" value="4.1"/>
15+
<rule ref="WordPress"/>
1616

1717
<!-- Verify i18n text domain -->
1818
<rule ref="WordPress.WP.I18n">
@@ -26,9 +26,9 @@
2626
<exclude-pattern>tests</exclude-pattern>
2727
</rule>
2828

29-
<!-- PHP compatibility level -->
30-
<config name="testVersion" value="5.2-"/>
31-
<rule ref="PHPCompatibility">
29+
<!-- PHP compatibility level -->
30+
<config name="testVersion" value="5.2-"/>
31+
<rule ref="PHPCompatibility">
3232
<exclude-pattern>tests</exclude-pattern>
3333
</rule>
3434
</ruleset>

tests/antivirustestcase.php

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ abstract class AntiVirus_TestCase extends WP_Mock\Tools\TestCase {
3535
public function setUp(): void {
3636
WP_Mock::setUp();
3737

38+
WP_Mock::passthruFunction( 'load_plugin_textdomain' );
3839
WP_Mock::passthruFunction( 'wp_parse_args' );
3940
WP_Mock::userFunction( 'get_option' )->with( 'antivirus' )->andReturnUsing(
4041
function () {

tests/bootstrap.php

+85
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,92 @@
88
// phpcs:ignore Squiz.Commenting.FileComment.Missing
99
require_once __DIR__ . '/../vendor/autoload.php';
1010

11+
// Override WP_CONTENT_DIR to use own resources instead of WP_Mock dummy files.
12+
define( 'WP_CONTENT_DIR', __DIR__ . '/resources' );
13+
1114
WP_Mock::bootstrap();
1215

1316
require_once __DIR__ . '/antivirustestcase.php';
1417
require_once __DIR__ . '/../inc/class-antivirus.php';
18+
19+
/**
20+
* Class WP_Theme_Mock.
21+
*
22+
* Mock-implementation of {@link WP_Theme}.
23+
*/
24+
class WP_Theme_Mock {
25+
/**
26+
* Theme data.
27+
*
28+
* @var array
29+
*/
30+
private $data;
31+
32+
/**
33+
* WP_Theme_Mock constructor.
34+
*
35+
* @param string $name Theme name.
36+
* @param string $stylesheet Theme stylesheet name.
37+
* @param array $files Theme files.
38+
* @param WP_Theme_Mock|null $parent Parent theme (optional).
39+
*/
40+
public function __construct( string $name, string $stylesheet, array $files, WP_Theme_Mock $parent = null ) {
41+
$this->data = array(
42+
'Name' => $name,
43+
'stylesheet' => $stylesheet,
44+
'files' => $files,
45+
'parent' => $parent ?? false,
46+
);
47+
}
48+
49+
/**
50+
* Get theme attribute.
51+
*
52+
* @param string $key Attribute key.
53+
*
54+
* @return mixed Attribute value.
55+
*/
56+
public function get( string $key ) {
57+
return $this->data[ $key ] ?? false;
58+
}
59+
60+
/**
61+
* Set theme attribute.
62+
*
63+
* @param string $key Attribute key.
64+
* @param mixed $val Attribute value.
65+
*/
66+
public function set( string $key, $val ): void {
67+
$this->data[ $key ] = $val;
68+
}
69+
70+
/**
71+
* Get stylesheet name.
72+
*
73+
* @return string Stylesheet name.
74+
*/
75+
public function get_stylesheet(): string {
76+
return $this->get( 'stylesheet' );
77+
}
78+
79+
/**
80+
* Get theme files.
81+
*
82+
* @param string $suffix File suffix (ignored here).
83+
* @param int $deptn File hierarchy depth (ignored here).
84+
*
85+
* @return false|mixed
86+
*/
87+
public function get_files( string $suffix, int $deptn ) {
88+
return $this->get( 'files' );
89+
}
90+
91+
/**
92+
* Get parent theme.
93+
*
94+
* @return false|WP_Theme_Mock Parent theme or false.
95+
*/
96+
public function parent() {
97+
return $this->get( 'parent' );
98+
}
99+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test content 1
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test content 2

0 commit comments

Comments
 (0)