Skip to content

Instantly share code, notes, and snippets.

View jonpugh's full-sized avatar

Jon Pugh jonpugh

View GitHub Profile
@jonpugh
jonpugh / apache-SA-CORE-2018-002.conf
Last active April 13, 2018 20:40
Web server configuration to mitigate Drupal SA-CORE-2018-002. Written by trusted sources. Patch your sites!!
# Apache configuration to block attempts to exploit the SA
# If using Aegir, you can put this file in /var/aegir/config/server_master/apache/post.d/SA-CORE-2018-002.conf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)(23value|23default_value|element_parents=%23)(.*) [NC]
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^.*$ - [R=403,L]
</IfModule>
@jonpugh
jonpugh / ABSTRACT.md
Last active January 25, 2018 03:05
DrupalCon Nashville 2018 Session Submission: Host Your Own Drupal with Open Source

Host Your Own Drupal with Open Source

Why Host your Own Drupal? With so many amazing hosting providers available to you, why in the world would anyone want to "self-host" in 2018?

Well, perhaps:

  1. Your organization has already invested in IT. Your data infrastructure and human resources should be put to use!
  2. Your app has special security, technology or location needs that just aren't fulfilled by hosting services.
  3. You want to get the most out of every server and every dollar, with entirely open source software.
@jonpugh
jonpugh / Breadcrumbs.php
Created May 5, 2016 00:28
Add Taxonomy Term to a Node's Breadcrumb in Drupal 8
<?php
// src/Breadcrumbs.php
namespace Drupal\modulename;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Link;
@jonpugh
jonpugh / http_passwords.drush.inc
Created September 24, 2015 15:40
This drush file adds to aegir apache config, when a site is protected by http basic authentication, it grants access to the site's files folder without a password.
<?php
/*
* Implementation of hook_provision_apache_vhost_config()
*/
function http_passwords_provision_apache_vhost_config($uri, $data) {
$lines = array();
$user = d()->http_basic_auth_username;
$pass = d()->http_basic_auth_password;
@jonpugh
jonpugh / access.feature
Last active September 15, 2015 17:01
A big test for access control
Feature: MyEngageNY: Community Content
Background:
Given users:
| name | mail | status | roles |
| group_owner | [email protected] | 1 | local test user |
| non_member | [email protected] | 1 | local test user |
| member_user | [email protected] | 1 | local test user |
| moderator | [email protected] | 1 | local test user |
| contentadmin| [email protected] | 1 | local test user, content administrator |
@jonpugh
jonpugh / gist:33e6220ef1817b7748c1
Created September 14, 2015 21:03
All the drupal extension behat steps: bin/behat -dl
default | Then every link should work
default | Given I am an anonymous user
default | Given I am not logged in
default | Given I am logged in as a user with the :role role(s)
default | Given I am logged in as a user with the :role role(s) and I have the following fields:
default | Given I am logged in as :name
default | Given I am logged in as a user with the :permissions permission(s)
default | Then I should see (the text ):text in the ":rowText" row
default | Given I click :link in the :rowText row
default | Then I (should )see the :link in the :rowText row
@jonpugh
jonpugh / FeatureContext.php
Last active November 21, 2018 14:21
This custom Behat FeatureContext includes a step called "Then every link should work". It checks every visitable link on a page for a 200 code.
<?php
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Drupal\DrupalExtension\Context\DrupalContext;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
@jonpugh
jonpugh / bootstrap.php
Created July 15, 2015 21:45
Custom Behat steps for OG: @given I start a :type community called :title with description :description
<?php
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Behat\Hook\Scope\BeforeStepScope;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception;
@jonpugh
jonpugh / docker-compose.yml
Created May 19, 2015 04:14
Exported docker-compose.yml from Rancher for a working wordpress cluster.
app:
environment:
WORDPRESS_DB_PASSWORD: password
external_links:
1979c1fa-26cd-45a0-91cc-c73812fc94b5: mysql
tty: true
image: wordpress
links:
- database
stdin_open: true
@jonpugh
jonpugh / gist:9a605976f53c1fe741e3
Created January 13, 2015 21:20
bin/behat -dl with drupalextension
default | Then I should get a :code response trying to access :url
default | Given I am an anonymous user
default | Given I am not logged in
default | Given I am logged in as a user with the :role role(s)
default | Given I am logged in as :name
default | Given I am logged in as a user with the :permissions permission(s)
default | Then I should see (the text ):text in the ":rowText" row
default | Given I click :link in the :rowText row
default | Then I (should )see the :link in the :rowText row
default | Given the cache has been cleared