mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Use of vars instead of func
This commit is contained in:
parent
c81cff094e
commit
e72b1e5f25
4 changed files with 11 additions and 14 deletions
|
@ -1,5 +1,7 @@
|
||||||
package cwe
|
package cwe
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Acronym is the acronym of CWE
|
// Acronym is the acronym of CWE
|
||||||
Acronym = "CWE"
|
Acronym = "CWE"
|
||||||
|
@ -14,6 +16,11 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// InformationURI link to the published CWE PDF
|
||||||
|
InformationURI = fmt.Sprintf("https://cwe.mitre.org/data/published/cwe_v%s.pdf/", Version)
|
||||||
|
// DownloadURI link to the zipped XML of the CWE list
|
||||||
|
DownloadURI = fmt.Sprintf("https://cwe.mitre.org/data/xml/cwec_v%s.xml.zip", Version)
|
||||||
|
|
||||||
data = map[string]*Weakness{}
|
data = map[string]*Weakness{}
|
||||||
|
|
||||||
weaknesses = []*Weakness{
|
weaknesses = []*Weakness{
|
||||||
|
|
10
cwe/types.go
10
cwe/types.go
|
@ -32,13 +32,3 @@ func (w *Weakness) MarshalJSON() ([]byte, error) {
|
||||||
URL: w.SprintURL(),
|
URL: w.SprintURL(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// InformationURI link to the published CWE PDF
|
|
||||||
func InformationURI() string {
|
|
||||||
return fmt.Sprintf("https://cwe.mitre.org/data/published/cwe_v%s.pdf/", Version)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DownloadURI link to the zipped XML of the CWE list
|
|
||||||
func DownloadURI() string {
|
|
||||||
return fmt.Sprintf("https://cwe.mitre.org/data/xml/cwec_v%s.xml.zip", Version)
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ var _ = Describe("CWE Types", func() {
|
||||||
})
|
})
|
||||||
Context("when consulting cwe types", func() {
|
Context("when consulting cwe types", func() {
|
||||||
It("it should retrieves the information and download URIs", func() {
|
It("it should retrieves the information and download URIs", func() {
|
||||||
Expect(cwe.InformationURI()).To(Equal("https://cwe.mitre.org/data/published/cwe_v4.4.pdf/"))
|
Expect(cwe.InformationURI).To(Equal("https://cwe.mitre.org/data/published/cwe_v4.4.pdf/"))
|
||||||
Expect(cwe.DownloadURI()).To(Equal("https://cwe.mitre.org/data/xml/cwec_v4.4.xml.zip"))
|
Expect(cwe.DownloadURI).To(Equal("https://cwe.mitre.org/data/xml/cwec_v4.4.xml.zip"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("it should retrieves the weakness ID and URL", func() {
|
It("it should retrieves the weakness ID and URL", func() {
|
||||||
|
|
|
@ -104,9 +104,9 @@ func buildSarifReportingDescriptorRelationship(weakness *cwe.Weakness) *Reportin
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildCWETaxonomy(taxa []*ReportingDescriptor) *ToolComponent {
|
func buildCWETaxonomy(taxa []*ReportingDescriptor) *ToolComponent {
|
||||||
return NewToolComponent(cwe.Acronym, cwe.Version, cwe.InformationURI()).
|
return NewToolComponent(cwe.Acronym, cwe.Version, cwe.InformationURI).
|
||||||
WithReleaseDateUtc(cwe.ReleaseDateUtc).
|
WithReleaseDateUtc(cwe.ReleaseDateUtc).
|
||||||
WithDownloadURI(cwe.DownloadURI()).
|
WithDownloadURI(cwe.DownloadURI).
|
||||||
WithOrganization(cwe.Organization).
|
WithOrganization(cwe.Organization).
|
||||||
WithShortDescription(NewMultiformatMessageString(cwe.Description)).
|
WithShortDescription(NewMultiformatMessageString(cwe.Description)).
|
||||||
WithIsComprehensive(true).
|
WithIsComprehensive(true).
|
||||||
|
|
Loading…
Reference in a new issue