Skip to content

Instantly share code, notes, and snippets.

View shazadbrohi's full-sized avatar

Shazad Brohi shazadbrohi

  • VMware
  • Austin, TX
View GitHub Profile
package main
import ("fmt"
"net/http"
"log"
"io/ioutil"
"io"
"sync"
"os"
)
package main
import ("fmt"
"net/http"
)
func main(){
rootHttpHandler := func(writer http.ResponseWriter, request *http.Request) {
fmt.Fprintf(writer, "Request Method: %s\n", request.Method)
fmt.Fprintf(writer, "Request Method: %q\n", request.URL)
$ ./ls
Reading contents of current directory:
Name: ls, Size: 2190488, Last Modified Time: 2021-01-30 16:36:15.436720922 -0600 CST
Name: ls.go, Size: 334, Last Modified Time: 2021-01-30 16:34:42.99726847 -0600 CST
$ ./ls
$ go build ls.go
@shazadbrohi
shazadbrohi / ls.go
Last active January 30, 2021 23:09
ls.go
package main
import (
"fmt"
"io/ioutil"
)
func main(){
fmt.Println("Reading contents of current directory: ")
files, err := ioutil.ReadDir(".")
@shazadbrohi
shazadbrohi / workload-specific-binding.yaml
Last active November 2, 2020 23:41
Grants permission to a specific workload to use the privileged pod security policy.
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: <role-binding-name>
namespace: <your-namespace>
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: privileged-cluster-role
subjects:
@shazadbrohi
shazadbrohi / namespaced-privileged-access.yaml
Created November 2, 2020 23:20
Grants all service accounts in a specific namespace permission to use the privileged pod security policy.
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: <name>-role-binding
namespace: <your-namespace>
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: privileged-cluster-role
subjects:
@shazadbrohi
shazadbrohi / privileged-cluster-role.yaml
Created November 2, 2020 23:14
A cluster role which authorizes use of the privileged-psp.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: privileged-cluster-role
rules:
- apiGroups:
- policy
resourceNames:
- privileged-psp
resources:
@shazadbrohi
shazadbrohi / privileged-psp.yaml
Created November 2, 2020 23:07
A privileged pod security policy resource
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: privileged-psp
spec:
allowPrivilegeEscalation: true
allowedCapabilities:
- '*'
fsGroup:
rule: RunAsAny