Skip to content

Instantly share code, notes, and snippets.

@prabhu
prabhu / bom.xslt
Created June 4, 2020 02:04
XSLT to transform CycloneDX SBoM xml to Markdown
<xsl:stylesheet version="1.0" xmlns:bom="http://cyclonedx.org/schema/bom/1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:text>## Project dependencies</xsl:text>
<xsl:text>&#xa;&#xa;</xsl:text>
<xsl:text>| Vendor | Name | Version | License Id | </xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>| -------|------|---------|------------|</xsl:text>
<xsl:text>&#xa;</xsl:text>
@prabhu
prabhu / inspect.sh
Last active June 3, 2020 17:56
Wrapper for ShiftLeft Inspect cli that just works
#!/bin/sh
# This script invokes Shiftleft Inspect on the current directory
{ # Prevent execution if this script was only partially downloaded
check_app_dir() {
if [ "$(pwd)" == "$HOME" ]; then
echo Please run this command from within the application directory and not from your HOME directory
exit 1
fi
}
download() {
@prabhu
prabhu / summary.py
Created May 30, 2020 19:28
Script to summarize all ShiftLeft Scan SAST reports
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from pathlib import Path
import json
# pip install jinja2
from jinja2 import Template
@prabhu
prabhu / org-scan.sh
Created May 30, 2020 19:20
Script to clone multiple repos from github and invoke ShiftLeft Scan
#!/usr/bin/env bash
# Script to clone repos from github and invoke ShiftLeft Scan
# You should have added your ssh public key to GitHub and have read access
# Create a PAT token for GitHub and store it as GITHUB_TOKEN env variable
CURR_DIR=$(pwd)
mkdir -p reports_dir
mkdir -p work_dir && cd work_dir
# Get the latest scan image
docker pull shiftleft/scan
@prabhu
prabhu / gist:509d048561db92195600
Created February 5, 2015 11:32
Iptables rule for mosh
# Mosh uses udp range 60000 - 61000. Just allow 60000 alone for added security
-A INPUT -p udp -m multiport --dports 60000:61000 -j ACCEPT
@prabhu
prabhu / gist:cbb786d01a85d6924cc8
Created January 27, 2015 19:56
Resume zsh for mac terminal (Tested on Yosemite)
# Originally found on - http://earthwithsun.com/questions/313650/resume-zsh-terminal-os-x-lion
# Tell the terminal about the working directory whenever it changes.
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL, including
# the host name to disambiguate local vs. remote paths.
# Percent-encode the pathname.
local URL_PATH=''
@prabhu
prabhu / Snippets
Last active January 31, 2021 23:08
A good browser detection logic
function detectBrowser(userAgent, language) {
var version, webkitVersion, iOSAgent, iOSDevice, iOSMajorVersion, iOSMinorVersion, browser = {};
userAgent = (userAgent || navigator.userAgent).toLowerCase();
language = language || navigator.language || navigator.browserLanguage;
version = browser.version = (userAgent.match(/.*(?:rv|chrome|webkit|opera|ie)[\/: ](.+?)([ \);]|$)/) || [])[1];
webkitVersion = (userAgent.match(/webkit\/(.+?) /) || [])[1];
iOSAgent = (userAgent.match(/\b(iPad|iPhone|iPod)\b.*\bOS (\d)_(\d)/i) || []);
iOSDevice = iOSAgent[1];
iOSMajorVersion = iOSAgent[2];
iOSMinorVersion = iOSAgent[3];