-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Allowing better configuration for the action (#3)
* 📌 Pinning feature branch for integration test * ✨ Back to composite with build args * 🚚 Backed up old action.yml * 🐛 Corrected Image Name * 🐛 Forgot parameter * Test * 🚚 Moved old action definition as backup * 🐛 Fixed Bug where Action is not build correctly * 📝 Updated docs to reflect new inputs * ➕ Added zerolog * ✨ Introduced Logging via zerolog * ✨ Implemented Call Chain Lookup * 🔧 Making docker build less verbose
- Loading branch information
Showing
14 changed files
with
287 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: "Golang Vulncheck" | ||
description: "Performs vulnerability scan using govulncheck and afterwards uploads it as Sarif Report to Github" | ||
author: "Templum" | ||
inputs: | ||
package: | ||
description: "The package you want to scan, by default will be ./..." | ||
required: false | ||
default: "./..." | ||
github-token: | ||
description: "Github App token to upload sarif report. Needs write permissions for security_events. By default it will use 'github.token' value" | ||
default: ${{ github.token }} | ||
required: true | ||
|
||
runs: | ||
using: "docker" | ||
image: "Dockerfile" | ||
env: | ||
GITHUB_TOKEN: "${{ inputs.github-token }}" | ||
PACKAGE: "${{ inputs.package }}" | ||
|
||
branding: | ||
icon: "alert-octagon" | ||
color: "red" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
|
||
"github.com/Templum/govulncheck-action/pkg/github" | ||
"github.com/Templum/govulncheck-action/pkg/sarif" | ||
"github.com/Templum/govulncheck-action/pkg/vulncheck" | ||
"github.com/rs/zerolog" | ||
) | ||
|
||
func main() { | ||
scanner := vulncheck.NewScanner() | ||
zerolog.SetGlobalLevel(zerolog.InfoLevel) | ||
|
||
if os.Getenv("LOCAL") == "true" { | ||
scanner = vulncheck.NewLocalScanner() | ||
logger := zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: zerolog.TimeFormatUnix}). | ||
With(). | ||
Timestamp(). | ||
Logger() // Main Logger | ||
|
||
reporter := sarif.NewSarifReporter(logger) | ||
github := github.NewSarifUploader(logger) | ||
scanner := vulncheck.NewScanner(logger) | ||
|
||
if os.Getenv("DEBUG") == "true" { | ||
zerolog.SetGlobalLevel(zerolog.DebugLevel) | ||
logger.Debug().Msg("Running in Debug-Mode will use hardcoded scan result and enable debug logs") | ||
|
||
scanner = vulncheck.NewLocalScanner(logger, "/workspaces/govulncheck-action/hack/output.json") | ||
} | ||
|
||
reporter := sarif.NewSarifReporter() | ||
converter := vulncheck.NewVulncheckConverter(reporter) | ||
github := github.NewSarifUploader() | ||
logger.Info(). | ||
Str("Go-Version", runtime.Version()). | ||
Str("Go-Os", runtime.GOOS). | ||
Str("Go-Arch", runtime.GOARCH). | ||
Msg("GoEnvironment Details:") | ||
|
||
result, err := scanner.Scan() | ||
if err != nil { | ||
fmt.Printf("%v \n", err) // TODO: Start using proper logger | ||
logger.Error().Err(err).Msg("Scanning yielded error") | ||
os.Exit(2) | ||
} | ||
|
||
err = converter.Convert(result) | ||
err = reporter.Convert(result) | ||
if err != nil { | ||
fmt.Printf("%v \n", err) // TODO: Start using proper logger | ||
logger.Error().Err(err).Msg("Conversion of Scan yielded error") | ||
os.Exit(2) | ||
} | ||
|
||
err = github.UploadReport(reporter) | ||
if err != nil { | ||
fmt.Printf("%v \n", err) // TODO: Start using proper logger | ||
logger.Error().Err(err).Msg("Upload of Sarif Report GitHub yielded error") | ||
os.Exit(2) | ||
} | ||
|
||
fmt.Println("Successfully processed uploaded vulncheck report to Github") | ||
logger.Info().Msg("Successfully uploaded Sarif Report to Github, it will be available after processing") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.