Skip to content

Instantly share code, notes, and snippets.

@za
za / trivy-hardcoded-secrets.md
Created November 28, 2023 09:38
Example of Trivy output when scanning for hardcoded secrets

Command:

$ git clone https://github.com/trufflesecurity/node-app-with-canary-token/
$ cd node-app-with-canary-token/
$ docker build -t node-app-with-canary-token .

Then run Trivy with secret scanning enabled:

➜  node-app-with-canary-token git:(main) trivy image --scanners secret node-app-with-canary-token
@za
za / extract_ip_address.py
Last active July 12, 2023 07:45
Extract IP address from a text file
import ipaddress
import re
import sys
def extract_ip_addresses(lines):
ip_addresses = []
for line in lines:
words = line.split()
for word in words:
word = re.sub('"', " ", word)
@za
za / git line history
Created December 15, 2022 07:11
git command to see the history of a specific line
git log master -'L100,+3':'src/main.py'
@za
za / gloggraph.txt
Last active May 25, 2022 04:06
git log graph to see the branches
alias gloggraph="git log --graph --simplify-by-decoration --pretty=format:'%d' --all"
@za
za / history of the deleted file
Created January 21, 2022 03:27
git to show history of deleted file
git log --all --full-history -- <filename>
@za
za / git reset one commit local
Created November 4, 2021 07:35
git reset one commit (local commit)
```
git reset --hard HEAD~1
```
@za
za / git amend
Created October 21, 2021 07:53
update/change your commit message
I was updating a URL in a PR. It was a simple one: replace `http` with `https`.
Then I saw they have a commit message guideline.
So I decided to update the commit message.
```
$ git commit --amend
$ git push -f
```
It will make a new commit and replace the previous commit message.
@za
za / git revert
Last active October 21, 2021 07:51
git revert
git revert is making a new commit by reverting the selected commit
```
$ git revert <$commit-id>
```
it's different with git reset.
Let's say we're trying to fix a bug. We've tried with a few commits. But it still didn't work.
So let's checkout to commit that we want and also push it to git server.
```
$ git reset <$hash-id>
$ git checkout -- . (to cancel any changes)
$ git push -f origin <$branch-name>
```
kwazii