Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
file restructure and export to a file directly instead of redirecting…
Browse files Browse the repository at this point in the history
… the output
  • Loading branch information
tjgurwara99 committed Feb 5, 2023
1 parent 48297f1 commit 797f937
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/vulnny/main.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
)

func main() {
outFile := flag.String("o", "", "File to export the SARIF log to. If not specified, the log would be printed to the stdout.")
flag.Parse()
log, err := runVulnny()
if err != nil {
Expand All @@ -27,7 +28,16 @@ func main() {
fmt.Fprintf(os.Stderr, "failed to marshal SARIF: %s\n", err.Error())
os.Exit(1)
}
fmt.Println(string(data))
out := os.Stdout
if *outFile != "" {
out, err = os.OpenFile(*outFile, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
defer out.Close()
}
fmt.Fprintln(out, string(data))
}

func runVulnny() (*sarif.Log, error) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 797f937

Please sign in to comment.