Skip to content

Instantly share code, notes, and snippets.

@afghanistanyn
afghanistanyn / trivy_scan.go
Last active October 24, 2023 08:22
Integrate trivy into your application
package service
import (
"context"
"errors"
"fmt"
"github.com/aquasecurity/trivy-db/pkg/db"
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"github.com/aquasecurity/trivy/pkg/commands/operation"
"github.com/aquasecurity/trivy/pkg/javadb"
import os
import select
import pty
# websocket input
websocket_input_file = open("websocket_input.txt")
def read_mysql_terminal(fd):
while True:
(readable, _, _) = select.select([fd], [], [], 0)
@afghanistanyn
afghanistanyn / audit.rules
Created May 20, 2019 03:04 — forked from Neo23x0/audit.rules
Linux Auditd Best Practice Configuration
# IMPORTANT!
# This gist has been transformed into a github repo
# You can find the most recent version there:
# https://github.com/Neo23x0/auditd
# ___ ___ __ __
# / | __ ______/ (_) /_____/ /
# / /| |/ / / / __ / / __/ __ /
# / ___ / /_/ / /_/ / / /_/ /_/ /
# /_/ |_\__,_/\__,_/_/\__/\__,_/
@afghanistanyn
afghanistanyn / gist:d6b82d61ce3cc590184e3fc1e6cd0f24
Created December 17, 2018 16:30 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@afghanistanyn
afghanistanyn / jenkins_get_job_git_url.py
Last active September 13, 2018 18:51
jenkins_get_job_git_url
from jenkinsapi.jenkins import Jenkins
import re
# work for jenkins pipeline job (local jenkins_file not scm script_file)
if __name__ == '__main__':
server = Jenkins('http://192.168.0.8', "admin", "jenkins",timeout=30)
job = server.get_job('test')
print job.baseurl
@afghanistanyn
afghanistanyn / AprConfiguration.java
Created January 18, 2018 09:37 — forked from andreldm/AprConfiguration.java
APR on Spring Boot
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.AprLifecycleListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* NOTE: You also need to install APR on your system, on Arch Linux the package is called `tomcat-native`.

MicroService Proxy Gateway Solutions

Kong, Traefik, Caddy, Linkerd, Fabio, Vulcand, and Netflix Zuul seem to the most common in microservice proxy/gateway solutions. Kubernetes Ingress is often a simple Ngnix, which is difficult to seperate the popularity from other things.

Github Star Trend:

Github Star History for Kong vs traefik vs fabio vs caddy vs Zuul

This is just a picture of this link from July 13, 2017

Service Mesh vs Reverse Proxy

@afghanistanyn
afghanistanyn / install-openresty.sh
Created January 9, 2018 03:18
Lua HMAC authentication
$ brew tap killercup/homebrew-openresty
$ brew install ngx_openresty
#!/bin/bash
set -e
JAVA_HOME=${1-text}
[ $# -eq 0 ] && { echo "Usage: sudo $0 \$(/usr/libexec/java_home -v '1.8*')" ; exit 1; }
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
wget https://letsencrypt.org/certs/letsencryptauthorityx1.der
wget https://letsencrypt.org/certs/letsencryptauthorityx2.der
@afghanistanyn
afghanistanyn / daemon.py
Created May 9, 2016 09:48 — forked from jamiesun/daemon.py
一个python守护进程的例子
#! /usr/bin/env python2.7
#encoding:utf-8
#@description:一个python守护进程的例子
#@tags:python,daemon
import sys
import os
import time
import atexit
from signal import SIGTERM