Skip to content

Commit 3d9ccc7

Browse files
authored
Merge pull request #41 from igorhrcek/issue-38
feat: Switched default file permissions from 666 to more secure 644
2 parents 03df726 + f349ecb commit 3d9ccc7

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ wp secure fix-permissions
144144
```
145145

146146
Use this command to verify that the permissions of all files and directories are set according the WordPress recommendations.
147-
This command will set **0666** to all files and **0755** to all folders inside WordPress installation.
147+
This command will set **0644** to all files and **0755** to all folders inside WordPress installation.
148148

149149
**IMPORTANT: Don't use this command if you don't know what you are doing here!**
150150

src/FileManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public function hasSecureBlock() : bool {
262262
*
263263
* @return bool
264264
*/
265-
public function createFile(int $permissions = 0666) : bool {
265+
public function createFile(int $permissions = 0644) : bool {
266266
if(!$this->fileExist()) {
267267
$path = explode("/", $this->path);
268268
$fileName = $path[count($path) - 1];

src/SubCommands/FixFileAndDirPermissions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class FixFileAndDirPermissions {
66
/**
77
* @var int Default permission mask for the file
88
*/
9-
public int $filePermissions = 0666;
9+
public int $filePermissions = 0644;
1010

1111
/**
1212
* @var int Default permission mask for the directory

tests/Unit/FileManager/FileReadableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function setUp(): void {
1717

1818
public function testFileIsWritable(): void {
1919
$this->expectException(FileIsNotReadable::class);
20-
$readableFile = FileHelper::create('.htaccess', 0666);
20+
$readableFile = FileHelper::create('.htaccess', 0644);
2121
$this->root->addChild($readableFile);
2222

2323
$unreadableFile = FileHelper::create('nginx.conf', 0000);

tests/Unit/FileManager/FileWritableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function setUp(): void
1616
}
1717

1818
public function testFileIsWritable(): void {
19-
$writableFile = FileHelper::create('.htaccess', 0666);
19+
$writableFile = FileHelper::create('.htaccess', 0644);
2020
$this->root->addChild($writableFile);
2121

2222
$nonWritableFile = FileHelper::create('nginx.conf', 0755);

tests/Unit/FileManager/WriteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function setUp(): void {
4545
$content2 = file_get_contents(getcwd() . '/tests/assets/htaccess-secured.txt');
4646
$this->file = FileHelper::create('.htaccess', 0755, $content);
4747
$this->file2 = FileHelper::create('.htaccess2', 0777, $content);
48-
$this->file3 = FileHelper::create('.htaccess-secured', 0666, $content2);
48+
$this->file3 = FileHelper::create('.htaccess-secured', 0644, $content2);
4949
$this->root->addChild($this->file);
5050
$this->root->addChild($this->file2);
5151
$this->root->addChild($this->file3);

0 commit comments

Comments
 (0)