Skip to content

Instantly share code, notes, and snippets.

@northwestcoder
northwestcoder / satori_datadog_v2.py
Created July 5, 2023 11:51
Satori to Datadog v2
import json
import requests
import datetime
import io
#REQUIRED
# Authenticate to Satori for a bearer token
satori_account_id = 'NEED_VALUE'
satori_serviceaccount_id = 'NEED_VALUE'
satori_serviceaccount_key = 'NEED_VALUE'
@northwestcoder
northwestcoder / send_satoriaudit_to_s3.py
Created May 19, 2023 14:20
simple example showing how to pull one day of Satori audit data, create a csv object, and store that as a file in S3 where the date is the S2 path
import json
import requests
import datetime
import io
import boto3
# Satori Authentication
# see https://app.satoricyber.com/docs/api for auth info
satori_serviceaccount_id = "MUST_FILL_IN"
@northwestcoder
northwestcoder / satori_access_on_demand.ipynb
Last active April 24, 2023 13:42
Python example showing creation of various Satori elements to grant access on-demand or JIT access
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@northwestcoder
northwestcoder / getWordCountForFolder.gs
Last active April 14, 2023 18:38
get word count for all google docs in a folder
function countAllWordsAndImagesInFolder(){
var googleDriveFolder = DriveApp.getFolderById("CHANGE_THIS_TO_YOUR_GOOGLE_DRIVE_FOLDER_ID");
var filesIterator = (googleDriveFolder.getFiles());
var file;
var mimetype;
var masterWordCount = 0;
var masterImageCount = 0;
while(filesIterator.hasNext()) //run loop while there is an new available file
@northwestcoder
northwestcoder / gen_fake_sf.py
Last active February 16, 2023 22:41
Generate Snowflake Schema, Tables, Users, Roles and Grants
import random, string
# This script will spit out three sql files in the current working dir:
# create_schema_and_tables.sql
# create_users_and_roles.sql
# drop_everything.sql
##########################################################
@northwestcoder
northwestcoder / postgres_scanner.py
Last active November 21, 2023 17:41
Postgres Table Scanner for Satori
import psycopg2
import time
# select one or more postgres schemas using the following format
TARGET_SCHEMAS = ('public', 'second_schema', 'third_etc')
# how many rows in each select statement
ROWS_TO_PULL = '1200'
# connection info
@northwestcoder
northwestcoder / scan_redshift_tables.py
Last active February 7, 2023 14:31
Redshift Table Scanner for Satori
# pip install redshift_connector
import redshift_connector
import time
# THIS SCRIPT will run queries on all tables in the selected schemas
# This will in turn trigger Satori's Data Inventory features
# select one or more redshift schemas using this format
TARGET_SCHEMAS = ('public', 'another_schema', 'a_third_schema')
# Please read the full documentation for Satori access to AWS S3 here:
# https://satoricyber.com/docs/datastores/s3/
# this example assumes you have already created a Satori Datastore for your AWS S3 access
# pip install boto3 and pandas for this example to work
import os
import boto3
import json
import pandas as pd
@northwestcoder
northwestcoder / generate_terraform.py
Created December 4, 2022 18:15
Python to generate terraform file for loading user information into satoricyber.com
# This script generates a terraform config file specific to
# bulk-loading user information into Satori.
#
# Satori: https://satoricyber.com/docs/directory/directory/
# Terraform: https://registry.terraform.io/providers/SatoriCyber/satori/latest/docs
#BEGIN config
#enter satori account information, url is currently correct for satori platform
my_satori_account = "NEED VALUE"
@northwestcoder
northwestcoder / copy_classifiers.py
Created November 21, 2022 20:20
Example of copying Satori classifiers from Datastore A to Datastore B
import json
import requests
#
# This scripts requires populated Inventory in Satori already.
# There are other scripts to automate inventory population in Satori
# Reminder: Inventory != Classifiers
#
#