1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ownCloud - Files_antivirus |
4
|
|
|
* |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the COPYING file. |
7
|
|
|
* |
8
|
|
|
* @author Viktar Dubiniuk <[email protected]> |
9
|
|
|
* |
10
|
|
|
* @copyright Viktar Dubiniuk 2015-2018 |
11
|
|
|
* @license AGPL-3.0 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OCA\Files_Antivirus\Db; |
15
|
|
|
|
16
|
|
|
use OCP\AppFramework\Db\Entity; |
17
|
|
|
use JsonSerializable; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class Rule |
21
|
|
|
* |
22
|
|
|
* @package OCA\Files_Antivirus\Db |
23
|
|
|
*/ |
24
|
|
|
class Rule extends Entity implements JsonSerializable { |
25
|
|
|
|
26
|
|
|
/* |
27
|
|
|
* Rule needs to be validated by the exit code returned by scanner |
28
|
|
|
*/ |
29
|
|
|
const RULE_TYPE_CODE = 1; |
30
|
|
|
|
31
|
|
|
/* |
32
|
|
|
* Rule needs to be validated by parsing the scanner output with regexp |
33
|
|
|
*/ |
34
|
|
|
const RULE_TYPE_MATCH = 2; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* |
38
|
|
|
* @var int groupId - used for sorting |
39
|
|
|
*/ |
40
|
|
|
protected $groupId; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @var int statusType - RULE_TYPE_CODE or RULE_TYPE_MATCH defines whether |
45
|
|
|
* rule should be checked by the shell exit code or regexp |
46
|
|
|
*/ |
47
|
|
|
protected $statusType; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
* @var int result - shell exit code for rules |
52
|
|
|
* of the type RULE_TYPE_CODE, 0 otherwise |
53
|
|
|
*/ |
54
|
|
|
protected $result; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* |
58
|
|
|
* @var string match - regexp to match for rules |
59
|
|
|
* of the type RULE_TYPE_MATCH, '' otherwise |
60
|
|
|
*/ |
61
|
|
|
protected $match; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* |
65
|
|
|
* @var string description - shell exit code meaning for rules |
66
|
|
|
* of the type RULE_TYPE_CODE, '' otherwise |
67
|
|
|
*/ |
68
|
|
|
protected $description; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* |
72
|
|
|
* @var int status - file check status. |
73
|
|
|
* SCANRESULT_UNCHECKED, SCANRESULT_INFECTED, SCANRESULT_CLEAN |
74
|
|
|
* are matching Unknown, Infected and Clean files accordingly. |
75
|
|
|
*/ |
76
|
|
|
protected $status; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Pack data into json |
80
|
|
|
* |
81
|
|
|
* @return array |
82
|
|
|
*/ |
83
|
1 |
|
public function jsonSerialize() { |
84
|
|
|
return [ |
85
|
1 |
|
'id' => $this->id, |
86
|
1 |
|
'group_id' => $this->groupId, |
87
|
1 |
|
'status_type' => $this->statusType, |
88
|
1 |
|
'result' => $this->result, |
89
|
1 |
|
'match' => $this->match, |
90
|
1 |
|
'description' => $this->description, |
91
|
1 |
|
'status' => $this->status |
92
|
|
|
]; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|