Skip to content

Commit

Permalink
fix: fix mapping of gocloc language to bearer (#1636)
Browse files Browse the repository at this point in the history
  • Loading branch information
didroe authored Jun 12, 2024
1 parent 58ce3a2 commit 9e7769a
Show file tree
Hide file tree
Showing 50 changed files with 3,924 additions and 3,905 deletions.
19 changes: 8 additions & 11 deletions pkg/commands/artifact/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ func getIgnoredFingerprints(settings settings.Config) (
return false, localIgnoredFingerprints, []string{}, nil
}


type ReportFailedError int

func (exitcode ReportFailedError) Error() string {
return "Report failed with exitcode"
return "Report failed with exitcode"
}

// Run performs artifact scanning
Expand Down Expand Up @@ -349,7 +349,7 @@ func Run(ctx context.Context, opts flagtypes.Options, engine engine.Engine) (err
if scanSettings.Scan.ExitCode == -1 {
return ReportFailedError(1)
} else {
return ReportFailedError(scanSettings.Scan.ExitCode)
return ReportFailedError(scanSettings.Scan.ExitCode)
}
}

Expand Down Expand Up @@ -456,14 +456,11 @@ func anySupportedLanguagesPresent(engine engine.Engine, inputgocloc *gocloc.Resu
}
}

foundLanguages := make(map[string]bool)
for _, language := range inputgocloc.Languages {
foundLanguages[strings.ToLower(language.Name)] = true
}

for _, supportedLanguage := range engine.GetLanguages() {
if _, supportedLangPresent := foundLanguages[supportedLanguage.ID()]; supportedLangPresent {
return true
for _, goclocLanguage := range inputgocloc.Languages {
for _, language := range engine.GetLanguages() {
if slices.Contains(language.GoclocLanguages(), goclocLanguage.Name) {
return true
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/commands/process/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,7 @@ func (rule *Rule) GetSeverity() string {

return rule.Severity
}

func (rule *Rule) IsSecrets() bool {
return rule.Languages == nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "gradleparser",
DetectorLanguage: (detectors.Language) (len=4) "Java",
DetectorLanguage: (detectors.Language) (len=4) "java",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "build.gradle",
Expand All @@ -25,7 +25,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "gradleparser",
DetectorLanguage: (detectors.Language) (len=4) "Java",
DetectorLanguage: (detectors.Language) (len=4) "java",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "build.gradle",
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/dependencies/buildgradle/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
func Discover(file *file.FileInfo) (report *depsbase.DiscoveredDependency) {
report = &depsbase.DiscoveredDependency{}
report.Provider = "gradleparser"
report.Language = "Java"
report.Language = "java"
report.PackageManager = "maven"

fileBytes, err := os.ReadFile(file.AbsolutePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerjson",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.json",
Expand All @@ -25,7 +25,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerjson",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.json",
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/dependencies/composerjson/composerjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var queryDependencies = parser.QueryMustCompile(language, `
func Discover(f *file.FileInfo) (report *depsbase.DiscoveredDependency) {
report = &depsbase.DiscoveredDependency{}
report.Provider = "composerjson"
report.Language = "PHP"
report.Language = "php"
report.PackageManager = "packagist"
tree, err := parser.ParseFile(f, f.Path, javascript.GetLanguage())
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -25,7 +25,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -48,7 +48,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -71,7 +71,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -94,7 +94,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -117,7 +117,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -140,7 +140,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
DetectorLanguage: (detectors.Language) (len=3) "php",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/dependencies/composerlock/composerlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var queryDependencies = parser.QueryMustCompile(language, `
func Discover(f *file.FileInfo) (report *depsbase.DiscoveredDependency) {
report = &depsbase.DiscoveredDependency{}
report.Provider = "composerlock"
report.Language = "PHP"
report.Language = "php"
report.PackageManager = "packagist"
tree, err := parser.ParseFile(f, f.Path, javascript.GetLanguage())
if err != nil {
Expand Down
Loading

0 comments on commit 9e7769a

Please sign in to comment.