From 4e486dae1dbd672717f8313cf96d922b7c2c9dec Mon Sep 17 00:00:00 2001 From: MaineK00n Date: Wed, 22 Feb 2023 15:59:47 +0900 Subject: [PATCH] style: fix typo (#1592) * style: fix typo * style: add comment --- detector/github.go | 1 + models/github.go | 3 +++ models/vulninfos.go | 2 ++ reporter/chatwork.go | 1 + reporter/email.go | 1 + reporter/googlechat.go | 1 + reporter/localfile.go | 1 + reporter/sbom/cyclonedx.go | 1 + reporter/slack.go | 1 + reporter/stdout.go | 1 + reporter/syslog.go | 1 + reporter/telegram.go | 1 + server/server.go | 2 +- 13 files changed, 16 insertions(+), 1 deletion(-) diff --git a/detector/github.go b/detector/github.go index 8267f424..a69afc82 100644 --- a/detector/github.go +++ b/detector/github.go @@ -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 { diff --git a/models/github.go b/models/github.go index a210cd39..bfa27e5a 100644 --- a/models/github.go +++ b/models/github.go @@ -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] == "=" { diff --git a/models/vulninfos.go b/models/vulninfos.go index b6e473e9..b7087561 100644 --- a/models/vulninfos.go +++ b/models/vulninfos.go @@ -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"` diff --git a/reporter/chatwork.go b/reporter/chatwork.go index 4a8af0a8..80ca2d94 100644 --- a/reporter/chatwork.go +++ b/reporter/chatwork.go @@ -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 { diff --git a/reporter/email.go b/reporter/email.go index 61481b53..c149785e 100644 --- a/reporter/email.go +++ b/reporter/email.go @@ -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) diff --git a/reporter/googlechat.go b/reporter/googlechat.go index 2c9fc680..e0525b18 100644 --- a/reporter/googlechat.go +++ b/reporter/googlechat.go @@ -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) diff --git a/reporter/localfile.go b/reporter/localfile.go index 20187081..a6f9656b 100644 --- a/reporter/localfile.go +++ b/reporter/localfile.go @@ -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") diff --git a/reporter/sbom/cyclonedx.go b/reporter/sbom/cyclonedx.go index 8732238e..b3290c9f 100644 --- a/reporter/sbom/cyclonedx.go +++ b/reporter/sbom/cyclonedx.go @@ -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() diff --git a/reporter/slack.go b/reporter/slack.go index f50bb803..0c229f7a 100644 --- a/reporter/slack.go +++ b/reporter/slack.go @@ -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 { diff --git a/reporter/stdout.go b/reporter/stdout.go index 1f4eab88..a9ea47df 100644 --- a/reporter/stdout.go +++ b/reporter/stdout.go @@ -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") diff --git a/reporter/syslog.go b/reporter/syslog.go index bb012bed..8b6e8f47 100644 --- a/reporter/syslog.go +++ b/reporter/syslog.go @@ -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() diff --git a/reporter/telegram.go b/reporter/telegram.go index 6e6d6e10..ec81a5dd 100644 --- a/reporter/telegram.go +++ b/reporter/telegram.go @@ -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", diff --git a/server/server.go b/server/server.go index 0dbe6f69..7078d32a 100644 --- a/server/server.go +++ b/server/server.go @@ -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,