Skip to content

Instantly share code, notes, and snippets.

View davidobrien1985's full-sized avatar

David O'Brien davidobrien1985

View GitHub Profile
@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 / 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 / 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 / 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