Skip to content

Commit

Permalink
Use of vars instead of func
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorel-35 committed Jun 13, 2021
1 parent c81cff0 commit e72b1e5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
7 changes: 7 additions & 0 deletions cwe/data.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cwe

import "fmt"

const (
// Acronym is the acronym of CWE
Acronym = "CWE"
Expand All @@ -14,6 +16,11 @@ const (
)

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{}

weaknesses = []*Weakness{
Expand Down
10 changes: 0 additions & 10 deletions cwe/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,3 @@ func (w *Weakness) MarshalJSON() ([]byte, error) {
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)
}
4 changes: 2 additions & 2 deletions cwe/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var _ = Describe("CWE Types", func() {
})
Context("when consulting cwe types", 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.DownloadURI()).To(Equal("https://cwe.mitre.org/data/xml/cwec_v4.4.xml.zip"))
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"))
})

It("it should retrieves the weakness ID and URL", func() {
Expand Down
4 changes: 2 additions & 2 deletions report/sarif/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func buildSarifReportingDescriptorRelationship(weakness *cwe.Weakness) *Reportin
}

func buildCWETaxonomy(taxa []*ReportingDescriptor) *ToolComponent {
return NewToolComponent(cwe.Acronym, cwe.Version, cwe.InformationURI()).
return NewToolComponent(cwe.Acronym, cwe.Version, cwe.InformationURI).
WithReleaseDateUtc(cwe.ReleaseDateUtc).
WithDownloadURI(cwe.DownloadURI()).
WithDownloadURI(cwe.DownloadURI).
WithOrganization(cwe.Organization).
WithShortDescription(NewMultiformatMessageString(cwe.Description)).
WithIsComprehensive(true).
Expand Down

0 comments on commit e72b1e5

Please sign in to comment.