Skip to content

Commit

Permalink
Merge pull request #41 from igorhrcek/issue-38
Browse files Browse the repository at this point in the history
feat: Switched default file permissions from 666 to more secure 644
  • Loading branch information
igorhrcek authored Apr 5, 2022
2 parents 03df726 + f349ecb commit 3d9ccc7
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ wp secure fix-permissions
```

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function hasSecureBlock() : bool {
*
* @return bool
*/
public function createFile(int $permissions = 0666) : bool {
public function createFile(int $permissions = 0644) : bool {
if(!$this->fileExist()) {
$path = explode("/", $this->path);
$fileName = $path[count($path) - 1];
Expand Down
2 changes: 1 addition & 1 deletion src/SubCommands/FixFileAndDirPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FixFileAndDirPermissions {
/**
* @var int Default permission mask for the file
*/
public int $filePermissions = 0666;
public int $filePermissions = 0644;

/**
* @var int Default permission mask for the directory
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/FileManager/FileReadableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function setUp(): void {

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

$unreadableFile = FileHelper::create('nginx.conf', 0000);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/FileManager/FileWritableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setUp(): void
}

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

$nonWritableFile = FileHelper::create('nginx.conf', 0755);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/FileManager/WriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function setUp(): void {
$content2 = file_get_contents(getcwd() . '/tests/assets/htaccess-secured.txt');
$this->file = FileHelper::create('.htaccess', 0755, $content);
$this->file2 = FileHelper::create('.htaccess2', 0777, $content);
$this->file3 = FileHelper::create('.htaccess-secured', 0666, $content2);
$this->file3 = FileHelper::create('.htaccess-secured', 0644, $content2);
$this->root->addChild($this->file);
$this->root->addChild($this->file2);
$this->root->addChild($this->file3);
Expand Down

0 comments on commit 3d9ccc7

Please sign in to comment.