Skip to content

Instantly share code, notes, and snippets.

View davidobrien1985's full-sized avatar

David O'Brien davidobrien1985

View GitHub Profile
@davidobrien1985
davidobrien1985 / BundleConfig.ps1
Created May 12, 2016 20:56
Packer template that's supposed to, but doesn't sysprep.
$EC2SettingsFile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Settings\\BundleConfig.xml"
$xml = [xml](get-content $EC2SettingsFile)
$xmlElement = $xml.get_DocumentElement()
foreach ($element in $xmlElement.Property)
{
if ($element.Name -eq "AutoSysprep")
{
$element.Value="Yes"
}
@davidobrien1985
davidobrien1985 / stored-proc.js
Last active December 22, 2023 10:59
Cosmos DB Stored Procedure to update all documents based on query with a new property called inventoryStatus. Change lines 27 and 37 to create a different property.
function addProperty(continuationToken) {
var response = getContext().getResponse();
var collection = getContext().getCollection();
var updated = 0;
if (continuationToken) { // Parse the token
var token = JSON.parse(continuationToken);
if (!token.queryContinuationToken) {
throw new Error('Bad token format: no continuation');
param (
[bool]$DeleteRoleAssignments = $false
)
if (-not (Get-Module -ListAvailable -Name Az)) {
Write-Output "Installing Az module..."
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
}
Connect-AzAccount
@davidobrien1985
davidobrien1985 / create-argos-azure-spn.ps1
Last active January 17, 2022 02:53
Create an Azure Active Directory App Registration / Service Principal to be used for ARGOS Cloud Security https://argos-security.io
<#
.SYNOPSIS
Create an Azure Active Directory App Registration / Service Principal to be used for ARGOS Cloud Security https://argos-security.io
.DESCRIPTION
This script creates an Azure Active Directory App Registration and an Application Secret that can be used to connect ARGOS Cloud Security to Microsoft Azure in order to scan Azure Subscriptions. The secret has a validity of 12 months.
.NOTES
Best executed in Azure Cloud Shell (https://shell.azure.com) as Cloud Shell is already authenticated to your tenant. User executing this script requires permissions to create an AAD App Registration and permissions to assign IAM Roles to Azure Subscriptions.
@davidobrien1985
davidobrien1985 / test.cs
Created September 11, 2021 06:46
repro
public class InventoryBulkStorage : IInventoryBulkStorage
{
private readonly CosmosContainer _containerId = CosmosContainer.Inventory;
private readonly bool _isBulk = true;
public async Task UpsertBulkAsync(IEnumerable<InventoryResource> resources)
{
var containers = CosmosProvider.Containers
.Where(c => c.ContainerId == _containerId && c.IsBulk == _isBulk)
.ToDictionary(k => k.Region, v => v.Container);
@davidobrien1985
davidobrien1985 / ARGOS-API-example.ps1
Created August 25, 2021 05:57
ARGOS API query example
# Use https://dev.argos-security.io/ for more information about browsing the API
# Go to https://app.argos-security.io/account/security to generate or get your personal API key
$headers = @{"Ocp-Apim-Subscription-Key"="____________________replace_________________"}
$result = Invoke-WebRequest -Headers $headers -Uri https://oapi.argos-security.io/argos-prod-fn/detections | ConvertFrom-Json
$detections = $result.data.detections
$openDetections = $detections | Where-Object -FilterScript {$_.status -eq "open"}
$azureDetections = $detections | Where-Object -FilterScript {$_.cloud -eq "azure"}
@davidobrien1985
davidobrien1985 / azure-sql-deploy.json
Created May 15, 2018 12:45
Azure SQL ARM template
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"administratorLogin": {
"type": "string"
},
"sqlPassword": {
"type": "securestring"
},
@davidobrien1985
davidobrien1985 / policy.json
Last active June 20, 2021 07:31
ARGOS AWS IAM policy document required for ARGOS to successfully scan your AWS Accounts
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeInternetGateways",
"ec2:DescribeNetworkAcls",
"ec2:DescribeNetworkInterfaces",
@davidobrien1985
davidobrien1985 / test-arm-template.ps1
Created September 17, 2020 05:29
Azure ARM template test
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$body = @'
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"projectName": {
"type": "string",
@davidobrien1985
davidobrien1985 / pipeline.yaml
Created February 16, 2020 05:46
azure devops pipeline example build - release
trigger:
branches:
include:
- master
paths:
exclude:
- infra/*
include:
- xirus/*