Skip to content

Instantly share code, notes, and snippets.

View Zenithar's full-sized avatar

Thibault NORMAND Zenithar

View GitHub Profile
@Zenithar
Zenithar / id.go
Last active May 14, 2019 19:56
How I write microservice (part 2)
package helpers
import (
"github.com/dchest/uniuri"
validation "github.com/go-ozzo/ozzo-validation"
"github.com/go-ozzo/ozzo-validation/is"
)
// IDGeneratedLength defines the length of the id string
const IDGeneratedLength = 32

How I write micro-services?

During my software developer experience, I have seen many bad practices as a code reviewer and collected a lot of tips to try to build better products. I want to focus on a specific part in order to prepare a enhanced Golang project template merging all these tips and practices.

What is a micro-service (again)?

My own personal definition

A micro-service is an internal autonomous observable immutable scalable self-contained unit of deployment of a non-monolithic style architecture. Each micro-service is responsible partially or completely of a part of a business problem, orchestrated and exposed by a Service Gateway.

Keybase proof

I hereby claim:

  • I am zenithar on github.
  • I am zenithar (https://keybase.io/zenithar) on keybase.
  • I have a public key ASDG9_2x78P6oupRsFw-miA9LKc1urQGyVAv2jq1FMj_Ggo

To claim this, I am signing this object:

package pbkdf1_ms
import (
"crypto/sha1"
"strconv"
)
// Key implements C# PasswordDeriveBytes
func Key(password, salt []byte, iterations int, dkLen int) []byte {
@Zenithar
Zenithar / Dockerfile
Last active January 9, 2018 16:39
Meltdown PoC in an Alpine Docker
# - BUILD ----------------------------------------------------------------------
FROM alpine:latest
RUN apk add --update gcc musl-dev wget ca-certificates \
&& wget https://raw.githubusercontent.com/gkaindl/meltdown-poc/master/meltdown.c \
&& cc -O0 meltdown.c -o meltdown
# - RUNTIME --------------------------------------------------------------------
FROM alpine:latest

Keybase proof

I hereby claim:

  • I am zenithar on github.
  • I am zenithar (https://keybase.io/zenithar) on keybase.
  • I have a public key whose fingerprint is 09BB F8C5 EBC5 26AB D528 CBA1 2A02 A167 5AEB 30CD

To claim this, I am signing this object:

WannaCry|WannaDecrypt0r NSA-Cyberweapon-Powered Ransomware Worm

  • Virus Name: WannaCrypt, WannaCry, WanaCrypt0r, WCrypt, WCRY
  • Vector: All Windows versions before Windows 10 are vulnerable if not patched for MS-17-010. It uses EternalBlue MS17-010 to propagate.
  • Ransom: between $300 to $600. There is code to 'rm' (delete) files in the virus. Seems to reset if the virus crashes.
  • Backdooring: The worm loops through every RDP session on a system to run the ransomware as that user. It also installs the DOUBLEPULSAR backdoor. It corrupts shadow volumes to make recovery harder. (source: malwarebytes)
  • Kill switch: If the website www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com is up the virus exits instead of infecting the host. (source: malwarebytes). This domain has been sinkholed, stopping the spread of the worm. Will not work if proxied (source).

update: A minor variant of the viru

@Zenithar
Zenithar / mastodon.yml
Created April 10, 2017 09:52
OpenAPI / Swagger Mastodon API Specification
swagger: '2.0'
info:
title: Mastodon API
description: API for GNU Social-compatible microblogging server
version: '1.1.1'
contact:
name: Mastodon API Team
url: https://github.com/tootsuite/mastodon
license:
name: AGPL
@Zenithar
Zenithar / threelist.go
Created January 30, 2017 21:41
Three lists comparator
package threelist
// Compare two lists old vs new using fullset
func Compare(fullset, old, new []string) ([]string, []string, []string) {
// Initialize empty result lists
keep := []string{}
removed := []string{}
added := []string{}
// For each element of fullset
@Zenithar
Zenithar / lua_boring_ssl.patch
Last active May 18, 2017 15:07
LUA Nginx Module Boring SSL Patch
diff --git a/src/ngx_http_lua_socket_tcp.c b/src/ngx_http_lua_socket_tcp.c
index 6db6e2d..cdad556 100644
--- a/src/ngx_http_lua_socket_tcp.c
+++ b/src/ngx_http_lua_socket_tcp.c
@@ -1327,7 +1327,7 @@ ngx_http_lua_socket_tcp_sslhandshake(lua_State *L)
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
- if (SSL_set_tlsext_host_name(c->ssl->connection, name.data)
+ if (SSL_set_tlsext_host_name(c->ssl->connection, (const char*)name.data)