From c055675d1be19b0d7d472e816aa1819c3738d7d2 Mon Sep 17 00:00:00 2001 From: bepsvpt <8221099+bepsvpt@users.noreply.github.com> Date: Mon, 16 Dec 2024 23:48:18 +0800 Subject: [PATCH] fix: lint --- tests/Builders/ClearSiteDataBuilderTest.php | 2 +- .../ContentSecurityPolicyBuilderTest.php | 30 ++++++++-------- ...pectCertificateTransparencyBuilderTest.php | 6 ++-- .../Builders/PermissionsPolicyBuilderTest.php | 8 ++--- .../StrictTransportSecurityBuilderTest.php | 4 +-- tests/MiddlewareTest.php | 4 +-- tests/SecureHeadersTest.php | 34 +++++++++---------- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/Builders/ClearSiteDataBuilderTest.php b/tests/Builders/ClearSiteDataBuilderTest.php index fb36960..c24a2a9 100644 --- a/tests/Builders/ClearSiteDataBuilderTest.php +++ b/tests/Builders/ClearSiteDataBuilderTest.php @@ -7,7 +7,7 @@ final class ClearSiteDataBuilderTest extends TestCase { - public function testClearSiteData() + public function test_clear_site_data() { $config = []; diff --git a/tests/Builders/ContentSecurityPolicyBuilderTest.php b/tests/Builders/ContentSecurityPolicyBuilderTest.php index 594ed1d..10e7ed9 100644 --- a/tests/Builders/ContentSecurityPolicyBuilderTest.php +++ b/tests/Builders/ContentSecurityPolicyBuilderTest.php @@ -7,7 +7,7 @@ final class ContentSecurityPolicyBuilderTest extends TestCase { - public function testEmptyDirective() + public function test_empty_directive() { $config = [ 'img-src' => [], @@ -47,7 +47,7 @@ public function testEmptyDirective() ); } - public function testSeldomUsedDirectives() + public function test_seldom_used_directives() { // sandbox $config = [ @@ -173,7 +173,7 @@ public function testSeldomUsedDirectives() ); } - public function testSchemeAutoAppendColon() + public function test_scheme_auto_append_colon() { $config = [ 'img-src' => [ @@ -191,7 +191,7 @@ public function testSchemeAutoAppendColon() ); } - public function testInvalidNonce() + public function test_invalid_nonce() { $config = [ 'img-src' => [ @@ -208,7 +208,7 @@ public function testInvalidNonce() ); } - public function testInvalidHash() + public function test_invalid_hash() { $config = [ 'font-src' => [ @@ -239,7 +239,7 @@ public function testInvalidHash() /* * https://signin.104.com.tw */ - public function testUsing104ContentSecurityPolicy() + public function test_using_104_content_security_policy() { $csp = "default-src api.rollbar.com 'self'; font-src 'self' fonts.gstatic.com heapanalytics.com data:; style-src 'self' 'unsafe-inline' tagmanager.google.com fonts.googleapis.com heapanalytics.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' tagmanager.google.com www.googletagmanager.com www.google-analytics.com ssl.google-analytics.com cdn.heapanalytics.com heapanalytics.com www.google.com.tw certify-js.alexametrics.com cdnjs.cloudflare.com static.104.com.tw data:; img-src 'self' ssl.gstatic.com www.gstatic.com www.googletagmanager.com www.google-analytics.com heapanalytics.com certify.alexametrics.com tls-detect.support.104.com.tw www.google.com.tw stats.g.doubleclick.net www.google.com ac.clazzrooms.com ac.beagiver.com signin.104dc.com signin.104.com.tw graphicwb.104.com.tw static.104.com.tw data:; frame-src 'self' www.google.com; connect-src 'self' www.google-analytics.com heapanalytics.com"; @@ -357,7 +357,7 @@ public function testUsing104ContentSecurityPolicy() /* * https://user.gamer.com.tw/login.php */ - public function testUsingGamerContentSecurityPolicy() + public function test_using_gamer_content_security_policy() { $csp = "frame-ancestors 'self' https://*.gamer.com.tw"; @@ -381,7 +381,7 @@ public function testUsingGamerContentSecurityPolicy() /* * https://secure2.store.apple.com/shop/sign_in */ - public function testUsingAppleContentSecurityPolicy() + public function test_using_apple_content_security_policy() { $csp = "frame-ancestors 'self'"; @@ -401,7 +401,7 @@ public function testUsingAppleContentSecurityPolicy() /* * https://dash.cloudflare.com/login */ - public function testUsingCloudflareContentSecurityPolicy() + public function test_using_cloudflare_content_security_policy() { $csp = "object-src 'none'; script-src 'nonce-Mzk3Nzg4MTcwMiw2MjQ3MTQ3OTk=' 'unsafe-eval' 'strict-dynamic' 'report-sample' https:; base-uri 'self'"; @@ -441,7 +441,7 @@ public function testUsingCloudflareContentSecurityPolicy() /* * https://www.facebook.com */ - public function testUsingFacebookContentSecurityPolicy() + public function test_using_facebook_content_security_policy() { $csp = "default-src * data: blob: 'self'; script-src *.facebook.com *.fbcdn.net *.facebook.net *.google-analytics.com *.virtualearth.net *.google.com 127.0.0.1:* *.spotilocal.com:* 'unsafe-inline' 'unsafe-eval' blob: data: 'self'; style-src data: blob: 'unsafe-inline' *; connect-src *.facebook.com facebook.com *.fbcdn.net *.facebook.net *.spotilocal.com:* wss://*.facebook.com:* https://fb.scanandcleanlocal.com:* attachment.fbsbx.com ws://localhost:* blob: *.cdninstagram.com 'self'; block-all-mixed-content; upgrade-insecure-requests"; @@ -532,7 +532,7 @@ public function testUsingFacebookContentSecurityPolicy() /* * https://github.com/ */ - public function testUsingGitHubContentSecurityPolicy() + public function test_using_github_content_security_policy() { $csp = "default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com www.githubstatus.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com wss://live.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com; img-src 'self' data: github.githubassets.com identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com *.githubusercontent.com customer-stories-feed.github.com spotlights-feed.github.com; manifest-src 'self'; media-src 'none'; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com"; @@ -640,7 +640,7 @@ public function testUsingGitHubContentSecurityPolicy() /* * https://accounts.google.com */ - public function testUsingGoogleContentSecurityPolicy() + public function test_using_google_content_security_policy() { $csp = "script-src 'nonce-oYvCFuvmnmawgMYMpObFBw' 'unsafe-inline' 'unsafe-eval'; object-src 'none'; base-uri 'self'; report-uri /cspreport"; @@ -678,7 +678,7 @@ public function testUsingGoogleContentSecurityPolicy() /* * https://www.paypal.com/tw/signin */ - public function testUsingPayPalContentSecurityPolicy() + public function test_using_paypal_content_security_policy() { $csp = "default-src 'self' https://*.paypal.com https://*.paypalobjects.com; frame-src 'self' https://*.brighttalk.com https://*.paypal.com https://*.paypalobjects.com https://www.youtube-nocookie.com https://www.xoom.com https://www.wootag.com; script-src 'nonce-JTDEJ1tJpkGVoRUcTBE9s6EbWk0sVDYtLrZ909/1KRzJcxGE' 'self' https://*.paypal.com https://*.paypalobjects.com https://assets-cdn.s-xoom.com 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://nominatim.openstreetmap.org https://*.paypal.com https://*.paypalobjects.com https://*.google-analytics.com https://*.salesforce.com https://*.force.com https://*.eloqua.com https://nexus.ensighten.com https://api.paypal-retaillocator.com https://*.brighttalk.com https://*.sperse.io https://*.dialogtech.com; style-src 'self' https://*.paypal.com https://*.paypalobjects.com https://assets-cdn.s-xoom.com 'unsafe-inline'; font-src 'self' https://*.paypal.com https://*.paypalobjects.com https://assets-cdn.s-xoom.com data:; img-src 'self' https: data:; form-action 'self' https://*.paypal.com https://*.salesforce.com https://*.eloqua.com https://secure.opinionlab.com; base-uri 'self' https://*.paypal.com; object-src 'none'; frame-ancestors 'self' https://*.paypal.com; block-all-mixed-content; report-uri https://www.paypal.com/csplog/api/log/csp"; @@ -825,7 +825,7 @@ public function testUsingPayPalContentSecurityPolicy() /* * https://beta.protonmail.com/ */ - public function testUsingProtonMailContentSecurityPolicy() + public function test_using_proton_mail_content_security_policy() { $csp = "default-src 'self'; connect-src 'self' blob:; script-src 'self' blob: 'sha256-eAhF1Kdccp0BTXM6nMW7SYBdV0c3fZwzcC177TQ692g='; style-src 'self' 'unsafe-inline'; img-src http: https: data: blob: cid:; frame-src 'self' blob: https://secure.protonmail.com; object-src 'self' blob:; child-src 'self' data: blob:; report-uri https://reports.protonmail.ch/reports/csp; frame-ancestors 'none'"; @@ -920,7 +920,7 @@ public function testUsingProtonMailContentSecurityPolicy() /* * https://www.reddit.com/login */ - public function testUsingRedditContentSecurityPolicy() + public function test_using_reddit_content_security_policy() { $csp = "frame-ancestors 'self' https://www.reddit.com https://new.reddit.com"; diff --git a/tests/Builders/ExpectCertificateTransparencyBuilderTest.php b/tests/Builders/ExpectCertificateTransparencyBuilderTest.php index 0baa6f3..375351b 100644 --- a/tests/Builders/ExpectCertificateTransparencyBuilderTest.php +++ b/tests/Builders/ExpectCertificateTransparencyBuilderTest.php @@ -7,7 +7,7 @@ final class ExpectCertificateTransparencyBuilderTest extends TestCase { - public function testExpectCertificateTransparency() + public function test_expect_certificate_transparency() { $config = [ 'max-age' => 1440, @@ -54,7 +54,7 @@ public function testExpectCertificateTransparency() ); } - public function testNegativeMaxAge() + public function test_negative_max_age() { $config = [ 'max-age' => -666, @@ -66,7 +66,7 @@ public function testNegativeMaxAge() ); } - public function testInvalidReportUri() + public function test_invalid_report_uri() { $config = [ 'max-age' => 86400, diff --git a/tests/Builders/PermissionsPolicyBuilderTest.php b/tests/Builders/PermissionsPolicyBuilderTest.php index 27b9d70..f5007d5 100644 --- a/tests/Builders/PermissionsPolicyBuilderTest.php +++ b/tests/Builders/PermissionsPolicyBuilderTest.php @@ -7,7 +7,7 @@ final class PermissionsPolicyBuilderTest extends TestCase { - public function testPolicies() + public function test_policies() { $config = [ 'autoplay' => [ @@ -40,7 +40,7 @@ public function testPolicies() ); } - public function testPolicyKeyPriority() + public function test_policy_key_priority() { $config = [ 'accelerometer' => [ @@ -69,7 +69,7 @@ public function testPolicyKeyPriority() ); } - public function testPolicyMissingKeys() + public function test_policy_missing_keys() { $config = [ 'accelerometer' => [ @@ -85,7 +85,7 @@ public function testPolicyMissingKeys() ); } - public function testInvalidPolicyAllowList() + public function test_invalid_policy_allow_list() { $config = [ 'accelerometer' => [ diff --git a/tests/Builders/StrictTransportSecurityBuilderTest.php b/tests/Builders/StrictTransportSecurityBuilderTest.php index b24f177..a994f7b 100644 --- a/tests/Builders/StrictTransportSecurityBuilderTest.php +++ b/tests/Builders/StrictTransportSecurityBuilderTest.php @@ -7,7 +7,7 @@ final class StrictTransportSecurityBuilderTest extends TestCase { - public function testStrictTransportSecurity() + public function test_strict_transport_security() { $config = [ 'max-age' => 1440, @@ -54,7 +54,7 @@ public function testStrictTransportSecurity() ); } - public function testNegativeMaxAge() + public function test_negative_max_age() { $config = [ 'max-age' => -666, diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index cc3d70b..1a1138b 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -48,7 +48,7 @@ protected function getEnvironmentSetUp($app) $app->make(HttpKernel::class)->pushMiddleware(SecureHeadersMiddleware::class); } - public function testMiddleware() + public function test_middleware() { $this->app['router']->get('/', function () { return 'Hello World!'; @@ -59,7 +59,7 @@ public function testMiddleware() $this->assertArrayHasKey('x-frame-options', $headers); } - public function testBinaryResponse() + public function test_binary_response() { $this->app['router']->get('/', function () { return response()->download(__DIR__.'/../README.md'); diff --git a/tests/SecureHeadersTest.php b/tests/SecureHeadersTest.php index c29aeb8..7c75f78 100644 --- a/tests/SecureHeadersTest.php +++ b/tests/SecureHeadersTest.php @@ -12,7 +12,7 @@ final class SecureHeadersTest extends TestCase */ protected $configPath = __DIR__.'/../config/secure-headers.php'; - public function testSendHeaders() + public function test_send_headers() { (new SecureHeaders($this->config()))->send(); @@ -29,7 +29,7 @@ public function testSendHeaders() ); } - public function testDisableHeader() + public function test_disable_header() { $config = $this->config(); @@ -42,7 +42,7 @@ public function testDisableHeader() $this->assertArrayNotHasKey('X-Download-Options', $headers); } - public function testLoadFromFile() + public function test_load_from_file() { $headers = SecureHeaders::fromFile($this->configPath)->headers(); @@ -51,14 +51,14 @@ public function testLoadFromFile() $this->assertArrayHasKey('X-Frame-Options', $headers); } - public function testFileNotFound() + public function test_file_not_found() { $this->expectException(InvalidArgumentException::class); SecureHeaders::fromFile(__DIR__.'/not-found'); } - public function testServerHeader() + public function test_server_header() { $config = $this->config(); @@ -76,7 +76,7 @@ public function testServerHeader() $this->assertSame('Example', $headers['Server']); } - public function testXPoweredByHeader() + public function test_x_powered_by_header() { $config = $this->config(); @@ -109,7 +109,7 @@ public function testXPoweredByHeader() $this->assertSame('Example', $headers['X-Powered-By']); } - public function testContentSecurityPolicy() + public function test_content_security_policy() { $config = $this->config(); @@ -147,7 +147,7 @@ public function testContentSecurityPolicy() ); } - public function testContentSecurityPolicyNonce() + public function test_content_security_policy_nonce() { $nonce = SecureHeaders::nonce(); @@ -178,7 +178,7 @@ public function testContentSecurityPolicyNonce() ); } - public function testContentSecurityPolicyRemoveNonce() + public function test_content_security_policy_remove_nonce() { SecureHeaders::nonce('script'); SecureHeaders::nonce('style'); @@ -217,7 +217,7 @@ public function testContentSecurityPolicyRemoveNonce() ); } - public function testContentSecurityPolicyNonceWillBeClearedAfterHeaderSent() + public function test_content_security_policy_nonce_will_be_cleared_after_header_sent() { $times = 10; @@ -233,7 +233,7 @@ public function testContentSecurityPolicyNonceWillBeClearedAfterHeaderSent() } } - public function testPermissionsPolicy() + public function test_permissions_policy() { $config = $this->config(); @@ -257,7 +257,7 @@ public function testPermissionsPolicy() $this->assertArrayNotHasKey('Permissions-Policy', $headers); } - public function testStrictTransportSecurity() + public function test_strict_transport_security() { $config = $this->config(); @@ -276,7 +276,7 @@ public function testStrictTransportSecurity() ); } - public function testExpectCertificateTransparency() + public function test_expect_certificate_transparency() { $config = $this->config(); @@ -295,7 +295,7 @@ public function testExpectCertificateTransparency() ); } - public function testClearSiteData() + public function test_clear_site_data() { $config = $this->config(); @@ -314,7 +314,7 @@ public function testClearSiteData() ); } - public function testCrossOriginPolicy() + public function test_cross_origin_policy() { $config = $this->config(); @@ -336,7 +336,7 @@ public function testCrossOriginPolicy() ); } - public function testReportingEndpoints() + public function test_reporting_endpoints() { $config = $this->config(); @@ -361,7 +361,7 @@ public function testReportingEndpoints() ); } - public function testNetworkErrorLogging() + public function test_network_error_logging() { $config = $this->config();