Skip to content

Commit 61d3f47

Browse files
committed
frontend & backend source code documentation
1 parent 27959c0 commit 61d3f47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2620
-294
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
/data/rulesets/yara_ruleset/*
1313
/data/rulesets/sigma_ruleset/*
1414
/data/fluentbit_db/*
15-
/data/log_ingest_data/evtx/*
16-
/data/log_ingest_data/auditd/*
17-
/data/log_ingest_data/json/*
18-
/data/log_ingest_data/csv/*
15+
/data/log_ingest_data/*/*
16+
!/data/log_ingest_data/*/.gitkeep
1917
/data/mysql_data/*
2018
/data/yara_triage_data/*
2119
/docs/graphs/*.bkp

data/log_ingest_data/auditd/.gitkeep

Whitespace-only changes.

data/log_ingest_data/csv/.gitkeep

Whitespace-only changes.

data/log_ingest_data/evtx/.gitkeep

Whitespace-only changes.

data/log_ingest_data/json/.gitkeep

Whitespace-only changes.

sentinel-kit_server_backend/src/Command/CreateUserCommand.php

Lines changed: 0 additions & 96 deletions
This file was deleted.

sentinel-kit_server_backend/src/Command/DatasourceCreateCommand.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,47 @@
1313
use App\Entity\Datasource;
1414

1515

16+
/**
17+
* Datasource Create Command creates new log data sources for ingestion.
18+
*
19+
* This console command allows administrators to create new data source configurations
20+
* for log ingestion. Each data source gets a unique ingest key and can be configured
21+
* with validity periods and target Elasticsearch indices.
22+
*/
1623
#[AsCommand(
1724
name: 'app:datasource:create',
1825
description: 'Create a new ingest datasource in the backend application',
1926
)]
2027
class DatasourceCreateCommand extends Command
2128
{
29+
/**
30+
* Entity manager for database operations.
31+
*/
2232
private $entityManager;
33+
34+
/**
35+
* URL generator for creating ingest URLs.
36+
*/
2337
private $urlGenerator;
2438

39+
/**
40+
* Command constructor with dependency injection.
41+
*
42+
* @param EntityManagerInterface $entityManager Doctrine entity manager
43+
* @param UrlGeneratorInterface $urlGenerator URL generator for ingest endpoints
44+
*/
2545
public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator)
2646
{
2747
parent::__construct();
2848
$this->entityManager = $entityManager;
2949
$this->urlGenerator = $urlGenerator;
3050
}
3151

52+
/**
53+
* Configure command arguments.
54+
*
55+
* Defines required and optional arguments for datasource creation.
56+
*/
3257
protected function configure(): void
3358
{
3459
$this
@@ -38,8 +63,34 @@ protected function configure(): void
3863
->addArgument('validTo', InputArgument::OPTIONAL, '(optional) Valid to (YYYY-MM-DD)');
3964
}
4065

