diff --git a/README.md b/README.md index b16e3d965..cc8c70a19 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ permissions: ```json { - "chmod": "0755" + "chmod": "0700" } ``` diff --git a/box.json.dist b/box.json.dist index aae5d34d3..461943561 100644 --- a/box.json.dist +++ b/box.json.dist @@ -1,6 +1,4 @@ { - "chmod": "0755", - "banner": [ "This file is part of the box project.", "", diff --git a/src/Configuration.php b/src/Configuration.php index 2ea5d031d..f8f13c2c7 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -1362,7 +1362,7 @@ private static function retrieveFileMode(stdClass $raw): ?int return intval($raw->chmod, 8); } - return null; + return intval(0755, 8); } private static function retrieveMainScriptPath(stdClass $raw, string $basePath, ?array $decodedJsonContents): ?string diff --git a/tests/ConfigurationTest.php b/tests/ConfigurationTest.php index 6337a7365..1f15d12ce 100644 --- a/tests/ConfigurationTest.php +++ b/tests/ConfigurationTest.php @@ -530,10 +530,10 @@ public function test_the_compression_algorithm_cannot_be_an_invalid_algorithm($c } } - public function test_no_file_mode_is_configured_by_default(): void + public function test_a_file_mode_is_configured_by_default(): void { - $this->assertNull($this->config->getFileMode()); - $this->assertNull($this->getNoFileConfig()->getFileMode()); + $this->assertSame(493, $this->config->getFileMode()); + $this->assertSame(493, $this->getNoFileConfig()->getFileMode()); } public function test_configure_file_mode(): void @@ -541,18 +541,18 @@ public function test_configure_file_mode(): void // Octal value provided $this->setConfig([ 'files' => [self::DEFAULT_FILE], - 'chmod' => '0755', + 'chmod' => '0644', ]); - $this->assertSame(0755, $this->config->getFileMode()); + $this->assertSame(420, $this->config->getFileMode()); // Decimal value provided $this->setConfig([ 'files' => [self::DEFAULT_FILE], - 'chmod' => '755', + 'chmod' => '0644', ]); - $this->assertSame(0755, $this->config->getFileMode()); + $this->assertSame(420, $this->config->getFileMode()); } public function test_a_main_script_path_is_configured_by_default(): void @@ -1593,7 +1593,7 @@ public function test_it_can_be_created_with_only_default_values(): void new MapFile($this->tmp, []), $this->config->getFileMapper() ); - $this->assertNull($this->config->getFileMode()); + $this->assertSame(493, $this->config->getFileMode()); $this->assertSame([], $this->config->getFiles()); $this->assertSame('', $this->config->getMainScriptContents()); $this->assertSame($this->tmp.'/index.php', $this->config->getMainScriptPath()); diff --git a/tests/Console/Command/CompileTest.php b/tests/Console/Command/CompileTest.php index c85d9f30e..4cc6c698e 100644 --- a/tests/Console/Command/CompileTest.php +++ b/tests/Console/Command/CompileTest.php @@ -101,7 +101,7 @@ public function test_it_can_build_a_PHAR_file(): void [ 'alias' => 'alias-test.phar', 'banner' => 'custom banner', - 'chmod' => '0755', + 'chmod' => '0700', 'compactors' => [Php::class], 'directories' => ['a'], 'files' => ['test.php'], @@ -166,7 +166,7 @@ public function test_it_can_build_a_PHAR_file(): void ? No compression ? Signing using a private key Private key passphrase: -? Setting file permissions to 0755 +? Setting file permissions to 0700 * Done. // PHAR: 45 files (100B) @@ -375,6 +375,7 @@ public function test_it_can_build_a_PHAR_without_any_configuration(): void ? Dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 49 files (100B) @@ -1726,6 +1727,7 @@ public function test_it_can_build_a_PHAR_overwriting_an_existing_one_in_verbose_ ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -1977,6 +1979,7 @@ public function test_it_can_build_a_PHAR_with_a_custom_banner(): void ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -2036,6 +2039,7 @@ public function test_it_can_build_a_PHAR_with_a_stub_file(): void ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -2100,6 +2104,7 @@ public function test_it_can_build_a_PHAR_with_the_default_stub_file(): void ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 2 files (100B) @@ -2164,6 +2169,7 @@ public function test_it_can_build_a_PHAR_without_a_main_script(): void ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -2233,6 +2239,7 @@ public function test_it_can_build_an_empty_PHAR(): void ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -2306,6 +2313,7 @@ public function test_it_can_build_a_PHAR_with_compressed_code(): void ? Removing the Composer dump artefacts ? Compressing with the algorithm "GZ" > Warning: the extension "zlib" will now be required to execute the PHAR +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -2375,6 +2383,7 @@ public function test_it_can_build_a_PHAR_in_a_non_existent_directory(): void ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -2522,6 +2531,7 @@ public function test_it_can_build_a_PHAR_file_without_a_shebang_line(): void ? Removing the Composer dump artefacts ? Compressing with the algorithm "GZ" > Warning: the extension "zlib" will now be required to execute the PHAR +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B) @@ -2599,6 +2609,7 @@ public function test_it_can_build_a_PHAR_with_an_output_which_does_not_have_a_PH ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression +? Setting file permissions to 0755 * Done. // PHAR: 1 file (100B)