A helper script to generate the client assertion required to authenticate to an Authorization Server that supports private_key_jwt, on the command-line with Ruby.
Recommended read:
Is `sudo` almost useless? - Information Security Stack Exchange
https://security.stackexchange.com/questions/232924/is-sudo-almost-useless
Recommended read:
How to convert a SVG to a PNG with ImageMagick? - Stack Overflow
https://stackoverflow.com/questions/9853325/how-to-convert-a-svg-to-a-png-with-imagemagick#14174624
Recommended read:
jq - my new favorite tool to work with json on the command line
https://200ok.ch/posts/jq-my-new-favorite-tool-to-work-with-json-on-the-command-line.html
I used to write a lot of shell scripts before realising that what I was trying to do was treat shell scripting as a "full" scripting language (I won't define here what I mean by "full").
Its not - reach for a higher level scripting language like Ruby or Python when things are getting more complicated, and allow shell scripts to glue things together, or be for quick tasks maybe a few lines long.
When you do write them, this advice is great but it's definitely worth gaining understanding of when you should and shouldn't use them.
Recommended read:
Anybody can write good bash (with a little effort)
https://blog.yossarian.net/2020/01/23/Anybody-can-write-good-bash-with-a-little-effort
This is a great resource to highlight the difficulty of creating temporary files safely - something I've tried to share before but without these great examples.
Its especially bad if using a shared CI/CD server and putting downloaded files into /tmp as you don't know whether it'll be clobbered / stolen by others on the instance
Recommended read:
Safely Creating And Using Temporary Files
https://www.netmeister.org/blog/mktemp.html
This is a great article about how to be safer when writing shell scripts. I am a huge proponent of not using them where possible, and instead moving them to another scripting language (Ruby, Python, Node) which you can test, and use a shared standard library.
Recommended read:
Use the Unofficial Bash Strict Mode (Unless You Looove Debugging)
http://redsymbol.net/articles/unofficial-bash-strict-mode/
This is a great post - I thoroughly recommend learning how to use common commandline tools such as awk, grep, sed, but also adopting a scripting language for more complicated stuff. I don't mean Bash, or another shell scripting language, but something like Node, Python or Ruby, as it'll give you the opportunity for a greater standard library, as well as tonnes of packages built by others.
Recommended read:
Learn a little jq, awk and sed
https://letterstoanewdeveloper.com/2019/07/29/learn-a-little-jq-awk-and-sed/
In every programming language, there is a linting tool that can help pick up on some common style issues. ShellCheck isn't one of those - it's so much more!
I've been using it for many years now, and since it came into my life it's honestly changed the way I use shell scripts. There have been so many pitfalls that I've avoided falling into since learning about them (and adding ShellCheck to my Vim linting setup.
This is a great read from Vidar, the ShellCheck author, about a case where it could've caught issues that caused the deletion of a production database!
How to easily introspect and pretty print a signed JWT (JWS) or an encrypted JWT (JWE) on the command line using Ruby's standard library, or using the ruby-jwt external library.