Skip to content

Commit

Permalink
Add demo GIF using vhs and make
Browse files Browse the repository at this point in the history
  • Loading branch information
picatz committed Dec 2, 2023
1 parent 92bf165 commit a263374
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cmd/taint/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: install
install:
@go build -o $(shell go env GOPATH)/bin/taint .

.PHONY: vhs
vhs:
@vhs ./vhs/demo.tape
32 changes: 32 additions & 0 deletions cmd/taint/example/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"database/sql"
"net/http"
)

func handle(db *sql.DB, q string) {
db.Query(q) // want "potential sql injection"
}

func business(db *sql.DB, q *string) error {
handle(db, *q)
return nil
}

func main() {
db, _ := sql.Open("sqlite3", ":memory:")

mux := http.NewServeMux()

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
user := r.URL.Query()["query"]
userValue := user[0]
business(db, &userValue)
})

err := http.ListenAndServe(":8080", mux)
if err != nil {
panic(err)
}
}
7 changes: 5 additions & 2 deletions cmd/taint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
styleNumber = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("69"))
styleArgument = lipgloss.NewStyle().Foreground(lipgloss.Color("68"))
styleFlag = lipgloss.NewStyle().Foreground(lipgloss.Color("66"))
styleCommand = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("55"))
styleCommand = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("62"))
)

var (
Expand Down Expand Up @@ -243,7 +243,10 @@ func (c commands) eval(ctx context.Context, bt *bufio.Writer, input string) erro
}
}

return fmt.Errorf("unknown command: %q", cmdName)
bt.WriteString("unknown command: " + cmdName + "\n")
bt.Flush()

return nil
}

var builtinCommandExit = &command{
Expand Down
Binary file added cmd/taint/vhs/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions cmd/taint/vhs/demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Output ./vhs/demo.gif

Set Margin 20
Set MarginFill "#ffffff"
Set BorderRadius 10

Set FontSize 20
Set Width 1200
Set Height 600

Type "taint"

Sleep 500ms

Enter

Sleep 3s

Type "load ./example"

Sleep 500ms

Enter

Sleep 2s

Type "n"

Tab@500ms 2

Sleep 500ms

Enter

Sleep 2s

Type "p"

Tab@500ms 2

Enter

Sleep 5s

Type "cg"

Sleep 1s

Enter

Sleep 5s

Type "callpath (*database/sql.DB).Query"

Sleep 500ms

Enter

Sleep 3s

Type "check *net/http.Request (*database/sql.DB).Query"

Sleep 500ms

Enter

Sleep 5s

Type "ex"

Tab@500ms 2

Enter

Sleep 5s

0 comments on commit a263374

Please sign in to comment.