Skip to content

Instantly share code, notes, and snippets.

View gene1wood's full-sized avatar
🎩

Gene Wood gene1wood

🎩
View GitHub Profile
Num Tool Name Executable Name
1 AMS (Amazon Mozilla Services) CLI ams
2 Auth0 for AWS aws-auth0
3 AWS login proxy aws-download-keys
4 AWS Single Sign-On aws_sso
5 AWS SSO CLI aws-sso
6 AWS SSO Login aws_sso_login
7 aws_secure aws_secure
8 aws-fed aws-fed
@gene1wood
gene1wood / How-to-pass-all-headers-in-CloudFront-using-CloudFormation.md
Last active February 8, 2023 20:24
How to configure CloudFront using CloudFormation to pass all headers

How to configure CloudFront using CloudFormation to pass all headers

How can you configure a CloudFront distribution to pass all headers to the origin if the CloudFront distribution is deployed using CloudFormation? If you deploy the distribution in the AWS Web Console, you can select between None, Whitelist and All. In CloudFront it appears that you can only assert a whitelist of allowed headers. This is done in this area of a CloudFormation resource describing a CloudFront distribution

Resources:
  CloudFrontDistribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
@gene1wood
gene1wood / aws-lambda-relative-import-no-known-parent-package.md
Last active June 11, 2024 21:15
Python relative imports in AWS Lambda fail with `attempted relative import with no known parent package`

Python relative imports in AWS Lambda fail with attempted relative import with no known parent package

The Problem

In AWS Lambda if I attempt an explicit relative import like this

.
├── lambda_file.py
└── example.py
@gene1wood
gene1wood / gist:aa1c7fe0ce68b529bd3196018e7f600b
Created September 23, 2019 16:04
Greasemonkey userscript to prevent Jira from capturing the Alt+1 Alt+2 Alt+3 keyboard shortcuts
// ==UserScript==
// @name JIRA: Prevent Alt+[123] hijacking
// @namespace https://github.com/yurikhan/
// @include *RapidBoard.jsp*
// @version 1
// @grant none
// ==/UserScript==
// https://jira.atlassian.com/browse/JSWSERVER-12296?focusedCommentId=957921&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-957921
@gene1wood
gene1wood / new-python-project-with-tox-and-pytest.md
Last active January 17, 2023 05:07
Example of the directory structure, setup.py, tox.ini and pytest tests for a new python project

Directory structure

projectname/                 [1]
├── projectname              [2]
│   ├── __init__.py
├── README.md
├── setup.py
├── tests
│   └── test_projectname.py
@gene1wood
gene1wood / .python-package-and-module-name-stats.md
Last active November 13, 2021 21:09
Statistics on python distribution package names and the names of the modules within those packages
  • All package names are considered lowercase as package names must be case insensitive
  • Packages with names containing no dashes or underscores (which are equivalent)
    • %74.37 (148 / 199)
  • Packages containing a module with the same name as the package
    • %67.84 (135 / 199)
  • Packages with the same package and module name, except dash converted to underscore
  • %13.07 (26 / 199)
@gene1wood
gene1wood / add_support_for_OrderedDict_in_PyYAML.py
Created August 27, 2019 14:48
Add support for OrderedDict to PyYAML to avoid the "RepresenterError: cannot represent an object: OrderedDict" error
from collections import OrderedDict
import sys
import yaml
test1 = {
'beta': 1,
'alpha': 2,
'charlie': 3}
print(yaml.safe_dump(test1, default_flow_style=False))
@gene1wood
gene1wood / scheduler.py.diff
Created August 16, 2019 14:50
Diff between scheduler.py in security_monkey 0.3.6 and moz_security_monkey
--- scheduler-ca556d328280eba6b53df8934a6d63eaf1eb7d86.py 2019-08-16 07:47:49.289601195 -0700
+++ scheduler-bd1b505fef48e69fab6a7e76538bbac8a9149013.py 2019-08-16 07:48:41.593548348 -0700
@@ -1,138 +1,143 @@
"""
-.. module: security_monkey.scheduler
+.. module: moz_security_monkey.scheduler
:platform: Unix
:synopsis: Runs watchers, auditors, or reports on demand or on a schedule
.. version:: $$VERSION$$
@gene1wood
gene1wood / get_policy_documents_for_role.py
Created July 24, 2019 14:53
Function to return all AWS IAM policy documents (inline and managed) for a given IAM role
import boto3
def get_paginated_results(product, action, key, credentials=None, args=None):
args = {} if args is None else args
credentials = {} if credentials is None else credentials
return [y for sublist in [x[key] for x in boto3.client(
product, **credentials).get_paginator(action).paginate(**args)]
for y in sublist]