Changeset 3171281
- Timestamp:
- 10/18/2024 08:07:21 AM (18 months ago)
- Location:
- gdata-antivirus
- Files:
-
- 4 edited
- 1 copied
-
tags/2.0.5 (copied) (copied from gdata-antivirus/branches/2.0.5)
-
trunk/Readme.txt (modified) (2 diffs)
-
trunk/Vaas/ScanClient.php (modified) (7 diffs)
-
trunk/composer.json (modified) (1 diff)
-
trunk/gdata-antivirus.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
gdata-antivirus/trunk/Readme.txt
r3170097 r3171281 5 5 Tested up to: 6.6 6 6 Requires PHP: 8.1 7 Stable tag: 2.0. 47 Stable tag: 2.0.5 8 8 License: GNU General Public License v3.0 9 9 License URI: https://github.com/GDATASoftwareAG/vaas/blob/main/LICENSE … … 57 57 == Changelog == 58 58 59 = 2.0.5 = 60 * don't connect to the backend for every page load 61 59 62 = 2.0.2 = 60 63 * also fix the bug for another failure case -
gdata-antivirus/trunk/Vaas/ScanClient.php
r3170097 r3171281 20 20 private IGdataAntivirusFileSystem $file_system; 21 21 private AdminNotices $admin_notices; 22 private bool $connected = \false; 22 23 public function __construct(LoggerInterface $logger, \Gdatacyberdefenseag\GdataAntivirus\Vaas\VaasOptions $vaas_options, IGdataAntivirusFileSystem $file_system, AdminNotices $admin_notices) 23 24 { … … 27 28 $this->file_system = $file_system; 28 29 $this->admin_notices = $admin_notices; 29 try {30 $this->Connect();31 } catch (\Exception $e) {32 $this->admin_notices->add_notice($e->getMessage());33 $this->logger->error("VaaS connection failed. Please verify if the VaaS-Url is correct.");34 return;35 }36 30 $plugin_upload_scan_enabled = (bool) get_option('gdatacyberdefenseag_antivirus_options_on_demand_scan_plugin_upload_scan_enabled', \true); 37 31 $media_upload_scan_enabled = (bool) get_option('gdatacyberdefenseag_antivirus_options_on_demand_scan_media_upload_scan_enabled', \true); … … 52 46 } 53 47 } 48 public function reconnect() 49 { 50 $this->connected = \false; 51 $this->connect(); 52 } 54 53 public function connect() 55 54 { 55 if ($this->connected === \true) { 56 return; 57 } 56 58 $options = $this->vaas_options->get_options(); 57 59 $this->vaas = new Vaas($options['vaas_url'], $this->logger, new VaasParameters(\false, \false)); … … 66 68 $this->vaas->connect($client_credentials_grant_authenticator->getToken()); 67 69 } 70 $this->connected = \true; 68 71 } 69 72 public function scan_post($data, $postdata, $unsanitized_postarr) … … 82 85 $post_content = wp_unslash($postdata['post_content']); 83 86 $stream = $this->file_system->get_resource_stream_from_string($post_content); 87 $this->connect(); 84 88 try { 85 89 $verdict = $this->vaas->ForStream($stream); 86 90 } catch (VaasInvalidStateException $e) { 87 91 try { 88 $this-> connect();92 $this->reconnect(); 89 93 $verdict = $this->vaas->ForStream($stream); 90 94 } catch (\Exception $e) { … … 130 134 $commend_content = wp_unslash($commentdata['comment_content']); 131 135 $stream = $this->file_system->get_resource_stream_from_string($commend_content); 136 $this->connect(); 132 137 try { 133 138 $verdict = $this->vaas->ForStream($stream); 134 139 } catch (VaasInvalidStateException $e) { 135 140 try { 136 $this-> connect();141 $this->reconnect(); 137 142 $verdict = $this->vaas->ForStream($stream); 138 143 } catch (\Exception $e) { … … 191 196 public function scan_file($file_path): Verdict 192 197 { 198 $this->connect(); 193 199 try { 194 200 $verdict = $this->vaas->ForFile($file_path)->Verdict; 201 } catch (VaasInvalidStateException $e) { 202 try { 203 $this->reconnect(); 204 $verdict = $this->vaas->ForFile($file_path)->Verdict; 205 } catch (\Exception $e) { 206 $this->logger->debug($e->getMessage()); 207 return Verdict::UNKNOWN; 208 } 195 209 } catch (\Exception $e) { 196 210 $this->logger->debug($e->getMessage()); -
gdata-antivirus/trunk/composer.json
r3170097 r3171281 1 1 { 2 2 "name": "gdatacyberdefenseag\/gdata-antivirus", 3 "version": "2.0. 4",3 "version": "2.0.5", 4 4 "autoload": { 5 5 "psr-4": { -
gdata-antivirus/trunk/gdata-antivirus.php
r3170097 r3171281 12 12 * @wordpress-plugin 13 13 * Plugin Name: G DATA Antivirus 14 * Version: 2.0. 414 * Version: 2.0.5 15 15 * Requires at least: 6.2 16 16 * Tested up to: 6.6
Note: See TracChangeset
for help on using the changeset viewer.