Skip to content

Commit

Permalink
Merge pull request #6990 from Checkmarx/kics-1418
Browse files Browse the repository at this point in the history
fix(parser): easyjson replaced by enconding json
  • Loading branch information
asofsilva authored Apr 10, 2024
2 parents 947ca37 + 8ddef74 commit fd036a8
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 202 deletions.
1 change: 0 additions & 1 deletion .github/scripts/coverage/.coverageignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*/**/model_easyjson.go
test/*.go
pkg/engine/mock/*.go
*/**/*_test.go
Expand Down
2 changes: 1 addition & 1 deletion cx.configuration
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"engineConfiguration": "",
"incremental": "false",
"forceScan" : "true",
"fileExcludes": "pkg/model/model_easyjson.go,*_test.go",
"fileExcludes": "*_test.go",
"folderExcludes": "test,e2e/fixtures,e2e/testcases,.github,pkg/parser/jsonfilter/parser"
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ require (
github.com/hashicorp/terraform-json v0.16.0
github.com/johnfercher/maroto v0.40.0
github.com/mackerelio/go-osstat v0.2.4
github.com/mailru/easyjson v0.7.7
github.com/moby/buildkit v0.12.5
github.com/open-policy-agent/opa v0.58.0
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -75,6 +74,7 @@ require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/samber/lo v1.38.1 // indirect
Expand Down
6 changes: 2 additions & 4 deletions pkg/model/model.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Package model (go:generate go run -mod=mod github.com/mailru/easyjson/easyjson ./$GOFILE)
package model

import (
"regexp"
"sort"
"strings"

_ "github.com/mailru/easyjson/gen" // easyjson unmarshaler
"github.com/rs/zerolog/log"
)

Expand Down Expand Up @@ -252,12 +250,12 @@ func (m FileMetadatas) ToMap() map[string]FileMetadata {
return c
}

// Documents (easyjson:json)
// Documents
type Documents struct {
Documents []Document `json:"document"`
}

// Document (easyjson:json)
// Document
type Document map[string]interface{}

// Combine merge documents from FileMetadatas using the ID as reference for Document ID and FileName as reference for file
Expand Down
193 changes: 0 additions & 193 deletions pkg/model/model_easyjson.go

This file was deleted.

3 changes: 1 addition & 2 deletions pkg/parser/json/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/Checkmarx/kics/pkg/model"
"github.com/Checkmarx/kics/pkg/resolver/file"
"github.com/mailru/easyjson"
)

// Parser defines a parser type
Expand All @@ -31,7 +30,7 @@ func (p *Parser) Resolve(fileContent []byte, filename string, resolveReferences
// Parse parses json file and returns it as a Document
func (p *Parser) Parse(_ string, fileContent []byte) ([]model.Document, []int, error) {
r := model.Document{}
err := easyjson.Unmarshal(fileContent, &r)
err := json.Unmarshal(fileContent, &r)
if err != nil {
var r []model.Document
err = json.Unmarshal(fileContent, &r)
Expand Down

0 comments on commit fd036a8

Please sign in to comment.