Skip to content

Commit

Permalink
SRE-59 ensure dev modulesare not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
benellefimostfa committed Oct 9, 2020
1 parent b59cb87 commit 9d92a24
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Policies/DevModulesEnabled.policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: "Dev Modules enabled"
name: algm:DevModulesEnabled
class: \Drutiny\algm\Audit\DevModulesEnabled
tags:
- Dev
description: |
Making sure no dev modules are enabled on prod.
success: |
Success: No dev modules enabled.
failure: |
Warning: There are some dev modules enabled: {{ modules }}, please check they are not enabled in production mode.
39 changes: 39 additions & 0 deletions src/Audit/DevModulesEnabled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php


namespace Drutiny\algm\Audit;

use Drutiny\Audit;
use Drutiny\Sandbox\Sandbox;


class DevModulesEnabled extends Audit {

public function audit(Sandbox $sandbox) {
$dev_modules = [
'browser_refresh',
'coffee',
'devel',
'hacked',
'kint',
'link_css',
'rules_ui',
'stage_file_proxy',
'reroute_email',
];

$info = array_keys($sandbox->drush([
'format' => 'json',
'status' => 'Enabled',
'type' => 'Module',
])->pmList());

if (empty(array_intersect($info, $dev_modules))) {
return TRUE;
}

$sandbox->setParameter('modules', implode(",", (array_intersect($info, $dev_modules))));
return FALSE;
}

}

0 comments on commit 9d92a24

Please sign in to comment.