README.md 5.58 KB
Newer Older
odavydyuk's avatar
odavydyuk committed
1
2
# Advanced Audit Tool

odavydyuk's avatar
odavydyuk committed
3
Drupal 8 auditor tool developed by Smile.
odavydyuk's avatar
odavydyuk committed
4

odavydyuk's avatar
odavydyuk committed
5
The module allow checking important information about project.
odavydyuk's avatar
odavydyuk committed
6
7
8

## Installation

odavydyuk's avatar
odavydyuk committed
9
10
### Prerequisites
To be able to set up this module on your project you will need following 
odavydyuk's avatar
odavydyuk committed
11
12
13
14
15
16
list of tools:
* composer
* Drupal installation via composer

### Installation process

odavydyuk's avatar
odavydyuk committed
17
* Run `composer require smile_support/adv_audit` command.
odavydyuk's avatar
odavydyuk committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
* Module will be installed to module/contrib directory with all the dependencies in project's `vendor` folder

## Instruction for writing a new plugin
**Advanced Audit** module uses plugin system where one plugin realizes one point for check.
The module uses own plugin type and it's plugin manager is `src/Plugin/AuditPluginsManager.php`.
Plugins are placed in `/src/Plugin/AuditPlugins/` folder.

### Modules Requirements

Some plugins required appropriate modules. If these modules are not installed on a project, plugins will be skipped. The requirements are set in annotation of each plugin that need it:

```
 *   requirements = {
 *     "module": {
 *       "features",
 *        ...
```
### Description for plugin annotation
```
  @AuditPlugin(
   id = "cron_settings",
   label = @Translation("Cron settings"),
   category = "performance",
   requirements = {},
  )
```
* **id** - The plugin ID (an unique machine name).
* **label** - The human readable name. 
* **category** - The plugin's category id. All available category described in `/config/install/adv_audit.settings.yml `
* **requirements** - The array of requirements that are need for plugin. If requirements are not met, the plugin will be marked as __SKIPPED__.

Each plugin has own configuration file `/config/install/adv_audit.plugins.{plugin_id}.yml`. This configuration files contain values:

```yaml
messages:
  description: "<p>This is description of plugin jobs</p>"
  actions: "<p>Each key supports %placeholders</p>"
  impacts: ""
  fail: ""
  success: ""
settings:
  enabled: 1|0
  severity: low|normal|high
help: ''
```
* **messages** - messages that are appeared in report depend on plugin's results. Can be overridden in plugin's settings form.
* **settings**
  * **enabled** - Status of the plugin. Can be overridden in plugin's settings form. 
  * **severity** - The default level of severity. Can be overridden in plugin's settings form. 

The main plugin's method `perform()` should return status `success()`, `fail()` or `skipped()`. If the plugin returns failed status the issues should be passed in the second argument:
```php
...
      return $this->fail('Reason why plugin has been failed', [
        'issues' => [
          0 => [
            '@issue_title' => 'There are we have some problems in @some_string.',
            '@some_string' => $some_string,
          ],
        ],
        '%link' => Link::createFromRoute($this->t('pass placeholders to messages in config file'), 'needed.route')
          ->toString(),
      ]);
```
The keys `issues` and `@issue_title` are required. Issues support placeholders. Also placeholders can be passed to **messages** as additional elements of the second argument:
```php
[
  'issues' => [$list_of_issues],
  '%placeholder_for_messages' => 'Placeholder text',
  '%second_placeholder_for_messages' => 'Or link',
  ...,
]
```
## Architecture
### Entities
* adv_audit
* adv_audit_issue

Audit reports are stored in `adv_entity` and `adv_audit_issue` entities (revisionable).

* `adv_audit` entity stores data about audit's results.
* `adv_audit_issue` stores issues data which were created by plugins if some checkpoints returned `failed` status.

Report is run by batch. Also particular checkpoint can be run from it's own settings form.

Issues can be ignored if plugin's failed status is false-positive in a project's context.

Reports can be exported to pdf or Google docs.


### Render reports
Each report is an particular `adv_audit` entity.
`\Drupal\adv_audit\Renderer\AuditReportRenderer` loads data from entity storage and renders them to template.

## Available checkpoints:

### 1. Performance
* Check php max_execution_time setting
* Cron settings
* ImageAPI Optimize
* Javascript & CSS aggregation
* Memcache/Redis settings
* Performance modules status
* Views performance settings
* Page caching performance
* Database usage
* Solr usage
* Memory usage check
* Page speed insights

### 2. Server Configuration
* Release notes & help files
* PHP Version
* Analyze Watchdog Logs.
* Check Opcache

### 3. Security
* Errors are written to the screen.
* PHP register globals
* Trusted Host Settings
* Check if users table contains anonymous user
* Unsafe extensions
* Admin pages access check
* No sensitive temporary files were found.
* Untrusted role's permission
* Security Code Review
* SSL test
* Dangerous Tags
* Check views are access controlled.
* Check Account settings
* PHP files in public directory cannot be executed.
* Anonymous user rights
* Allowed HTML tags in text formats
* Check must-have modules for security reasons
* Administrator's name check

### 4. Drupal core and contributed modules
* No database updates required
* Modules security updates
* Configuration Manager
* Patched Drupal core.
* Drupal core
* Modules non-security updates
* Patched modules.
* Features status

### 5. Architecture analysis
* Check if CI/CD exists on a project
* Check files structure on a project.
* Check if composer is used on a project.

### 6. Code review (custom modules and themes)
* Code audit by CodeSniffer
* Auditing code smells, code complexity. Code metrics and potential problems

### 7. Other recommendations
* Database tables engine check.
* Check environment settings.
* Check Seo recommendations: contrib modules and robots.txt.
* Check Ultimate cron module