1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Zikula package. |
7
|
|
|
* |
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Zikula\SecurityCenterModule\Entity; |
15
|
|
|
|
16
|
|
|
use DateTime; |
17
|
|
|
use Doctrine\ORM\Mapping as ORM; |
18
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
19
|
|
|
use Zikula\Bundle\CoreBundle\Doctrine\EntityAccess; |
20
|
|
|
use Zikula\UsersModule\Entity\UserEntity; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Intrusion |
24
|
|
|
* |
25
|
|
|
* @ORM\Entity(repositoryClass="Zikula\SecurityCenterModule\Entity\Repository\IntrusionRepository") |
26
|
|
|
* @ORM\Table(name="sc_intrusion") |
27
|
|
|
*/ |
28
|
|
|
class IntrusionEntity extends EntityAccess |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* ID of the entity |
32
|
|
|
* |
33
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
34
|
|
|
* @ORM\Id |
35
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
36
|
|
|
* @var int |
37
|
|
|
*/ |
38
|
|
|
private $id; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Name of the entity |
42
|
|
|
* |
43
|
|
|
* @ORM\Column(name="name", type="string", length=128, nullable=false) |
44
|
|
|
* @Assert\Length(min="1", max="128") |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $name; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Tag |
51
|
|
|
* |
52
|
|
|
* @ORM\Column(name="tag", type="string", length=150, nullable=true) |
53
|
|
|
* @Assert\AtLeastOneOf( |
54
|
|
|
* @Assert\Blank(), |
55
|
|
|
* @Assert\Length(min="1", max="150") |
56
|
|
|
* ) |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
private $tag; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Value |
63
|
|
|
* |
64
|
|
|
* @ORM\Column(name="value", type="text", nullable=false) |
65
|
|
|
* @Assert\NotNull |
66
|
|
|
* @var string |
67
|
|
|
*/ |
68
|
|
|
private $value; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Page called when intrusion was detected |
72
|
|
|
* |
73
|
|
|
* @ORM\Column(name="page", type="text", nullable=false) |
74
|
|
|
* @Assert\NotNull |
75
|
|
|
* @var string |
76
|
|
|
*/ |
77
|
|
|
private $page; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* User id assoicated with the intrusion |
81
|
|
|
* |
82
|
|
|
* @ORM\ManyToOne(targetEntity="Zikula\UsersModule\Entity\UserEntity") |
83
|
|
|
* @ORM\JoinColumn(name="uid", referencedColumnName="uid") |
84
|
|
|
*/ |
85
|
|
|
private $user; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Ip address of the intrustion |
89
|
|
|
* |
90
|
|
|
* @ORM\Column(name="ip", type="string", length=40, nullable=false) |
91
|
|
|
* @Assert\Length(min="1", max="40") |
92
|
|
|
* @var string |
93
|
|
|
*/ |
94
|
|
|
private $ip; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Impact |
98
|
|
|
* |
99
|
|
|
* @ORM\Column(name="impact", type="integer", nullable=false) |
100
|
|
|
* @Assert\NotNull |
101
|
|
|
* @var int |
102
|
|
|
*/ |
103
|
|
|
private $impact; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Filters |
107
|
|
|
* |
108
|
|
|
* @ORM\Column(name="filters", type="text", nullable=false) |
109
|
|
|
* @Assert\NotNull |
110
|
|
|
* @var string |
111
|
|
|
*/ |
112
|
|
|
private $filters; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Timestamp of the intrusion |
116
|
|
|
* |
117
|
|
|
* @ORM\Column(name="date", type="datetime", nullable=false) |
118
|
|
|
* @Assert\NotNull |
119
|
|
|
* @var DateTime |
120
|
|
|
*/ |
121
|
|
|
private $date; |
122
|
|
|
|
123
|
|
|
public function getId(): ?int |
124
|
|
|
{ |
125
|
|
|
return $this->id; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function setId(int $id): self |
129
|
|
|
{ |
130
|
|
|
$this->id = $id; |
131
|
|
|
|
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getName(): string |
136
|
|
|
{ |
137
|
|
|
return $this->name; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function setName(string $name): self |
141
|
|
|
{ |
142
|
|
|
$this->name = $name; |
143
|
|
|
|
144
|
|
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function getTag(): string |
148
|
|
|
{ |
149
|
|
|
return $this->tag; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function setTag(string $tag): self |
153
|
|
|
{ |
154
|
|
|
$this->tag = $tag; |
155
|
|
|
|
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function getValue(): string |
160
|
|
|
{ |
161
|
|
|
return $this->value; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function setValue(string $value): self |
165
|
|
|
{ |
166
|
|
|
$this->value = $value; |
167
|
|
|
|
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function getPage(): string |
172
|
|
|
{ |
173
|
|
|
return $this->page; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function setPage(string $page): self |
177
|
|
|
{ |
178
|
|
|
$this->page = $page; |
179
|
|
|
|
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
public function getUser(): UserEntity |
184
|
|
|
{ |
185
|
|
|
return $this->user; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function getUid(): int |
189
|
|
|
{ |
190
|
|
|
return $this->getUser()->getUid(); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function getUsername(): string |
194
|
|
|
{ |
195
|
|
|
return $this->getUser()->getUname(); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
public function setUser(UserEntity $user): self |
199
|
|
|
{ |
200
|
|
|
$this->user = $user; |
201
|
|
|
|
202
|
|
|
return $this; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
public function getIp(): string |
206
|
|
|
{ |
207
|
|
|
return $this->ip; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
public function setIp(string $ip): self |
211
|
|
|
{ |
212
|
|
|
$this->ip = $ip; |
213
|
|
|
|
214
|
|
|
return $this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function getImpact(): int |
218
|
|
|
{ |
219
|
|
|
return $this->impact; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
public function setImpact(int $impact): self |
223
|
|
|
{ |
224
|
|
|
$this->impact = $impact; |
225
|
|
|
|
226
|
|
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
public function getFilters(): string |
230
|
|
|
{ |
231
|
|
|
return $this->filters; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
public function setFilters(string $filters): self |
235
|
|
|
{ |
236
|
|
|
$this->filters = $filters; |
237
|
|
|
|
238
|
|
|
return $this; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
public function getDate(): DateTime |
242
|
|
|
{ |
243
|
|
|
return $this->date; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
public function setDate(DateTime $date): self |
247
|
|
|
{ |
248
|
|
|
$this->date = $date; |
249
|
|
|
|
250
|
|
|
return $this; |
251
|
|
|
} |
252
|
|
|
} |
253
|
|
|
|