Skip to content

Instantly share code, notes, and snippets.

View wparad's full-sized avatar
🇨🇭
I solve security in SaaS.

Warren Parad wparad

🇨🇭
I solve security in SaaS.
View GitHub Profile
var AWS = require('aws-sdk');
var forwardFrom = '[email protected]';
var forwardTo = '[email protected]';
exports.handler = function(event, context) {
var msgInfo = JSON.parse(event.Records[0].Sns.Message);
// don't process spam messages
if (msgInfo.receipt.spamVerdict.status === 'FAIL' || msgInfo.receipt.virusVerdict.status === 'FAIL') {
console.log('Message is spam or contains virus, ignoring.');
@wparad
wparad / AWS IAM Policy - ForceMFA.json
Created May 1, 2018 08:29 — forked from incyclum/AWS IAM Policy - ForceMFA.json
AWS IAM Policy - Force MFA - This policy allows users to manage their own passwords and MFA devices but nothing else unless they authenticate with MFA -- *EDIT*: I forgot where I found it in the 1st place. In fact this policy is explained statement by statement in AWS docs: https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_users-self-man…
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases",
"iam:ListUsers",
"iam:GetAccountPasswordPolicy",
{ "from": 0,
"size": 100,
"version": true,
"sort": [
{
"_script": {
"order": "desc",
"type": "string",
"script": {
"lang": "painless",
@wparad
wparad / nvidia-fix.sh
Created January 13, 2019 10:38
Fix Nvidia Graphics card drivers
# dpkg: error: version '-' has bad syntax: version string has embedd
sudo apt -o Dpkg::Options::="--force-overwrite" install --fix-broken
sudo ubuntu-drivers autoinstall
#!/usr/bin/env bash
# Assuming the VPN connection name is SeedBox
currentState=`nmcli connection | grep SeedBox | tr -s ' ' | cut -f4 -d' '`
if [ "${currentState}" = "--" ]
then
nmcli connection up SeedBox
else
nmcli connection down SeedBox
@wparad
wparad / terraform.yml
Last active February 13, 2024 15:50
Terraform GithubAction Workflow
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: write
@wparad
wparad / aws_vpn.tf
Last active January 10, 2022 17:27
Terraform VPN creation
locals {
environment = "dev",
vpc = {
vpc_id = "VPC_ID",
private_subnets = ["SUBNET_ID_1"]
}
}
resource "aws_cloudwatch_log_group" "vpn_cloudwatch_log_group" {
name = "/aws/vpn"
@wparad
wparad / index.js
Created November 4, 2020 20:33
Best practices for improving AWS Lambda defaults for the aws-sdk.
require('error-object-polyfill');
const Api = require('openapi-factory');
process.env.AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1;
require('http').globalAgent.keepAlive = true;
require('https').globalAgent.keepAlive = true;
const logger = require('./requestLogger');
try {
const XrayManager = require('./xrayManager');
@wparad
wparad / find-large-files.sh
Created November 4, 2020 20:45
Find large files
du -h . | grep -E '^[^[:space:]]+(M|G)[[:space:]]' | sort -h
@wparad
wparad / .aws-config
Last active November 21, 2020 09:57
Default AWS configuration
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
[default]
region=us-east-1
output=json
cli_binary_format=raw-in-base64-out
cli_auto_prompt = on