Skip to content

Commit 739e3fc

Browse files
committed
Updated README with more information. Added *.phar to asset file types blacklist
1 parent 64a2f46 commit 739e3fc

File tree

2 files changed

+60
-29
lines changed

2 files changed

+60
-29
lines changed

README.md

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,79 @@ Composer plugin for improving the website security for composer-based Drupal web
66

77
## Why use this Plugin?
88
The critical security issue with [Coder](https://www.drupal.org/project/coder) is a good example to consider moving PHP files outside of docroot:
9-
- [Remote Code Execution - SA-CONTRIB-2016-039](https://www.drupal.org/node/2765575)
9+
- [SA-CONTRIB-2016-039 - Remote Code Execution](https://www.drupal.org/node/2765575)
1010
- https://twitter.com/drupalsecurity/status/753263548458004480
1111

1212
More related links:
1313
- [Moving all PHP files out of the docroot](https://www.drupal.org/node/2767907)
1414
- [#1672986: Option to have all php files outside of web root](https://www.drupal.org/node/1672986)
1515

1616
## Requirements
17-
Except for Windows, this plugin should work on environments that have Composer support. [Windows support issue](https://github.com/drupal-composer/drupal-paranoia/issues/5).
17+
Except for Windows, this plugin should work on environments that have Composer support. Do you use Windows? [Help us](https://github.com/drupal-composer/drupal-paranoia/issues/5).
1818

19-
## Configuration
19+
## Installation
2020
Make sure you have a based [drupal-composer/drupal-project](https://github.com/drupal-composer/drupal-project) project created.
2121

22-
Rename your current docroot directory to `app`.
22+
Rename your current docroot directory to `/app`.
2323
```
24+
cd drupal-project-root
2425
mv web app
2526
```
2627

27-
Update the `composer.json` of your root package with the following changes:
28+
Update the `composer.json` of your root package with the following values:
2829
```json
2930
"extra": {
31+
"drupal-paranoia": {
32+
"app-dir": "app",
33+
"web-dir": "web"
34+
},
3035
"installer-paths": {
3136
"app/core": ["type:drupal-core"],
3237
"app/libraries/{$name}": ["type:drupal-library"],
3338
"app/modules/contrib/{$name}": ["type:drupal-module"],
3439
"app/profiles/contrib/{$name}": ["type:drupal-profile"],
3540
"app/themes/contrib/{$name}": ["type:drupal-theme"],
3641
"drush/contrib/{$name}": ["type:drupal-drush"]
37-
},
38-
"drupal-paranoia": {
39-
"app-dir": "app",
40-
"web-dir": "web"
41-
},
42-
"..."
42+
}
4343
}
4444
```
4545

46+
Explaining:
47+
- __/app__ folder: Drupal full installation.
48+
- __/web__ folder: Will contain only symlinks of the assets files and PHP stub files (index.php, install.php, etc) from the `/app` folder.
49+
4650
Use `composer require ...` to install this Plugin on your project.
4751
```
4852
composer require drupal-composer/drupal-paranoia:~1
4953
```
5054

5155
Done! The plugin and the new docroot are now installed.
5256

53-
### Optional Configurations
57+
### Asset file types
58+
The asset files are symlinked from `/app` to `/web` folder.
5459

55-
#### Modify the asset file types
60+
Default asset file types are provided by the plugin:
61+
```
62+
robots.txt
63+
.htaccess
64+
*.css
65+
*.eot
66+
*.ico
67+
*.gif
68+
*.jpeg
69+
*.jpg
70+
*.js
71+
*.otf
72+
*.png
73+
*.svg
74+
*.ttf
75+
*.woff
76+
*.woff2
77+
```
5678

5779
To extend the list of assets file types you can use the `asset-files` config:
5880
```json
5981
"extra": {
60-
"...",
6182
"drupal-paranoia": {
6283
"app-dir": "app",
6384
"web-dir": "web",
@@ -70,8 +91,7 @@ To extend the list of assets file types you can use the `asset-files` config:
7091
}
7192
```
7293

73-
If you need to modify it you can use the
74-
`post-drupal-set-asset-file-types` event:
94+
If you need to modify the list you can use the `post-drupal-set-asset-file-types` event:
7595
```json
7696
"scripts": {
7797
"post-drupal-set-asset-file-types": [
@@ -104,12 +124,26 @@ class ScriptHandler {
104124
}
105125
```
106126

107-
#### Plugin events
127+
By the purpose of this plugin, the following files types are __not allowed__ and if listed they will be ignored:
128+
```
129+
*.inc
130+
*.install
131+
*.module
132+
*.phar
133+
*.php
134+
*.profile
135+
*.theme
136+
```
137+
138+
### Web server docroot
139+
Change the document root config of your web server to point to `/web` folder.
140+
141+
## Plugin events
108142
This plugin fires the following named event during its execution process:
109143

110144
- __drupal-paranoia-post-command-run__: Occurs after the command `drupal:paranoia` is executed.
111145

112-
##### Example of event subscriber
146+
### Example of event subscriber
113147

114148
```php
115149
<?php
@@ -146,22 +180,18 @@ class MyClass implements PluginInterface, EventSubscriberInterface
146180
}
147181
```
148182

149-
## Folder structure
150-
Your project now is basically structured on two folders.
151-
- __app__: Contains the files and folders of the full Drupal installation.
152-
- __web__: Contains only the __symlinks of the assets files__ and the __PHP stub files__ from the `app` folder.
183+
## Local development
184+
Every time you install or update a Drupal package via Composer, the `/web` folder will recreated.
153185

154-
Every time that you install or update a Drupal package via Composer, the `web` folder is automatically recreated.
186+
```
187+
composer require drupal/devel:~1.0
188+
> drupal-paranoia: docroot folder has been rebuilt.
189+
```
155190

156-
If necessary, you can rebuild it manually, running the command
191+
When working with themes, CSS and JS for example, it may be necessary to rebuild the folder manually to symlink the new assets.
157192
```
158193
composer drupal:paranoia
159194
```
160195

161-
This could be necessary when updating themes images, CSS and JS files.
162-
163196
### Public files
164197
This plugin assumes that the public files folder exists at `app/sites/<site>/files` and symlinks `web/sites/<site>/files -> ../../../app/sites/<site>/files`.
165-
166-
## Important
167-
The document root configuration of your web server should point to the `web` path.

src/Installer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ public function createAssetSymlinks() {
284284
$finder->notName('*.inc');
285285
$finder->notName('*.install');
286286
$finder->notName('*.module');
287+
$finder->notName('*.phar');
287288
$finder->notName('*.php');
288289
$finder->notName('*.profile');
289290
$finder->notName('*.theme');

0 commit comments

Comments
 (0)