• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / jobs / 21145580946

19 Jan 2026 04:55PM UTC coverage: 58.025% (-4.5%) from 62.567%
21145580946

push

github

daycry
Add security, performance, and health features; simplify architecture

Introduces shell command whitelisting, smart token detection, per-queue rate limiting, dead letter queue, job timeout protection, config caching, and a health monitoring command. Refactors architecture by consolidating traits, removing the CompletionStrategy pattern, and unifying retry policies under RetryPolicyFixed. Updates documentation and tests to reflect new features and architectural changes, ensuring backward compatibility and improved reliability.

143 of 340 new or added lines in 20 files covered. (42.06%)

1 existing line in 1 file now uncovered.

1193 of 2056 relevant lines covered (58.03%)

4.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Jobs/ShellJob.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Queues.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Jobs\Jobs;
15

16
use Daycry\Jobs\Exceptions\JobException;
17
use Daycry\Jobs\Interfaces\JobInterface;
18
use Daycry\Jobs\Job;
19

20
/**
21
 * Executes a shell command using exec().
22
 * Payload: string command to execute. Returns captured output array.
23
 * NOTE: Commands are validated against whitelist if configured.
24
 */
25
class ShellJob extends Job implements JobInterface
26
{
27
    public function handle(mixed $payload): mixed
28
    {
NEW
29
        $this->validateCommand($payload);
×
30

31
        $payload = escapeshellcmd($payload);
×
32
        exec($payload, $output);
×
33

34
        return $output;
×
35
    }
36

37
    public function beforeRun(Job $job): Job
38
    {
39
        return $job;
×
40
    }
41

42
    public function afterRun(Job $job): Job
43
    {
44
        return $job;
×
45
    }
46

47
    /**
48
     * Validate command against whitelist if configured.
49
     */
50
    private function validateCommand(string $command): void
51
    {
NEW
52
        $config  = config('Jobs');
×
NEW
53
        $allowed = $config->allowedShellCommands ?? [];
×
54

55
        // Empty whitelist = allow all (backward compatible)
NEW
56
        if (empty($allowed)) {
×
NEW
57
            return;
×
58
        }
59

60
        // Extract command name (first token)
NEW
61
        $parts   = preg_split('/\s+/', trim($command), 2);
×
NEW
62
        $cmdName = $parts[0] ?? '';
×
63

64
        // Check if command is in whitelist
NEW
65
        if (! in_array($cmdName, $allowed, true)) {
×
NEW
66
            throw JobException::forShellCommandNotAllowed($cmdName);
×
67
        }
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc