Skip to content

Commit 1b09e11

Browse files
Fix problem with command usage
1 parent f8c8f23 commit 1b09e11

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
retries: 3
3030

3131
keycloak:
32+
container_name: rmap-keycloak
3233
image: quay.io/reconmap/keycloak-custom:latest
3334
command: "start --hostname=http://localhost:8080 --proxy-headers xforwarded --http-enabled true --import-realm"
3435
environment:

database/01-schema.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,13 @@ INSERT INTO command(id, creator_uid, name)
396396
VALUES (1, 1, 'nmap');
397397

398398
TRUNCATE TABLE command_usage;
399-
INSERT INTO command_usage(id, creator_uid, command_id, description, executable_path, arguments, output_filename,
399+
INSERT INTO command_usage(id, creator_uid, command_id, name, description, executable_path, arguments, output_filename,
400400
output_parser)
401-
VALUES (1, 1, 1, "Scan all reserved TCP ports on the machine. The -v option enables verbose mode.", "nmap",
401+
VALUES (1, 1, 1, "Normal scan", "Scan all reserved TCP ports on the machine. The -v option enables verbose mode.",
402+
"nmap",
402403
" -v scanme.nmap.org", "STDOUT", "nmap"),
403404
(2, 1, 1,
405+
"Stealth scan",
404406
"Launches a stealth SYN scan against each machine that is up out of the 256 IPs on the /24 sized network where Scanme resides. It also tries to determine what operating system is running on each host that is up and running. This requires root privileges because of the SYN scan and OS detection.",
405407
"nmap", " -sS -O scanme.nmap.org/24", "STDOUT", "nmap");
406408

src/Controllers/Commands/UploadCommandOutputController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
class UploadCommandOutputController extends UploadAttachmentController
1414
{
15-
public function __construct(AttachmentRepository $attachmentRepository,
16-
AttachmentFilePath $attachmentFilePathService,
17-
RedisServer $redisServer,
18-
private readonly CommandRepository $commandRepository,
19-
private readonly CommandUsageRepository $commandUsageRepository,
15+
public function __construct(AttachmentRepository $attachmentRepository,
16+
AttachmentFilePath $attachmentFilePathService,
17+
RedisServer $redisServer,
18+
private readonly CommandRepository $commandRepository,
19+
private readonly CommandUsageRepository $commandUsageRepository,
2020
)
2121
{
2222
parent::__construct($attachmentRepository, $attachmentFilePathService, $redisServer);
@@ -26,13 +26,13 @@ public function __construct(AttachmentRepository $attachmentRepository,
2626
public function __invoke(ServerRequestInterface $request, array $args): array
2727
{
2828
$params = $request->getParsedBody();
29-
$commandId = (int)$params['commandId'];
29+
$commandUsageId = (int)$params['commandUsageId'];
3030
$taskId = isset($params['taskId']) ? intval($params['taskId']) : null;
3131

3232
$files = $request->getUploadedFiles();
3333
$resultFile = $files['resultFile'];
3434

35-
$usage = $this->commandUsageRepository->findById($commandId);
35+
$usage = $this->commandUsageRepository->findById($commandUsageId);
3636
$command = $this->commandRepository->findById($usage['command_id']);
3737

3838
$userId = $request->getAttribute('userId');

src/Repositories/CommandUsageRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class CommandUsageRepository extends MysqlRepository
1212
{
13-
public const UPDATABLE_COLUMNS_TYPES = [
13+
public const array UPDATABLE_COLUMNS_TYPES = [
1414
'command_id' => 'i',
1515
'name' => 's',
1616
'description' => 's',

src/Repositories/SearchCriterias/TaskSearchCriteria.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,49 @@
66

77
class TaskSearchCriteria extends SearchCriteria
88
{
9-
public function addProjectCriterion(int $projectId)
9+
public function addProjectCriterion(int $projectId): void
1010
{
1111
$this->addCriterion('t.project_id = ?', [$projectId]);
1212
}
1313

14-
public function addStatusCriterion(string $status)
14+
public function addStatusCriterion(string $status): void
1515
{
1616
$this->addCriterion('t.status = ?', [$status]);
1717
}
1818

19-
public function addProjectTemplateCriterion(bool $isTemplate)
19+
public function addProjectTemplateCriterion(bool $isTemplate): void
2020
{
2121
$this->addCriterion('p.is_template = ?', [$isTemplate]);
2222
}
2323

24-
public function addProjectIsNotTemplateCriterion()
24+
public function addProjectIsNotTemplateCriterion(): void
2525
{
2626
$this->addProjectTemplateCriterion(false);
2727
}
2828

29-
public function addAssigneeCriterion(int $assigneeUid)
29+
public function addAssigneeCriterion(int $assigneeUid): void
3030
{
3131
$this->addCriterion('t.assignee_uid = ?', [$assigneeUid]);
3232
}
3333

34-
public function addPriorityCriterion(string $priority)
34+
public function addPriorityCriterion(string $priority): void
3535
{
3636
$this->addCriterion('t.priority = ?', [$priority]);
3737
}
3838

39-
public function addKeywordsCriterion(string $keywords)
39+
public function addKeywordsCriterion(string $keywords): void
4040
{
4141
$keywordsLike = "%$keywords%";
4242

4343
$this->addCriterion('t.summary LIKE ? OR t.description LIKE ?', [$keywordsLike, $keywordsLike]);
4444
}
4545

46-
public function addUserCriterion(int $userId)
46+
public function addUserCriterion(int $userId): void
4747
{
4848
$this->addCriterion('(p.visibility = "public" OR ? IN (SELECT user_id FROM project_user WHERE project_id = p.id))', [$userId]);
4949
}
5050

51-
public function addProjectArchivedCriterion(int $projectIsArchived)
51+
public function addProjectArchivedCriterion(int $projectIsArchived): void
5252
{
5353
$this->addCriterion('p.archived = ?', [$projectIsArchived]);
5454
}

tests/ControllerTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Reconmap;
44

5-
use Monolog\Logger;
5+
use Psr\Log\LoggerInterface;
66
use Reconmap\Controllers\Controller;
77
use Reconmap\Services\Security\AuthorisationService;
88

99
class ControllerTestCase extends DatabaseTestCase
1010
{
1111
public function injectController(Controller $controller): Controller
1212
{
13-
$mockLogger = $this->createMock(Logger::class);
13+
$mockLogger = $this->createMock(LoggerInterface::class);
1414
$controller->setLogger($mockLogger);
1515

1616
return $controller;

0 commit comments

Comments
 (0)