@@ -298,6 +298,7 @@ func fetchDependencyGraph(r *models.ScanResult, httpClient *http.Client, owner,
|
||||
return nil
|
||||
}
|
||||
|
||||
// DependencyGraph is a GitHub API response
|
||||
type DependencyGraph struct {
|
||||
Data struct {
|
||||
Repository struct {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
// key: BlobPath
|
||||
type DependencyGraphManifests map[string]DependencyGraphManifest
|
||||
|
||||
// DependencyGraphManifest has filename, repository, dependencies
|
||||
type DependencyGraphManifest struct {
|
||||
BlobPath string `json:"blobPath"`
|
||||
Filename string `json:"filename"`
|
||||
@@ -76,6 +77,7 @@ func (m DependencyGraphManifest) Ecosystem() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Dependency has dependency package information
|
||||
type Dependency struct {
|
||||
PackageName string `json:"packageName"`
|
||||
PackageManager string `json:"packageManager"`
|
||||
@@ -83,6 +85,7 @@ type Dependency struct {
|
||||
Requirements string `json:"requirements"`
|
||||
}
|
||||
|
||||
// Version returns version
|
||||
func (d Dependency) Version() string {
|
||||
s := strings.Split(d.Requirements, " ")
|
||||
if len(s) == 2 && s[0] == "=" {
|
||||
|
||||
@@ -310,6 +310,7 @@ type GitHubSecurityAlert struct {
|
||||
DismissReason string `json:"dismissReason"`
|
||||
}
|
||||
|
||||
// RepoURLPackageName returns a string connecting the repository and package name
|
||||
func (a GitHubSecurityAlert) RepoURLPackageName() string {
|
||||
return fmt.Sprintf("%s %s", a.Repository, a.Package.Name)
|
||||
}
|
||||
@@ -319,6 +320,7 @@ func (a GitHubSecurityAlert) RepoURLManifestPath() string {
|
||||
return fmt.Sprintf("%s/%s", a.Repository, a.Package.ManifestPath)
|
||||
}
|
||||
|
||||
// GSAVulnerablePackage has vulnerable package information
|
||||
type GSAVulnerablePackage struct {
|
||||
Name string `json:"name"`
|
||||
Ecosystem string `json:"ecosystem"`
|
||||
|
||||
@@ -20,6 +20,7 @@ type ChatWorkWriter struct {
|
||||
Proxy string
|
||||
}
|
||||
|
||||
// Write results to ChatWork
|
||||
func (w ChatWorkWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
|
||||
for _, r := range rs {
|
||||
|
||||
@@ -23,6 +23,7 @@ type EMailWriter struct {
|
||||
Cnf config.SMTPConf
|
||||
}
|
||||
|
||||
// Write results to Email
|
||||
func (w EMailWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
var message string
|
||||
sender := NewEMailSender(w.Cnf)
|
||||
|
||||
@@ -21,6 +21,7 @@ type GoogleChatWriter struct {
|
||||
Proxy string
|
||||
}
|
||||
|
||||
// Write results to Google Chat
|
||||
func (w GoogleChatWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
re := regexp.MustCompile(w.Cnf.ServerNameRegexp)
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ type LocalFileWriter struct {
|
||||
Gzip bool
|
||||
}
|
||||
|
||||
// Write results to Local File
|
||||
func (w LocalFileWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
if w.FormatOneLineText {
|
||||
path := filepath.Join(w.CurrentDir, "summary.txt")
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/future-architect/vuls/models"
|
||||
)
|
||||
|
||||
// GenerateCycloneDX generates a string in CycloneDX format
|
||||
func GenerateCycloneDX(format cdx.BOMFileFormat, r models.ScanResult) ([]byte, error) {
|
||||
bom := cdx.NewBOM()
|
||||
bom.SerialNumber = uuid.New().URN()
|
||||
|
||||
@@ -33,6 +33,7 @@ type message struct {
|
||||
Attachments []slack.Attachment `json:"attachments"`
|
||||
}
|
||||
|
||||
// Write results to Slack
|
||||
func (w SlackWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
|
||||
for _, r := range rs {
|
||||
|
||||
@@ -23,6 +23,7 @@ func (w StdoutWriter) WriteScanSummary(rs ...models.ScanResult) {
|
||||
fmt.Printf("%s\n", formatScanSummary(rs...))
|
||||
}
|
||||
|
||||
// Write results to stdout
|
||||
func (w StdoutWriter) Write(rs ...models.ScanResult) error {
|
||||
if w.FormatOneLineText {
|
||||
fmt.Print("\n\n")
|
||||
|
||||
@@ -16,6 +16,7 @@ type SyslogWriter struct {
|
||||
Cnf config.SyslogConf
|
||||
}
|
||||
|
||||
// Write results to syslog
|
||||
func (w SyslogWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
facility, _ := w.Cnf.GetFacility()
|
||||
severity, _ := w.Cnf.GetSeverity()
|
||||
|
||||
@@ -21,6 +21,7 @@ type TelegramWriter struct {
|
||||
Proxy string
|
||||
}
|
||||
|
||||
// Write results to Telegram
|
||||
func (w TelegramWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
for _, r := range rs {
|
||||
msgs := []string{fmt.Sprintf("*%s*\n%s\n%s\n%s",
|
||||
|
||||
@@ -129,7 +129,7 @@ func (h VulsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// sever subcmd doesn't have diff option
|
||||
// server subcmd doesn't have diff option
|
||||
reports = append(reports, reporter.LocalFileWriter{
|
||||
CurrentDir: dir,
|
||||
FormatJSON: true,
|
||||
|
||||
Reference in New Issue
Block a user