-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SRE-59 ensure dev modulesare not enabled
- Loading branch information
benellefimostfa
committed
Oct 9, 2020
1 parent
b59cb87
commit 9d92a24
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |