Skip to content

Instantly share code, notes, and snippets.

View nyrahul's full-sized avatar
🐞

Rahul Jadhav nyrahul

🐞
  • AccuKnox
View GitHub Profile
@nyrahul
nyrahul / tenant-status.py
Last active May 30, 2024 10:18
CSPM get tenant status
-----
# exec into any celery pod
# python3 manage.py shell
# Cut paste below code and execute
# kubectl exec -n accuknox-divy deployments/uwsgi -- python3 manage.py generate_report > report.csv
from django.core.management.base import BaseCommand
from django.db import connection
from django.utils import timezone
from django_tenants.utils import schema_context

Step 1: Create cluster

./create-cluster.sh

Step 2: Install apparmor utilities

# Install apparmor utilites in the kind cluster nodes
docker exec -it cluster01-worker bash -c "apt update && apt install apparmor-utils -y && systemctl restart containerd"
docker exec -it cluster01-control-plane bash -c "apt update && apt install apparmor-utils -y && systemctl restart containerd"
bin/pulsar-admin tenants list
bin/pulsar-admin namespaces list "accuknox"
bin/pulsar-admin topics list "accuknox/cluster"
bin/pulsar-admin topics list "accuknox/datapipeline"
bin/pulsar-admin topics stats "persistent://accuknox/datapipeline/kubearmoralerts" | less
bin/pulsar-admin topics examine-messages --initialPosition latest --messagePosition 1 "persistent://accuknox/datapipeline/kubearmoralerts"
bin/pulsar-admin topics clear-backlog -s "accuknox-data-offloader" "persistent://accuknox/datapipeline/kubearmoralerts"
@nyrahul
nyrahul / nmap-scan.sh
Created June 23, 2023 13:25
Get nmap report for TLS/SSL and convert it to json
nmap -Pn -sT -p 3000 localhost --script ssl-cert --script ssl-enum-ciphers --script ssl-cert -oX t.xml
yq . t.xml -o json --xml-attribute-prefix '' > t.json
| Name | Address | Status | Version | Ciphersuite | Hash | Signature | Verification |
| ------------------------------------------------------------------------------------- | -------------------- | ---------- | ------- | ---------------------------- | ------ | --------- | -------------------------------------------- |
| accuknox-agents/agents-operator[health-check] | 172.20.183.36:9090 | PLAIN_TEXT | | | | | |
| accuknox-agents/agents-operator[spire-agent] | 172.20.183.36:9091 | PLAIN_TEXT | | | | | |
| accuknox-agents/discovery-engine
@nyrahul
nyrahul / dependencies.json
Last active March 6, 2023 05:43
Accuknox microservices dependency map
[
{
"microservice": "cluster-entity-daemon",
"operator": ">=",
"version": "v0.2.0"
},
[
{
"depends_on": "shared-informer-service",
"operator": ">=",
@nyrahul
nyrahul / docker-compose.yaml
Created August 31, 2022 06:13
gitea docker-compose yaml that just works
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.17.1
container_name: gitea
@nyrahul
nyrahul / gist:3ad59a48508fc3ce60a1fa0442c8fbe5
Created May 20, 2022 17:01
cherry pick from remote branch and raise PR
git fetch upstream
git checkout -b v0.3-backport remotes/upstream/v0.3
git cherry-pick <commit-hash> #Note that you should not pick merge hash
git push origin v0.3-backport
# Raise a PR from origin/v0.3-backport to upstream/v0.3
@nyrahul
nyrahul / imp-git-cmds.sh
Last active March 14, 2022 15:28
git commands
# Backporting to a branch by cherry-picking from the upstream/stable branch
git fetch upstream
git checkout upstream/v0.2 # verify if the tip is same as that of the branch you expect by comparing sha hash
git switch -c gke-cos-fix
git cherry-pick e2737efa975198efde13a48435cc994daa3ba018 # substitute with your commit of interest
git push origin gke-cos-fix # push the branch to your origin repo
# Go to github UI and raise PR to the v0.2 branch
# Pull PR locally and test
git fetch upstream pull/37/head:mybranch
@nyrahul
nyrahul / close-fd-problem.c
Last active December 15, 2021 07:52
ebpf syscall close does not give the right fd
//https://stackoverflow.com/questions/70344928/bpf-kprobe-macro-provides-unexpected-value-of-function-argument
// Trying without BPF_KPROBE
SEC("kprobe/__x64_sys_close")
int myclose(struct pt_regs *ctx) {
u32 pid = bpf_get_current_pid_tgid() >> 32;
int fd = PT_REGS_PARM1_CORE(ctx);
// filter specific pid for simplicity
if (pid != SRV_PID) {