Skip to content

Instantly share code, notes, and snippets.

View heavypackets's full-sized avatar

Sabree Blackmon heavypackets

View GitHub Profile
use partial_application::partial;
enum Ops {
Add, Sub, Div, Mult
}
fn calc(op: Ops, x: i32, y: i32) -> i32 {
match op {
Ops::Add => x + y,
Ops::Sub => x - y,
@heavypackets
heavypackets / partial_application.rs
Last active June 30, 2020 05:44
Partial application fun in Rust
#[macro_use]
extern crate partial_application;
enum Ops {
Add, Sub, Div, Mult
}
fn calc(op: Ops, x: i32, y: i32) -> i32 {
match op {
Ops::Add => x + y,
@heavypackets
heavypackets / spire-deployment.yml
Last active October 17, 2018 16:10
spire-server K8 configuration
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: spire-server
namespace: spire
labels:
app: spire-server
spec:
selector:
@heavypackets
heavypackets / envoy.yaml
Created October 10, 2018 06:06
Simple Secretes: Prometheus Envoy
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 10000 }
...
clusters:
- name: secrets-metrics
...
tls_context:
#!/bin/bash
# PLEASE DON'T DO THIS
set -x
for addr in $(nmap -n -sL 192.168.1.0/24 | grep "Nmap scan report" | awk '{print $NF}')
do
curl -G --connect-timeout 1 http://${addr}/metrics > ${addr}
done
@heavypackets
heavypackets / envoy.yaml
Created October 10, 2018 03:03
simple-secrets_fluentd-envoy
static_resources:
listeners:
- name: fluentd
address:
socket_address: { address: 0.0.0.0, port_value: 24224 }
filter_chains:
- filters:
- name: envoy.tcp_proxy
config:
stat_prefix: ingress_tcp
@heavypackets
heavypackets / envoy.yaml
Last active October 10, 2018 02:44
simple-secretes_server-envoy-snippet
static_resources:
listeners:
- name: fluentd
address:
socket_address: { address: 127.0.0.1, port_value: 24224 }
filter_chains:
- filters:
- name: envoy.tcp_proxy
config:
stat_prefix: ingress_tcp
@heavypackets
heavypackets / audits.rs
Last active October 10, 2018 02:34
simple-secretes_audit_examples
// Check password
if !verify_password(&user_info) {
audit_event(
ServerEvents::LoginFailureInvalidPassword,
&format!(
"Login failure for user {} due to invalid password",
user_info.username
),
);
unsuccessful_login_counter.inc();
@heavypackets
heavypackets / envoy.yaml
Created October 10, 2018 01:47
simple-secrets_server-envoy
- name: simple-secrets-metrics
address:
socket_address: { address: 0.0.0.0, port_value: 10000 }
...
tls_context:
common_tls_context:
tls_params:
ecdh_curves: "X25519:P-256:P-521:P-384"
tls_certificates:
certificate_chain: { "filename": "/certs/svid.pem" }
fn main() {
...
let mut metrics_router = Router::new();
metrics_router.get("/metrics", metrics, "get_metrics");
let _metrics = Iron::new(metrics_router).http("127.0.0.1:3001");
audit_event(
ServerEvents::Start,
&format!("New instance of secret-server started: {}", *SPIFFE_ID),
);