diff options
-rw-r--r-- | CHANGELOG.md | 12 | ||||
-rw-r--r-- | appinfo/database.xml | 2 | ||||
-rw-r--r-- | lib/Db/FileOperationMapper.php | 18 | ||||
-rw-r--r-- | tests/Integration/AppTest.php | 2 | ||||
-rw-r--r-- | tests/Unit/Db/FileOperationMapperTest.php | 28 | ||||
-rw-r--r-- | tests/Unit/Service/FileOperationServiceTest.php | 28 |
6 files changed, 51 insertions, 39 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 815aebf..a28d5c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog All notable changes to this project will be documented in this file. +## 0.2.4 + +### Added + +- Added Travis CI. + +## 0.2.3 + +### Fixed + +- Fix CSRF settings. + ## 0.2.2 ### Added diff --git a/appinfo/database.xml b/appinfo/database.xml index 8f2b9b4..8735bc7 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -5,7 +5,7 @@ <overwrite>false</overwrite> <charset>utf8</charset> <table> - <name>*dbprefix*ransomware_detection_file</name> + <name>*dbprefix*ransomware_detection</name> <declaration> <field> <name>id</name> diff --git a/lib/Db/FileOperationMapper.php b/lib/Db/FileOperationMapper.php index 9d78537..7987b02 100644 --- a/lib/Db/FileOperationMapper.php +++ b/lib/Db/FileOperationMapper.php @@ -32,7 +32,7 @@ class FileOperationMapper extends Mapper public function __construct( IDBConnection $db ) { - parent::__construct($db, 'ransomware_detection_file'); + parent::__construct($db, 'ransomware_detection'); } /** @@ -47,7 +47,7 @@ class FileOperationMapper extends Mapper */ public function find($id, $userId) { - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `id` = ? AND `user_id` = ?'; return $this->findEntity($sql, [$id, $userId]); @@ -65,7 +65,7 @@ class FileOperationMapper extends Mapper */ public function findOneByFileName($name, $userId) { - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `original_name` = ? AND `user_id` = ?'; return $this->findEntity($sql, [$name, $userId]); @@ -81,7 +81,7 @@ class FileOperationMapper extends Mapper */ public function findOneWithHighestId($userId) { - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file` WHERE `user_id` = ?'. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'. 'ORDER BY id DESC LIMIT 1'; return $this->findEntity($sql, [$userId]); @@ -97,7 +97,7 @@ class FileOperationMapper extends Mapper */ public function findAll(array $params = [], $limit = null, $offset = null) { - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file` WHERE `user_id` = ?'; + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'; return $this->findEntities($sql, $params, $limit, $offset); } @@ -113,7 +113,7 @@ class FileOperationMapper extends Mapper */ public function findSequenceById(array $params = [], $limit = null, $offset = null) { - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file` WHERE `sequence` = ? AND `user_id` = ?'; + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `sequence` = ? AND `user_id` = ?'; return $this->findEntities($sql, $params, $limit, $offset); } @@ -125,7 +125,7 @@ class FileOperationMapper extends Mapper */ public function deleteById($id, $userId) { - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file` WHERE `id` = ? AND `user_id` = ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `id` = ? AND `user_id` = ?'; $stmt = $this->execute($sql, [$id, $userId]); $stmt->closeCursor(); } @@ -137,7 +137,7 @@ class FileOperationMapper extends Mapper */ public function deleteSequenceById($sequence, $userId) { - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file` WHERE `sequence` = ? AND `user_id` = ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `sequence` = ? AND `user_id` = ?'; $stmt = $this->execute($sql, [$sequence, $userId]); $stmt->closeCursor(); } @@ -149,7 +149,7 @@ class FileOperationMapper extends Mapper */ public function deleteFileOperationsBefore($timestamp) { - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file` WHERE `timestamp` < ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `timestamp` < ?'; $stmt = $this->execute($sql, [$timestamp]); $stmt->closeCursor(); } diff --git a/tests/Integration/AppTest.php b/tests/Integration/AppTest.php index 5116f93..d2ca4bd 100644 --- a/tests/Integration/AppTest.php +++ b/tests/Integration/AppTest.php @@ -76,7 +76,7 @@ abstract class AppTest extends PHPUnit_Framework_TestCase protected function clearDatabase($user) { $sql = [ - 'DELETE FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?', + 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?', ]; $db = $this->container->query(IDBConnection::class); foreach ($sql as $query) { diff --git a/tests/Unit/Db/FileOperationMapperTest.php b/tests/Unit/Db/FileOperationMapperTest.php index 20fb584..917a99a 100644 --- a/tests/Unit/Db/FileOperationMapperTest.php +++ b/tests/Unit/Db/FileOperationMapperTest.php @@ -55,7 +55,7 @@ class FileOperationMapperTest extends MapperTestUtility $userId = 'john'; $id = 3; $rows = [['id' => $this->fileOperations[0]->getId()]]; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `id` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$id, $userId], $rows); @@ -68,7 +68,7 @@ class FileOperationMapperTest extends MapperTestUtility { $userId = 'john'; $id = 3; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `id` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$id, $userId]); @@ -83,7 +83,7 @@ class FileOperationMapperTest extends MapperTestUtility $userId = 'john'; $id = 3; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `id` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$id, $userId], $rows); @@ -98,7 +98,7 @@ class FileOperationMapperTest extends MapperTestUtility $userId = 'john'; $name = 'test'; $rows = [['id' => $this->fileOperations[0]->getId()]]; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `original_name` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$name, $userId], $rows); @@ -111,7 +111,7 @@ class FileOperationMapperTest extends MapperTestUtility { $userId = 'john'; $name = 'test'; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `original_name` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$name, $userId]); @@ -126,7 +126,7 @@ class FileOperationMapperTest extends MapperTestUtility $userId = 'john'; $name = 'test'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `original_name` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$name, $userId], $rows); @@ -140,7 +140,7 @@ class FileOperationMapperTest extends MapperTestUtility { $userId = 'john'; $rows = [['id' => $this->fileOperations[0]->getId()]]; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'. 'ORDER BY id DESC LIMIT 1'; $this->setMapperResult($sql, [$userId], $rows); @@ -152,7 +152,7 @@ class FileOperationMapperTest extends MapperTestUtility public function testFindOneWithHighestIdNotFound() { $userId = 'john'; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'. 'ORDER BY id DESC LIMIT 1'; $this->setMapperResult($sql, [$userId]); @@ -166,7 +166,7 @@ class FileOperationMapperTest extends MapperTestUtility { $userId = 'john'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'. 'ORDER BY id DESC LIMIT 1'; $this->setMapperResult($sql, [$userId], $rows); @@ -180,7 +180,7 @@ class FileOperationMapperTest extends MapperTestUtility { $userId = 'john'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'; + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'; $this->setMapperResult($sql, [$userId], $rows); $result = $this->mapper->findAll([$userId]); @@ -192,7 +192,7 @@ class FileOperationMapperTest extends MapperTestUtility $userId = 'john'; $sequence = '1'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `sequence` = ? AND `user_id` = ?'; + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `sequence` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$sequence, $userId], $rows); $result = $this->mapper->findSequenceById([$sequence, $userId]); @@ -204,7 +204,7 @@ class FileOperationMapperTest extends MapperTestUtility $fileOperation = new FileOperation(); $fileOperation->setId(3); - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file_operation` WHERE `id` = ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `id` = ?'; $arguments = [$fileOperation->getId()]; $this->setMapperResult($sql, $arguments, [], null, null, true); @@ -219,7 +219,7 @@ class FileOperationMapperTest extends MapperTestUtility $fileOperation->setUserId($userId); $fileOperation->setId(3); - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file_operation` WHERE `id` = ? AND `user_id` = ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `id` = ? AND `user_id` = ?'; $arguments = [$fileOperation->getId(), $userId]; $this->setMapperResult($sql, $arguments, [], null, null, true); @@ -235,7 +235,7 @@ class FileOperationMapperTest extends MapperTestUtility $fileOperation->setUserId($userId); $fileOperation->setSequence(1); - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file_operation` WHERE `sequence` = ? AND `user_id` = ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `sequence` = ? AND `user_id` = ?'; $arguments = [$fileOperation->getSequence(), $userId]; $this->setMapperResult($sql, $arguments, [], null, null, true); diff --git a/tests/Unit/Service/FileOperationServiceTest.php b/tests/Unit/Service/FileOperationServiceTest.php index be9dca8..9be9620 100644 --- a/tests/Unit/Service/FileOperationServiceTest.php +++ b/tests/Unit/Service/FileOperationServiceTest.php @@ -58,7 +58,7 @@ class FileOperationServiceTest extends MapperTestUtility $userId = 'john'; $id = 3; $rows = [['id' => $this->fileOperations[0]->getId()]]; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `id` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$id, $userId], $rows); @@ -71,7 +71,7 @@ class FileOperationServiceTest extends MapperTestUtility { $userId = 'john'; $id = 3; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `id` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$id, $userId]); @@ -86,7 +86,7 @@ class FileOperationServiceTest extends MapperTestUtility $userId = 'john'; $id = 3; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `id` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$id, $userId], $rows); @@ -101,7 +101,7 @@ class FileOperationServiceTest extends MapperTestUtility $userId = 'john'; $name = 'test'; $rows = [['id' => $this->fileOperations[0]->getId()]]; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `original_name` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$name, $userId], $rows); @@ -114,7 +114,7 @@ class FileOperationServiceTest extends MapperTestUtility { $userId = 'john'; $name = 'test'; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `original_name` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$name, $userId]); @@ -129,7 +129,7 @@ class FileOperationServiceTest extends MapperTestUtility $userId = 'john'; $name = 'test'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` '. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` '. 'WHERE `original_name` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$name, $userId], $rows); @@ -143,7 +143,7 @@ class FileOperationServiceTest extends MapperTestUtility { $userId = 'john'; $rows = [['id' => $this->fileOperations[0]->getId()]]; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'. 'ORDER BY id DESC LIMIT 1'; $this->setMapperResult($sql, [$userId], $rows); @@ -155,7 +155,7 @@ class FileOperationServiceTest extends MapperTestUtility public function testFindOneWithHighestIdNotFound() { $userId = 'john'; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'. 'ORDER BY id DESC LIMIT 1'; $this->setMapperResult($sql, [$userId]); @@ -169,7 +169,7 @@ class FileOperationServiceTest extends MapperTestUtility { $userId = 'john'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'. + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'. 'ORDER BY id DESC LIMIT 1'; $this->setMapperResult($sql, [$userId], $rows); @@ -183,7 +183,7 @@ class FileOperationServiceTest extends MapperTestUtility { $userId = 'john'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `user_id` = ?'; + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `user_id` = ?'; $this->setMapperResult($sql, [$userId], $rows); $result = $this->service->findAll(); @@ -195,7 +195,7 @@ class FileOperationServiceTest extends MapperTestUtility $userId = 'john'; $sequence = '1'; $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*ransomware_detection_file_operation` WHERE `sequence` = ? AND `user_id` = ?'; + $sql = 'SELECT * FROM `*PREFIX*ransomware_detection` WHERE `sequence` = ? AND `user_id` = ?'; $this->setMapperResult($sql, [$sequence, $userId], $rows); $result = $this->service->findSequenceById([$sequence]); @@ -209,7 +209,7 @@ class FileOperationServiceTest extends MapperTestUtility $fileOperation->setUserId($userId); $fileOperation->setId(3); - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file_operation` WHERE `id` = ? AND `user_id` = ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `id` = ? AND `user_id` = ?'; $arguments = [$fileOperation->getId(), $userId]; $this->setMapperResult($sql, $arguments, [], null, null, true); @@ -225,7 +225,7 @@ class FileOperationServiceTest extends MapperTestUtility $fileOperation->setUserId($userId); $fileOperation->setSequence(1); - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file_operation` WHERE `sequence` = ? AND `user_id` = ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `sequence` = ? AND `user_id` = ?'; $arguments = [$fileOperation->getSequence(), $userId]; $this->setMapperResult($sql, $arguments, [], null, null, true); @@ -242,7 +242,7 @@ class FileOperationServiceTest extends MapperTestUtility $fileOperation->setSequence(1); $fileOperation->setTimestamp(strtotime('-1 week')); - $sql = 'DELETE FROM `*PREFIX*ransomware_detection_file_operation` WHERE `timestamp` < ?'; + $sql = 'DELETE FROM `*PREFIX*ransomware_detection` WHERE `timestamp` < ?'; $time = time(); $arguments = [$time]; |