Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issuer subject_hash ambiguities & bogus results with unknown issuers #240

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions application/clicommands/CheckCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icingaweb2-module-x509/icingaweb2-module-x509/application/clicommands/CheckCommand.php was not matched in reported errors.

Check failure on line 1 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icingaweb2-module-x509/icingaweb2-module-x509/application/clicommands/CheckCommand.php was not matched in reported errors.

Check failure on line 1 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icingaweb2-module-x509/icingaweb2-module-x509/application/clicommands/CheckCommand.php was not matched in reported errors.

Check failure on line 1 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icingaweb2-module-x509/icingaweb2-module-x509/application/clicommands/CheckCommand.php was not matched in reported errors.

Check failure on line 1 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icingaweb2-module-x509/icingaweb2-module-x509/application/clicommands/CheckCommand.php was not matched in reported errors.

// Icinga Web 2 X.509 Module | (c) 2019 Icinga GmbH | GPLv2

Expand Down Expand Up @@ -68,37 +68,30 @@
exit(3);
}

$targets = X509Target::on(Database::get())->with([
'chain',
'chain.certificate',
'chain.certificate.issuer_certificate'
]);

$targets->getWith()['target.chain.certificate.issuer_certificate']->setJoinType('LEFT');
$targets = X509Target::on(Database::get())
->with(['chain', 'chain.certificate'])
->without('target.chain.certificate.issuer_certificate');

$targets->columns([
'port',
'chain.valid',
'chain.invalid_reason',
'subject' => 'chain.certificate.subject',
'self_signed' => new Expression('COALESCE(%s, %s)', [
'chain.certificate.issuer_certificate.self_signed',
'chain.certificate.self_signed'
])
'self_signed' => 'chain.certificate.self_signed'
]);

// Sub query for `valid_from` column
$validFrom = $targets->createSubQuery(new X509Certificate(), 'chain.certificate');
$validFrom
->columns([new Expression('MAX(GREATEST(%s, %s))', ['valid_from', 'issuer_certificate.valid_from'])])
->columns([new Expression('MAX(%s)', ['valid_from'])])
->getSelectBase()
->resetWhere()
->where(new Expression('sub_certificate_link.certificate_chain_id = target_chain.id'));

// Sub query for `valid_to` column
$validTo = $targets->createSubQuery(new X509Certificate(), 'chain.certificate');
$validTo
->columns([new Expression('MIN(LEAST(%s, %s))', ['valid_to', 'issuer_certificate.valid_to'])])
->columns([new Expression('MIN(%s)', ['valid_to'])])
->getSelectBase()
// Reset the where clause generated within the createSubQuery() method.
->resetWhere()
Expand All @@ -107,21 +100,24 @@
list($validFromSelect, $_) = $validFrom->dump();
list($validToSelect, $_) = $validTo->dump();
$targets
// When the host or IP being checked is part of multiple targets and the user did not provide a filter
// on a specific port, we want to render the result with least valid_to timestamp.
->orderBy('valid_to', SORT_DESC)
->withColumns([
'valid_from' => new Expression($validFromSelect),

Check failure on line 107 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 107 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 107 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 107 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 107 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.
'valid_to' => new Expression($validToSelect)

Check failure on line 108 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 108 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 108 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 108 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.

Check failure on line 108 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Parameter #1 $statement of class ipl\Sql\Expression constructor expects string, mixed given.
])
->getSelectBase()
->where(new Expression('target_chain_link.order = 0'));

if ($ip !== null) {
$targets->filter(Filter::equal('ip', $ip));

Check failure on line 114 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 114 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 114 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 114 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 114 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.
}
if ($hostname !== null) {
$targets->filter(Filter::equal('hostname', $hostname));

Check failure on line 117 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 117 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 117 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 117 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 117 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.
}
if ($this->params->has('port')) {
$targets->filter(Filter::equal('port', $this->params->get('port')));

Check failure on line 120 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 120 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 120 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 120 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.

Check failure on line 120 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array<mixed>|bool|float|int|string, mixed given.
}

$allowSelfSigned = (bool) $this->params->get('allow-self-signed', false);
Expand All @@ -133,8 +129,8 @@

