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