Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed JSON encoder from encoding/json to json-iterator/go #1250

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/guacone/cmd/collectsub_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ package cmd

import (
"context"
"encoding/json"
"fmt"
"io"
"os"

jsoniter "github.com/json-iterator/go"

"github.com/guacsec/guac/pkg/cli"
"github.com/guacsec/guac/pkg/collectsub/client"
"github.com/guacsec/guac/pkg/collectsub/collectsub"
Expand All @@ -31,6 +32,8 @@ import (
"github.com/spf13/viper"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

type csubClientOptions struct {
addr string
}
Expand Down
5 changes: 4 additions & 1 deletion internal/testing/cmd/pubsub_test/cmd/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ package cmd

import (
"context"
"encoding/json"
"fmt"
"os"
"sync"
"time"

jsoniter "github.com/json-iterator/go"

"github.com/guacsec/guac/pkg/assembler"
"github.com/guacsec/guac/pkg/emitter"
"github.com/guacsec/guac/pkg/handler/collector"
Expand All @@ -37,6 +38,8 @@ import (
"github.com/spf13/viper"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

type options struct {
dbAddr string
user string
Expand Down
1 change: 0 additions & 1 deletion internal/testing/cmd/pubsub_test/cmd/osv.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package cmd

import (
"context"
"encoding/json"
"fmt"
"net/http"
"os"
Expand Down
5 changes: 4 additions & 1 deletion internal/testing/dochelper/dochelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
package dochelper

import (
"encoding/json"
"fmt"
"reflect"
"time"

jsoniter "github.com/json-iterator/go"

attestation_vuln "github.com/guacsec/guac/pkg/certifier/attestation"
"github.com/guacsec/guac/pkg/handler/processor"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

func existAndPop(nodes []*processor.DocumentNode, n *processor.DocumentNode) bool {
for i, nn := range nodes {
if DocTreeEqual(nn, n) {
Expand Down
5 changes: 4 additions & 1 deletion internal/testing/testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package testdata
import (
_ "embed"
"encoding/base64"
"encoding/json"
"time"

jsoniter "github.com/json-iterator/go"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/guacsec/guac/internal/testing/keyutil"
Expand Down Expand Up @@ -137,6 +138,8 @@ var (
//go:embed exampledata/ingest_predicates.json
IngestPredicatesExample []byte

// json format
json = jsoniter.ConfigCompatibleWithStandardLibrary
// CycloneDX VEX testdata unaffected
pkg, _ = asmhelpers.PurlToPkg("pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.10.0?type=jar")
vulnSpec = &generated.VulnerabilityInputSpec{
Expand Down
5 changes: 4 additions & 1 deletion pkg/assembler/assembler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ package assembler

import (
"context"
"encoding/json"
"fmt"
"testing"
"time"

jsoniter "github.com/json-iterator/go"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/guacsec/guac/internal/testing/ptrfrom"
"github.com/guacsec/guac/pkg/assembler/clients/generated"
"github.com/guacsec/guac/pkg/assembler/helpers"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

func TestIngestPredicates(t *testing.T) {
ctx := context.Background()
slsaStartTime, _ := time.Parse(time.RFC3339, "2020-08-19T08:38:00Z")
Expand Down
5 changes: 4 additions & 1 deletion pkg/assembler/backends/arangodb/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

jsoniter "github.com/json-iterator/go"

"github.com/arangodb/go-driver"
"github.com/guacsec/guac/pkg/assembler/graphql/model"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

func (c *arangoClient) Artifacts(ctx context.Context, artifactSpec *model.ArtifactSpec) ([]*model.Artifact, error) {
values := map[string]any{}

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/certifyBad.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/certifyGood.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/certifyScorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"sort"
"strconv"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/certifyVEXStatement.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/certifyVuln.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/hasMetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/hasSBOM.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/hasSLSA.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/hashEqual.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/isDependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/isOccurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/pkgEqual.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/pointOfContact.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/src.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/vulnEqual.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/vulnMetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
Expand Down
1 change: 0 additions & 1 deletion pkg/assembler/backends/arangodb/vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package arangodb

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down
4 changes: 3 additions & 1 deletion pkg/assembler/backends/ent/backend/pkgequal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
package backend

import (
"encoding/json"
"strconv"

"github.com/google/go-cmp/cmp"
"github.com/guacsec/guac/internal/testing/ptrfrom"
"github.com/guacsec/guac/pkg/assembler/graphql/model"
jsoniter "github.com/json-iterator/go"
"golang.org/x/exp/slices"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

func (s *Suite) TestPkgEqual() {
type call struct {
P1 *model.PkgInputSpec
Expand Down
5 changes: 4 additions & 1 deletion pkg/assembler/backends/inmem/isOccurrence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ package inmem_test

import (
"context"
"encoding/json"
"strings"
"testing"

jsoniter "github.com/json-iterator/go"

"github.com/google/go-cmp/cmp"
"golang.org/x/exp/slices"

Expand All @@ -29,6 +30,8 @@ import (
"github.com/guacsec/guac/pkg/assembler/graphql/model"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

func convNode(n model.Node) hasID {
// All nodes have a json "id"
// Only getting top-level id however
Expand Down
5 changes: 4 additions & 1 deletion pkg/assembler/backends/neptune/neptune.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ package neptune

import (
"context"
"encoding/json"
"fmt"
"net/http"
"os"
"time"

jsoniter "github.com/json-iterator/go"

"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/guacsec/guac/pkg/assembler/backends"
"github.com/guacsec/guac/pkg/assembler/backends/neo4j"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

const neptuneServiceName = "neptune-db"

func init() {
Expand Down
5 changes: 4 additions & 1 deletion pkg/certifier/certify/certify.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ package certify

import (
"context"
"encoding/json"
"fmt"
"time"

jsoniter "github.com/json-iterator/go"

"github.com/guacsec/guac/pkg/certifier"
"github.com/guacsec/guac/pkg/emitter"
"github.com/guacsec/guac/pkg/handler/processor"
"github.com/guacsec/guac/pkg/logging"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

const (
BufferChannelSize int = 1000
)
Expand Down
1 change: 0 additions & 1 deletion pkg/certifier/certify/certify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package certify

import (
"context"
"encoding/json"
"errors"
"fmt"
"testing"
Expand Down
Loading
Loading