Skip to content

Instantly share code, notes, and snippets.

View davidobrien1985's full-sized avatar

David O'Brien davidobrien1985

View GitHub Profile
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 / 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');
@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 / 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/*
@davidobrien1985
davidobrien1985 / arm-afd-storage.json
Last active February 9, 2020 04:56
ARM template to deploy Azure Front Door and maintenance rules
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"frontDoorName": {
"defaultValue": "davidobrien",
"type": "string"
},
"storageAccountName": {
"defaultValue": "davidobrienmaintenance",
@davidobrien1985
davidobrien1985 / main.go
Last active May 26, 2019 11:14
requires passing in of "user" parameter, example: `go run main.go -user=davidobrien1985`
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
)