Skip to content

Instantly share code, notes, and snippets.

View Aupajo's full-sized avatar

Pete Nicholls Aupajo

  • Christchurch, New Zealand
View GitHub Profile
@Aupajo
Aupajo / jose-generate-key-export-jwk-sign-decode.js
Last active October 13, 2023 01:44
Using Jose to generate a secret, JWKS, sign a JWT, and verify (useful for testing)
import * as jose from "jose";
const ONE_HOUR_FROM_NOW = Math.floor(Date.now() / 1000) + 60 * 60;
// Mock this, for example
const jwt = {
// Standard claims
sub: "https://login.salesforce.com/id/00Dxx0000001gPLEAY/005xx000001Sw9AAAS",
iss: "urn:example:issuer",
aud: "urn:example:audience",
@Aupajo
Aupajo / georgia.js
Last active November 5, 2020 22:10
Georgia Bitbar
#!/usr/bin/env node
const fetch = require('node-fetch')
function formattedCount(number) {
return number.toLocaleString()
}
async function start() {
const url = 'https://www.huffpost.com/elections/president.json'
@Aupajo
Aupajo / verify-ssl.rb
Created February 3, 2020 02:17
SSL verification in Ruby
# Usage: ruby verify-ssl.rb domain1.com domain2.com domain3.com
require 'socket'
require 'openssl'
SSL_PORT = 443
def verify(domain, cert_store)
puts "---"
puts "Domain: #{domain}"
require 'digest/md5'
# This demonstrates an approach you can use to deterministically generate fake
# data based on user data to anonymize it.
# An array of substitute names read from a file
substitute_names = File.read('names.txt').split("\n")
# Real customer data, e.g., from a database
real_name = "John Realname"
require 'digest/md5'
# This demonstrates an approach you can use to deterministically generate fake
# data based on user data to anonymize it.
# An array of substitute names read from a file
substitute_names = File.read('names.txt').split("\n")
# Real customer data, e.g., from a database
real_name = "John Realname"
@Aupajo
Aupajo / 32bitapps.rb
Last active October 12, 2019 22:58
Find out which 32-bit apps won't make the leap to Catalina
#!/usr/bin/env ruby
begin
require 'plist'
rescue LoadError
abort "Missing dependency. Please run: `gem install plist` and try again."
end
raw_output = `system_profiler SPApplicationsDataType -xml -detailLevel mini`

3.1 ACCESS CONTROL

Basic Security Requirements

3.1.1 Limit system access to authorized users, processes acting on behalf of authorized users, and devices (including other systems).

3.1.2 Limit system access to the types of transactions and functions that authorized users are permitted to execute.

Derived Security Requirements

@Aupajo
Aupajo / pre-commit
Created February 14, 2018 03:02
Check for `.only` in a Git pre-commit hook. Gives you the option to show the diffs and continue with the commit.
#!/bin/bash
match_pattern=".only"
file_pattern="*.js"
# Exit if any command fails
set -e
function matching_diff {
git diff --staged -G "$match_pattern" $@ -- $file_pattern
@Aupajo
Aupajo / app.js
Last active January 24, 2018 01:17
Continuations in Node
const { createNamespace } = require('continuation-local-storage')
const createUUID = require('uuid/v1')
// Application
const logger = require('./logger')
const performSomeProcessing = require('./processing')
// Establish a new storage area for the continuation
const context = createNamespace('context')
require 'thread'
def thing_yielder(&block)
things = %i( a b c )
yieldings = Queue.new
threads = things.map do |thing|
Thread.new do
sleep rand(1..3) # Simulate work
yieldings << thing