From bdb92acd47d139fe22b5122f619591e4f0909e17 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 15 Sep 2026 09:17:59 +0300 Subject: [PATCH] Check copyright headers and add missing headers WE2-1296 Signed-off-by: Raul Metsma --- .github/workflows/copyright.yml | 11 + .github/workflows/coverity.yml | 3 + .github/workflows/php.yml | 3 + LICENSE | 2 +- example/public/index.php | 24 +- example/public/js/errors.js | 2 +- example/public/js/web-eid.js | 2 +- example/src/Auth.php | 24 +- example/src/Config.php | 84 +++---- example/src/LogWriter.php | 24 +- example/src/Logger.php | 24 +- example/src/Pages.php | 24 +- example/src/Router.php | 24 +- example/src/Template.php | 24 +- example/src/app.conf.php | 2 + src/authtoken/WebEidAuthToken.php | 24 +- src/certificate/CertificateData.php | 24 +- src/certificate/CertificateLoader.php | 24 +- src/certificate/CertificateValidator.php | 24 +- .../SubjectCertificatePolicies.php | 24 +- src/challenge/ChallengeNonce.php | 24 +- src/challenge/ChallengeNonceGenerator.php | 24 +- .../ChallengeNonceGeneratorBuilder.php | 24 +- src/challenge/ChallengeNonceGeneratorImpl.php | 24 +- src/challenge/ChallengeNonceStore.php | 24 +- src/exceptions/AuthTokenException.php | 24 +- src/exceptions/AuthTokenParseException.php | 24 +- .../AuthTokenSignatureValidationException.php | 24 +- .../CertificateDecodingException.php | 24 +- .../CertificateExpiredException.php | 24 +- .../CertificateNotTrustedException.php | 24 +- .../CertificateNotYetValidException.php | 24 +- .../ChallengeNonceExpiredException.php | 24 +- .../ChallengeNonceGenerationException.php | 24 +- .../ChallengeNonceNotFoundException.php | 24 +- .../ChallengeNullOrEmptyException.php | 24 +- src/exceptions/OCSPCertificateException.php | 24 +- .../SessionDoesNotExistException.php | 24 +- ...erCertificateDisallowedPolicyException.php | 24 +- ...UserCertificateMissingPurposeException.php | 24 +- ...serCertificateOCSPCheckFailedException.php | 24 +- .../UserCertificateParseException.php | 24 +- .../UserCertificateRevokedException.php | 24 +- .../UserCertificateWrongPurposeException.php | 24 +- src/ocsp/Ocsp.php | 24 +- src/ocsp/OcspBasicResponse.php | 24 +- src/ocsp/OcspRequest.php | 24 +- src/ocsp/OcspResponse.php | 24 +- src/ocsp/certificate/CertificateLoader.php | 238 ++++++++---------- .../exceptions/OcspCertificateException.php | 24 +- src/ocsp/exceptions/OcspException.php | 24 +- .../OcspResponseDecodeException.php | 24 +- .../exceptions/OcspVerifyFailedException.php | 24 +- src/ocsp/maps/OcspBasicResponseMap.php | 24 +- src/ocsp/maps/OcspRequestMap.php | 24 +- src/ocsp/maps/OcspResponseMap.php | 24 +- src/util/AsnUtil.php | 24 +- src/util/CollectionsUtil.php | 24 +- src/util/DateAndTime.php | 24 +- src/util/DefaultClock.php | 102 +++----- src/util/HashAlgorithm.php | 2 + src/util/SecureRandom.php | 24 +- src/util/TrustedCertificates.php | 24 +- src/validator/AuthTokenSignatureValidator.php | 24 +- .../AuthTokenValidationConfiguration.php | 24 +- src/validator/AuthTokenValidator.php | 24 +- src/validator/AuthTokenValidatorBuilder.php | 24 +- src/validator/AuthTokenValidatorImpl.php | 24 +- .../SubjectCertificateNotRevokedValidator.php | 24 +- .../SubjectCertificatePolicyValidator.php | 24 +- .../SubjectCertificatePurposeValidator.php | 24 +- .../SubjectCertificateTrustedValidator.php | 24 +- .../SubjectCertificateValidator.php | 24 +- .../SubjectCertificateValidatorBatch.php | 24 +- src/validator/ocsp/OcspClient.php | 24 +- src/validator/ocsp/OcspClientImpl.php | 24 +- src/validator/ocsp/OcspRequestBuilder.php | 24 +- src/validator/ocsp/OcspResponseValidator.php | 24 +- src/validator/ocsp/OcspServiceProvider.php | 24 +- src/validator/ocsp/OcspUrl.php | 24 +- src/validator/ocsp/service/AiaOcspService.php | 24 +- .../service/AiaOcspServiceConfiguration.php | 24 +- .../ocsp/service/DesignatedOcspService.php | 24 +- .../DesignatedOcspServiceConfiguration.php | 24 +- src/validator/ocsp/service/OcspService.php | 24 +- tests/authtoken/WebEidAuthTokenTest.php | 24 +- tests/certificate/CertificateDataTest.php | 24 +- .../certificate/CertificateValidatorTest.php | 24 +- .../challenge/ChallengeNonceGeneratorTest.php | 24 +- tests/ocsp/OcspRequestTest.php | 24 +- tests/ocsp/OcspResponseTest.php | 24 +- tests/ocsp/OcspTest.php | 24 +- .../certificate/CertificateLoaderTest.php | 24 +- tests/testutil/AbstractTestWithValidator.php | 24 +- tests/testutil/AuthTokenValidators.php | 24 +- tests/testutil/Certificates.php | 24 +- tests/testutil/Dates.php | 24 +- tests/testutil/Logger.php | 24 +- tests/testutil/OcspServiceMaker.php | 24 +- tests/util/AsnUtilTest.php | 24 +- tests/util/CollectionsUtilTest.php | 24 +- tests/util/UriTest.php | 24 +- tests/validator/AuthTokenAlgorithmTest.php | 24 +- .../AuthTokenCertificateBelgianIdCardTest.php | 25 +- .../AuthTokenCertificateFinnishIdCardTest.php | 25 +- tests/validator/AuthTokenCertificateTest.php | 25 +- tests/validator/AuthTokenSignatureTest.php | 24 +- .../AuthTokenSignatureValidatorTest.php | 24 +- tests/validator/AuthTokenStructureTest.php | 25 +- .../AuthTokenValidationConfigurationTest.php | 24 +- .../AuthTokenValidatorBuilderTest.php | 24 +- ...jectCertificateNotRevokedValidatorTest.php | 24 +- .../SubjectCertificatePolicyValidatorTest.php | 24 +- ...SubjectCertificatePurposeValidatorTest.php | 24 +- .../ocsp/OcspResponseValidatorTest.php | 24 +- .../ocsp/OcspServiceProviderTest.php | 24 +- tests/validator/ocsp/OcspUrlTest.php | 24 +- 117 files changed, 418 insertions(+), 2581 deletions(-) create mode 100644 .github/workflows/copyright.yml diff --git a/.github/workflows/copyright.yml b/.github/workflows/copyright.yml new file mode 100644 index 0000000..fc439ac --- /dev/null +++ b/.github/workflows/copyright.yml @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: Estonian Information System Authority +# SPDX-License-Identifier: MIT + +name: Copyright +on: [push, pull_request] +permissions: + contents: read +jobs: + copyright: + name: Check copyright headers + uses: web-eid/.github/.github/workflows/copyright.yml@9ea5bd0c816309493524bce9f96024ed3cc6ff1d # main diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index dcb7450..31b67bc 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Estonian Information System Authority +# SPDX-License-Identifier: MIT + name: Coverity Scan on: diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index bbf6c5c..9be3325 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Estonian Information System Authority +# SPDX-License-Identifier: MIT + name: PHP Composer on: diff --git a/LICENSE b/LICENSE index 31623c1..422c40b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022-2024 Estonian Information System Authority +Copyright (c) Estonian Information System Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/example/public/index.php b/example/public/index.php index 094c1c1..770c640 100644 --- a/example/public/index.php +++ b/example/public/index.php @@ -1,26 +1,6 @@ configArr = $configArr; - return $instance; - } - - public function overrideFromEnv() - { - foreach ($this->configArr as $key => $value) { - $envKey = 'WEB_EID_SAMPLE_'.strtoupper($key); - $envValue = getenv($envKey); - if ($envValue !== false) { - $this->configArr[$key] = $envValue; - } - } - - return $this; - } - - public function get($name) - { - return isset ($this->configArr[$name]) ? $this->configArr[$name] : null; - } +configArr = $configArr; + return $instance; + } + + public function overrideFromEnv() + { + foreach ($this->configArr as $key => $value) { + $envKey = 'WEB_EID_SAMPLE_'.strtoupper($key); + $envValue = getenv($envKey); + if ($envValue !== false) { + $this->configArr[$key] = $envValue; + } + } + + return $this; + } + + public function get($name) + { + return isset ($this->configArr[$name]) ? $this->configArr[$name] : null; + } } \ No newline at end of file diff --git a/example/src/LogWriter.php b/example/src/LogWriter.php index 62424a3..b9faf6a 100644 --- a/example/src/LogWriter.php +++ b/example/src/LogWriter.php @@ -1,26 +1,6 @@ loadX509($fileContent); - if (!$loaded) { - throw new OcspCertificateException( - "Certificate decoding from Base64 or parsing failed for " . - $pathToFile - ); - } - $this->certificate = $certificate; - return $this; - } - - /** - * Loads the certificate from string and returns the certificate - * - * @param string certString - certificate as string - * @throws OcspCertificateException when the certificate decoding or parse fails - */ - public function fromString(string $certString) - { - $certificate = new X509(); - $loaded = false; - try { - $loaded = $certificate->loadX509($certString); - } catch (Exception $e) { - } - if (!$loaded) { - throw new OcspCertificateException( - "Certificate decoding from Base64 or parsing failed" - ); - } - $this->certificate = $certificate; - return $this; - } - - public function getIssuerCertificateUrl(): string - { - if (!$this->certificate) { - throw new OcspCertificateException("Certificate not loaded"); - } - - $url = ""; - $opts = $this->certificate->getExtension("id-pe-authorityInfoAccess"); - foreach ($opts as $opt) { - if ($opt["accessMethod"] == "id-ad-caIssuers") { - $url = $opt["accessLocation"]["uniformResourceIdentifier"]; - break; - } - } - return $url; - } - - public function getOcspResponderUrl(): string - { - if (!$this->certificate) { - throw new OcspCertificateException("Certificate not loaded"); - } - - $url = ""; - $opts = $this->certificate->getExtension("id-pe-authorityInfoAccess"); - foreach ($opts as $opt) { - if ($opt["accessMethod"] == "id-ad-ocsp" || $opt["accessMethod"] == "id-pkix-ocsp") { - $url = $opt["accessLocation"]["uniformResourceIdentifier"]; - break; - } - } - return $url; - } - - public function getCert(): X509 - { - if (!$this->certificate) { - throw new OcspCertificateException("Certificate not loaded"); - } - return $this->certificate; - } -} +loadX509($fileContent); + if (!$loaded) { + throw new OcspCertificateException( + "Certificate decoding from Base64 or parsing failed for " . + $pathToFile + ); + } + $this->certificate = $certificate; + return $this; + } + + /** + * Loads the certificate from string and returns the certificate + * + * @param string certString - certificate as string + * @throws OcspCertificateException when the certificate decoding or parse fails + */ + public function fromString(string $certString) + { + $certificate = new X509(); + $loaded = false; + try { + $loaded = $certificate->loadX509($certString); + } catch (Exception $e) { + } + if (!$loaded) { + throw new OcspCertificateException( + "Certificate decoding from Base64 or parsing failed" + ); + } + $this->certificate = $certificate; + return $this; + } + + public function getIssuerCertificateUrl(): string + { + if (!$this->certificate) { + throw new OcspCertificateException("Certificate not loaded"); + } + + $url = ""; + $opts = $this->certificate->getExtension("id-pe-authorityInfoAccess"); + foreach ($opts as $opt) { + if ($opt["accessMethod"] == "id-ad-caIssuers") { + $url = $opt["accessLocation"]["uniformResourceIdentifier"]; + break; + } + } + return $url; + } + + public function getOcspResponderUrl(): string + { + if (!$this->certificate) { + throw new OcspCertificateException("Certificate not loaded"); + } + + $url = ""; + $opts = $this->certificate->getExtension("id-pe-authorityInfoAccess"); + foreach ($opts as $opt) { + if ($opt["accessMethod"] == "id-ad-ocsp" || $opt["accessMethod"] == "id-pkix-ocsp") { + $url = $opt["accessLocation"]["uniformResourceIdentifier"]; + break; + } + } + return $url; + } + + public function getCert(): X509 + { + if (!$this->certificate) { + throw new OcspCertificateException("Certificate not loaded"); + } + return $this->certificate; + } +} diff --git a/src/ocsp/exceptions/OcspCertificateException.php b/src/ocsp/exceptions/OcspCertificateException.php index b8c332c..eb03f8f 100644 --- a/src/ocsp/exceptions/OcspCertificateException.php +++ b/src/ocsp/exceptions/OcspCertificateException.php @@ -1,26 +1,6 @@ mockedClock)) { - return $this->mockedClock; - } - return new DateTime(); - } - - public function setClock(DateTime $mockedClock): void - { - $this->mockedClock = $mockedClock; - } - - public function resetClock(): void - { - unset($this->mockedClock); - } +mockedClock)) { + return $this->mockedClock; + } + return new DateTime(); + } + + public function setClock(DateTime $mockedClock): void + { + $this->mockedClock = $mockedClock; + } + + public function resetClock(): void + { + unset($this->mockedClock); + } } \ No newline at end of file diff --git a/src/util/HashAlgorithm.php b/src/util/HashAlgorithm.php index 9a5105a..edb1e50 100644 --- a/src/util/HashAlgorithm.php +++ b/src/util/HashAlgorithm.php @@ -1,4 +1,6 @@