$state = 3;
foreach ($targets as $target) {
if (! $target->chain->valid && (! $target['self_signed'] || ! $allowSelfSigned)) {

Check failure on line 132 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Cannot access property $valid on mixed.

Check failure on line 132 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Cannot access property $valid on mixed.

Check failure on line 132 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Cannot access property $valid on mixed.

Check failure on line 132 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Cannot access property $valid on mixed.

Check failure on line 132 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Cannot access property $valid on mixed.
$invalidMessage = $target['subject'] . ': ' . $target->chain->invalid_reason;

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Binary operation "." between mixed and ': ' results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Binary operation "." between non-falsy-string and mixed results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Cannot access property $invalid_reason on mixed.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Binary operation "." between mixed and ': ' results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Binary operation "." between non-falsy-string and mixed results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Cannot access property $invalid_reason on mixed.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Binary operation "." between mixed and ': ' results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Binary operation "." between non-falsy-string and mixed results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.3 on ubuntu-latest

Cannot access property $invalid_reason on mixed.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Binary operation "." between mixed and ': ' results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Binary operation "." between non-falsy-string and mixed results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Cannot access property $invalid_reason on mixed.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Binary operation "." between mixed and ': ' results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Binary operation "." between non-falsy-string and mixed results in an error.

Check failure on line 133 in application/clicommands/CheckCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Cannot access property $invalid_reason on mixed.
$output[$invalidMessage] = $invalidMessage;
$state = 2;
}
Expand Down
4 changes: 2 additions & 2 deletions application/clicommands/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
foreach ($bundle as $data) {
$cert = openssl_x509_read($data);

list($id, $_) = CertificateUtils::findOrInsertCert($db, $cert);
$certInfo = CertificateUtils::findOrInsertCert($db, $cert);

$db->update(
'x509_certificate',
[
'trusted' => 'y',
'mtime' => new Expression('UNIX_TIMESTAMP() * 1000')
],
['id = ?' => $id]
['id = ?' => $certInfo->certId]

Check failure on line 52 in application/clicommands/ImportCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Access to an undefined property object::$certId.

Check failure on line 52 in application/clicommands/ImportCommand.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Access to an undefined property object::$certId.
);

$count++;
Expand Down
6 changes: 3 additions & 3 deletions library/X509/CertificateUtils.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in library/X509/CertificateUtils.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\X509\\CertificateUtils\:\:findOrInsertCert\(\) return type has no value type specified in iterable type array\.$# in path /home/runner/work/icingaweb2-module-x509/icingaweb2-module-x509/library/X509/CertificateUtils.php was not matched in reported errors.

Check failure on line 1 in library/X509/CertificateUtils.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\X509\\CertificateUtils\:\:findOrInsertCert\(\) return type has no value type specified in iterable type array\.$# in path /home/runner/work/icingaweb2-module-x509/icingaweb2-module-x509/library/X509/CertificateUtils.php was not matched in reported errors.

// Icinga Web 2 X.509 Module | (c) 2018 Icinga GmbH | GPLv2

Expand Down Expand Up @@ -206,7 +206,7 @@
* @param Connection $db
* @param mixed $cert
*
* @return array
* @return object
*/
public static function findOrInsertCert(Connection $db, $cert)
{
Expand All @@ -223,7 +223,7 @@

$row = $row->first();
if ($row) {
return [$row->id, $row->issuer_hash];
return (object)['certId' => $row->id, 'issuerHash' => $row->issuer_hash, 'fingerprint' => $fingerprint];
}

Logger::debug("Importing certificate: %s", $certInfo['name']);
Expand Down Expand Up @@ -281,7 +281,7 @@

CertificateUtils::insertSANs($db, $certId, $sans);

return [$certId, $issuerHash];
return (object)['certId' => $certId, 'issuerHash' => $issuerHash, 'fingerprint' => $fingerprint];
}

private static function insertSANs($db, $certId, iterable $sans): void
Expand Down
22 changes: 14 additions & 8 deletions library/X509/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Icinga\Module\X509\Model\X509Target;
use Icinga\Module\X509\React\StreamOptsCaptureConnector;
use Icinga\Util\Json;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Query;
use ipl\Scheduler\Common\TaskProperties;
use ipl\Scheduler\Contract\Task;
use ipl\Sql\Connection;
Expand Down Expand Up @@ -696,34 +698,38 @@

$chainId = $this->db->lastInsertId();

$lastCertInfo = [];
$lastCertInfo = null;
foreach ($chain as $index => $cert) {
$lastCertInfo = CertificateUtils::findOrInsertCert($this->db, $cert);
list($certId, $_) = $lastCertInfo;

$this->db->insert(
'x509_certificate_chain_link',
[
'certificate_chain_id' => $chainId,
$this->db->quoteIdentifier('order') => $index,
'certificate_id' => $certId,
'certificate_id' => $lastCertInfo->certId,

Check failure on line 709 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Access to an undefined property object::$certId.

Check failure on line 709 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Access to an undefined property object::$certId.
'ctime' => new Expression('UNIX_TIMESTAMP() * 1000')
]
);

$lastCertInfo[] = $index;
$lastCertInfo->order = $index;

Check failure on line 714 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Access to an undefined property object::$order.

Check failure on line 714 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Access to an undefined property object::$order.
}

// There might be chains that do not include the self-signed top-level Ca,
// so we need to include it manually here, as we need to display the full
// chain in the UI.
$binaryBehavior = (new Binary([]))->setQuery((new Query())->setDb($this->db));
$rootCa = X509Certificate::on($this->db)
->columns(['id'])
->filter(Filter::equal('subject_hash', $lastCertInfo[1]))
->filter(Filter::equal('subject_hash', $lastCertInfo->issuerHash))

Check failure on line 723 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Cannot access property $issuerHash on object|null.

Check failure on line 723 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Cannot access property $issuerHash on object|null.
->filter(Filter::equal('self_signed', true))
// Since we don't enforce the subject_hash of the certificates to be unambiguous, we might end up
// with more than one self-signed CA with the same hash and CN but different validity timestamps,
// and in such situations we need to make sure to retrieve the correct certificate (the one
// containing the expected fingerprint).
->orderBy(new Expression('%s = ?', ['fingerprint'], $binaryBehavior->toDb($lastCertInfo->fingerprint, 'fingerprint', '')), SORT_DESC)

Check failure on line 729 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Cannot access property $fingerprint on object|null.

Check failure on line 729 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Parameter #1 $orderBy of method ipl\Orm\Query::orderBy() expects array|int|string, ipl\Sql\Expression given.

Check failure on line 729 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Cannot access property $fingerprint on object|null.

Check failure on line 729 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Parameter #1 $orderBy of method ipl\Orm\Query::orderBy() expects array|int|string, ipl\Sql\Expression given.
->first();

if ($rootCa && $rootCa->id !== $lastCertInfo[0]) {
if ($rootCa && $rootCa->id !== (int) $lastCertInfo->certId) {

Check failure on line 732 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Cannot access property $certId on object|null.

Check failure on line 732 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Cannot access property $certId on object|null.
$this->db->update(
'x509_certificate_chain',
['length' => count($chain) + 1],
Expand All @@ -734,7 +740,7 @@
'x509_certificate_chain_link',
[
'certificate_chain_id' => $chainId,
$this->db->quoteIdentifier('order') => $lastCertInfo[2] + 1,
$this->db->quoteIdentifier('order') => $lastCertInfo->order + 1,

Check failure on line 743 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Cannot access property $order on object|null.

Check failure on line 743 in library/X509/Job.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Cannot access property $order on object|null.
'certificate_id' => $rootCa->id,
'ctime' => new Expression('UNIX_TIMESTAMP() * 1000')
]
Expand Down
3 changes: 2 additions & 1 deletion library/X509/Web/Control/SearchBar/ObjectSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Icinga\Module\X509\Web\Control\SearchBar;

use DateTime;
use Exception;
use Icinga\Module\X509\Common\Database;
use ipl\Orm\Exception\InvalidColumnException;
Expand Down Expand Up @@ -137,7 +138,7 @@ protected function fetchValueSuggestions($column, $searchTerm, Filter\Chain $sea
$value = $value ? 'y' : 'n';
}

yield $value;
yield $value instanceof DateTime ? $value->getTimestamp() : $value;
}
} catch (InvalidColumnException $e) {
throw new SearchException(sprintf(t('"%s" is not a valid column'), $e->getColumn()));
Expand Down
21 changes: 3 additions & 18 deletions phpstan-baseline-common.neon
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ parameters:
count: 1
path: application/controllers/CertificateController.php

-
message: "#^Parameter \\#1 \\$cert of method Icinga\\\\Module\\\\X509\\\\CertificateDetails\\:\\:setCert\\(\\) expects Icinga\\\\Module\\\\X509\\\\Model\\\\X509Certificate, Icinga\\\\Module\\\\X509\\\\Model\\\\X509Certificate\\|null given\\.$#"
count: 1
path: application/controllers/CertificateController.php

-
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -155,31 +150,21 @@ parameters:
count: 1
path: application/controllers/ChainController.php

-
message: "#^Cannot access property \\$target on Icinga\\\\Module\\\\X509\\\\Model\\\\X509CertificateChain\\|null\\.$#"
count: 3
path: application/controllers/ChainController.php

-
message: "#^Method Icinga\\\\Module\\\\X509\\\\Controllers\\\\ChainController\\:\\:indexAction\\(\\) has no return type specified\\.$#"
count: 1
path: application/controllers/ChainController.php

-
message: "#^Offset 'invalid_reason' does not exist on Icinga\\\\Module\\\\X509\\\\Model\\\\X509CertificateChain\\|null\\.$#"
count: 1
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
count: 2
path: application/controllers/ChainController.php

-
message: "#^Offset 'valid' does not exist on Icinga\\\\Module\\\\X509\\\\Model\\\\X509CertificateChain\\|null\\.$#"
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
path: application/controllers/ChainController.php

-
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
count: 2
path: application/controllers/ChainController.php

-
message: "#^Method Icinga\\\\Module\\\\X509\\\\Controllers\\\\ConfigController\\:\\:backendAction\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
Loading