66+
/**
67+
* Execute the datasource creation command.
68+
*
69+
* Creates a new data source with the specified configuration, generates
70+
* a unique ingest key, and provides the ingestion endpoint information.
71+
*
72+
* @param InputInterface $input Command line input arguments
73+
* @param OutputInterface $output Command line output interface
74+
*
75+
* @return int Command exit code (SUCCESS or FAILURE)
76+
*
77+
* Arguments:
78+
* - name: Unique name for the data source
79+
* - index: Target Elasticsearch index suffix
80+
* - validFrom: Optional start date (YYYY-MM-DD format)
81+
* - validTo: Optional end date (YYYY-MM-DD format)
82+
*
83+
* Output:
84+
* - Success: Datasource details including ingest key and forwarder URL
85+
* - Failure: Error message for duplicate names or invalid dates
86+
*
87+
* Exit codes:
88+
* - Command::SUCCESS (0): Datasource created successfully
89+
* - Command::FAILURE (1): Name already exists, invalid dates, or database error
90+
*/
4191
protected function execute(InputInterface $input, OutputInterface $output): int
4292
{
93+
// Initialize console style helper and extract arguments
4394
$io = new SymfonyStyle($input, $output);
4495
$name = $input->getArgument('name');
4596
$index = $input->getArgument('index');
@@ -49,6 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
49100
$validFromDate = null;
50101
$validToDate = null;
51102

103+
// Parse and validate optional date arguments
52104
if ($validFrom) {
53105
try{
54106
$validFromDate = new \DateTime($validFrom);
@@ -67,20 +119,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
67119
}
68120
}
69121

122+
// Check for existing datasource with the same name
70123
$existingDatasource = $this->entityManager->getRepository(Datasource::class)->findOneBy(['name' => $name]);
71124

72125
if ($existingDatasource) {
73126
$io->error(sprintf('Datasource "%s" already exists.', $name));
74127
return Command::FAILURE;
75128
}
76129

130+
// Create new datasource entity with provided configuration
77131
$datasource = new Datasource();
78132
$output->writeln(sprintf('%s - %s', $name, $index));
79133
$datasource->setName($name);
80134
$datasource->setTargetIndex($index);
81135
$datasource->setValidFrom($validFromDate);
82136
$datasource->setValidTo($validToDate);
83137

138+
// Persist the new datasource to database
84139
try {
85140
$this->entityManager->persist($datasource);
86141
$this->entityManager->flush();
@@ -89,6 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
89144
return Command::FAILURE;
90145
}
91146

147+
// Display success information with datasource details
92148
$io->success(sprintf('Datasource "%s" created successfully', $name));
93149
$io->writeln(sprintf('Valid from %s', $validFrom ? $validFromDate->format('Y-m-d') : 'N/A'));
94150
$io->writeln(sprintf('Valid to %s', $validTo ? $validToDate->format('Y-m-d') : 'N/A'));

sentinel-kit_server_backend/src/Command/DatasourceDeleteCommand.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,71 @@
1111
use Doctrine\ORM\EntityManagerInterface;
1212
use App\Entity\Datasource;
1313

14+
/**
15+
* Datasource Delete Command removes data sources from the system.
16+
*
17+
* This console command allows administrators to permanently delete data source
18+
* configurations. Can delete by either ID or name for flexible administration.
19+
*/
1420
#[AsCommand(
1521
name: 'app:datasource:delete',
1622
description: 'Delete a datasource from the backend application',
1723
)]
1824
class DatasourceDeleteCommand extends Command
1925
{
20-
26+
/**
27+
* Entity manager for database operations.
28+
*/
2129
private EntityManagerInterface $entityManager;
2230

31+
/**
32+
* Command constructor with dependency injection.
33+
*
34+
* @param EntityManagerInterface $entityManager Doctrine entity manager
35+
*/
2336
public function __construct(EntityManagerInterface $entityManager)
2437
{
2538
parent::__construct();
2639
$this->entityManager = $entityManager;
2740
}
2841

42+
/**
43+
* Configure command arguments.
44+
*
45+
* Defines the required ID or name argument for datasource deletion.
46+
*/
2947
protected function configure(): void
3048
{
3149
$this
3250
->addArgument('id', InputArgument::REQUIRED, 'ID or name of the datasource to delete');
3351
}
3452

53+
/**
54+
* Execute the datasource deletion command.
55+
*
56+
* Permanently removes a datasource configuration from the system.
57+
* Supports lookup by both numeric ID and string name.
58+
*
59+
* @param InputInterface $input Command line input arguments
60+
* @param OutputInterface $output Command line output interface
61+
*
62+
* @return int Command exit code (SUCCESS or FAILURE)
63+
*
64+
* Arguments:
65+
* - id: Datasource ID (numeric) or name (string) to delete
66+
*
67+
* Exit codes:
68+
* - Command::SUCCESS (0): Datasource deleted successfully
69+
* - Command::FAILURE (1): Datasource not found or database error
70+
*/
3571
protected function execute(InputInterface $input, OutputInterface $output): int
3672
{
73+
// Initialize console style helper
3774
$io = new SymfonyStyle($input, $output);
3875

3976
$dsId = $input->getArgument('id');
4077

78+
// Determine if searching by ID (numeric) or name (string)
4179
if (is_numeric(intval($dsId)) && intval($dsId) > 0) {
4280
$datasource = $this->entityManager->getRepository(Datasource::class)->find((int)$dsId);
4381
} else {
@@ -49,6 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4987
return Command::FAILURE;
5088
}
5189

90+
// Permanently delete the datasource from database
5291
try{
5392
$this->entityManager->remove($datasource);
5493
$this->entityManager->flush();

sentinel-kit_server_backend/src/Command/DatasourceListCommand.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,63 @@
1010
use Doctrine\ORM\EntityManagerInterface;
1111
use App\Entity\Datasource;
1212

13+
/**
14+
* Datasource List Command displays all configured data sources.
15+
*
16+
* This console command allows administrators to view all registered data sources
17+
* with their configuration details including validity periods and target indices.
18+
*/
1319
#[AsCommand(
1420
name: 'app:datasource:list',
1521
description: 'List all data sources in the backend application',
1622
)]
1723
class DatasourceListCommand extends Command
1824
{
19-
25+
/**
26+
* Entity manager for database operations.
27+
*/
2028
private EntityManagerInterface $entityManager;
2129

30+
/**
31+
* Command constructor with dependency injection.
32+
*
33+
* @param EntityManagerInterface $entityManager Doctrine entity manager
34+
*/
2235
public function __construct(EntityManagerInterface $entityManager)
2336
{
2437
parent::__construct();
2538
$this->entityManager = $entityManager;
2639
}
2740

41+
/**
42+
* Configure command (no arguments needed for listing all datasources).
43+
*/
2844
protected function configure(): void
2945
{
3046
}
3147

48+
/**
49+
* Execute the datasource listing command.
50+
*
51+
* Retrieves and displays all data source configurations with their
52+
* details including ID, name, target index, and validity periods.
53+
*
54+
* @param InputInterface $input Command line input (no arguments)
55+
* @param OutputInterface $output Command line output interface
56+
*
57+
* @return int Command exit code (always SUCCESS)
58+
*
59+
* Output format: "ID: {id} | Name: {name} | Index: {index} | Valid From: {date} | Valid To: {date}"
60+
*/
3261
protected function execute(InputInterface $input, OutputInterface $output): int
3362
{
63+
// Initialize console style helper
3464
$io = new SymfonyStyle($input, $output);
3565

66+
// Retrieve all datasources from database
3667
$datasources = $this->entityManager->getRepository(Datasource::class)->findAll();
68+
69+
// Display each datasource's configuration details
3770
foreach ($datasources as $datasource) {
3871
$io->writeln(
3972
'ID: ' . $datasource->getId() .

0 commit comments

Comments
 (0)