1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\Module\logpeek\Config; |
6
|
|
|
|
7
|
|
|
use E_USER_NOTICE; |
|
|
|
|
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\Configuration; |
10
|
|
|
use SimpleSAML\Utils; |
11
|
|
|
use Symfony\Component\Yaml\Yaml; |
12
|
|
|
use Symfony\Component\Yaml\Exception\ParseException; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Configuration for the module logpeek. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
class Logpeek { |
19
|
|
|
/** @var int */ |
20
|
|
|
public const MAX_BLOCKSIZE = 8192; |
21
|
|
|
|
22
|
|
|
/** @var int */ |
23
|
|
|
public const DEFAULT_BLOCKSIZE = 8192; |
24
|
|
|
|
25
|
|
|
/** @var int */ |
26
|
|
|
public const DEFAULT_LINES = 500; |
27
|
|
|
|
28
|
|
|
/** @var array */ |
29
|
|
|
private array $data = []; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $defaultConfigFile |
34
|
|
|
* @throws \Symfony\Component\Yaml\Exception\ParseException |
35
|
|
|
*/ |
36
|
|
|
public function __construct(string $defaultConfigFile = 'module_logpeek.yml') |
37
|
|
|
{ |
38
|
|
|
$configUtils = new Utils\Config(); |
39
|
|
|
$configDir = $configUtils->getConfigDir(); |
40
|
|
|
$yamlConfig = Yaml::parse(file_get_contents($configDir . '/' . $defaultConfigFile)) ?? []; |
41
|
|
|
if (isset($yamlConfig['logFile'])) { |
42
|
|
|
$this->setLogfile($yamlConfig['logFile']); |
43
|
|
|
} else { |
44
|
|
|
$config = Configuration::getInstance(); |
45
|
|
|
$loggingDir = $config->getPathValue('loggingdir', 'log/'); |
46
|
|
|
$this->setLogfile($loggingDir . $config->getString('logging.logfile', 'simplesamlphp.log')); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$this->setLines($yamlConfig['lines'] ?? self::DEFAULT_LINES); |
50
|
|
|
$this->setBlockSize($yamlConfig['blockSize'] ?? self::DEFAULT_BLOCKSIZE); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $name |
56
|
|
|
* @return mixed |
57
|
|
|
*/ |
58
|
|
|
public function __get(string $name) |
59
|
|
|
{ |
60
|
|
|
if (array_key_exists($name, $this->data)) { |
61
|
|
|
return $this->data[$name]; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$trace = debug_backtrace(); |
65
|
|
|
trigger_error( |
66
|
|
|
sprintf( |
67
|
|
|
'Undefined property via __get(): %s in %s on line %d', |
68
|
|
|
$name, |
69
|
|
|
$trace[0]['file'], |
70
|
|
|
$trace[0]['line'], |
71
|
|
|
), |
72
|
|
|
E_USER_NOTICE |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
return null; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param string $logFile |
81
|
|
|
* @return void |
82
|
|
|
*/ |
83
|
|
|
protected function setLogFile(string $logFile): void { |
84
|
|
|
$this->data['logFile'] = $logFile; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param int $lines |
90
|
|
|
* @return void |
91
|
|
|
*/ |
92
|
|
|
protected function setLines(int $lines): void { |
93
|
|
|
Assert::positiveInteger($lines); |
94
|
|
|
$this->data['lines'] = $lines; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param int $blockSize |
100
|
|
|
* @return void |
101
|
|
|
*/ |
102
|
|
|
protected function setBlockSize(int $blockSize): void { |
103
|
|
|
Assert::range($blockSize, 0, self::MAX_BLOCKSIZE); |
104
|
|
|
$this->data['blockSize'] = $blockSize; |
105
|
|
|
} |
106
|
|
|
}; |
107
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths