Skip to content

Commit 3591889

Browse files
committedMar 16, 2025··
Capture the agent signature on boot
1 parent 0644f4e commit 3591889

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed
 

‎agent/src/agent.php

+10
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
use Laravel\NightwatchAgent\Factories\ServerFactory;
88
use Psr\Http\Message\ResponseInterface;
99
use React\EventLoop\Loop;
10+
use RuntimeException;
1011
use Throwable;
1112

1213
use function date;
14+
use function file_get_contents;
1315
use function gethostname;
1416
use function round;
1517
use function str_replace;
@@ -46,8 +48,16 @@
4648
$ingestTimeout ??= 10;
4749
/** @var ?string $server */
4850
$server ??= (string) gethostname();
51+
/** @var ?string $signature */
52+
$signature ??= (static function () use ($basePath) {
53+
$signature = file_get_contents($basePath.'/../../version.txt');
4954

55+
if ($signature === false) {
56+
throw new RuntimeException('Unable to verify the signature file');
57+
}
5058

59+
return $signature;
60+
})();
5161

5262
/*
5363
* Logging helpers...

‎src/Console/AgentCommand.php

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Laravel\Nightwatch\Console;
44

55
use Illuminate\Console\Command;
6+
use Laravel\Nightwatch\Ingest;
67
use SensitiveParameter;
78
use Symfony\Component\Console\Attribute\AsCommand;
89

@@ -54,6 +55,8 @@ public function handle(): void
5455

5556
$server = $this->option('server') ?? $this->server;
5657

58+
$signature = Ingest::AGENT_SIGNATURE;
59+
5760
require __DIR__.'/../../agent/build/agent.phar';
5861
}
5962
}

‎src/Ingest.php

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
final class Ingest implements LocalIngest
1313
{
14+
public const AGENT_SIGNATURE = 'EA7F6BABFE0D3F3B53FEE7E9C5F2E657FAF8CA6156CC92AF7ADC0F750930A98963BC7BB69056C010F4A5B77B4B53C064618A53DE62B1B482A2D75EAEDA38B682';
15+
1416
/**
1517
* @var (callable(string): void)|null
1618
*/

0 commit comments

Comments
 (0)
Please sign in to comment.