From 1bede1ee0aa0e370b903cef0861b188edf69750a Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Fri, 1 Mar 2024 23:22:51 +0400 Subject: [PATCH] refactor: drop easyjson Signed-off-by: knqyf263 --- magefiles/magefile.go | 14 - pkg/module/module.go | 5 +- pkg/module/serialize/types.go | 10 - pkg/module/serialize/types_easyjson.go | 3024 ------------------------ pkg/module/wasm/sdk.go | 23 +- 5 files changed, 11 insertions(+), 3065 deletions(-) delete mode 100644 pkg/module/serialize/types_easyjson.go diff --git a/magefiles/magefile.go b/magefiles/magefile.go index cafd8a045c47..f0d514155f6e 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -76,14 +76,6 @@ func (Tool) Labeler() error { return sh.Run("go", "install", "github.com/knqyf263/labeler@latest") } -// EasyJSON installs easyjson -func (Tool) EasyJSON() error { - if exists(filepath.Join(GOBIN, "easyjson")) { - return nil - } - return sh.Run("go", "install", "github.com/mailru/easyjson/...@v0.7.7") -} - // Kind installs kind cluster func (Tool) Kind() error { return sh.RunWithV(ENV, "go", "install", "sigs.k8s.io/kind@v0.19.0") @@ -163,12 +155,6 @@ func Yacc() error { return sh.Run("go", "generate", "./pkg/licensing/expression/...") } -// Easyjson generates JSON marshaler/unmarshaler for TinyGo/WebAssembly as TinyGo doesn't support encoding/json. -func Easyjson() error { - mg.Deps(Tool{}.EasyJSON) - return sh.Run("easyjson", "./pkg/module/serialize/types.go") -} - type Test mg.Namespace // FixtureContainerImages downloads and extracts required images diff --git a/pkg/module/module.go b/pkg/module/module.go index 4395feeddeb3..3d670999e1b9 100644 --- a/pkg/module/module.go +++ b/pkg/module/module.go @@ -9,7 +9,6 @@ import ( "regexp" "sync" - "github.com/mailru/easyjson" "github.com/samber/lo" "github.com/tetratelabs/wazero" "github.com/tetratelabs/wazero/api" @@ -235,8 +234,8 @@ func unmarshal(mem api.Memory, ptrSize uint64, v any) error { return nil } -func marshal(ctx context.Context, m api.Module, malloc api.Function, v easyjson.Marshaler) (uint64, uint64, error) { - b, err := easyjson.Marshal(v) +func marshal(ctx context.Context, m api.Module, malloc api.Function, v any) (uint64, uint64, error) { + b, err := json.Marshal(v) if err != nil { return 0, 0, xerrors.Errorf("marshal error: %w", err) } diff --git a/pkg/module/serialize/types.go b/pkg/module/serialize/types.go index 21733f736082..df72a953eee3 100644 --- a/pkg/module/serialize/types.go +++ b/pkg/module/serialize/types.go @@ -4,15 +4,8 @@ import ( "github.com/aquasecurity/trivy/pkg/types" ) -// TinyGo doesn't support encoding/json, but github.com/mailru/easyjson for now. -// We need to generate JSON-related methods like MarshalEasyJSON implementing easyjson.Marshaler. -// -// $ make easyjson - -//easyjson:json type StringSlice []string -//easyjson:json type AnalysisResult struct { // TODO: support other fields as well // OS *types.OS @@ -34,7 +27,6 @@ type CustomResource struct { type PostScanAction string -//easyjson:json type PostScanSpec struct { // What action the module will do in post scanning. // value: INSERT, UPDATE and DELETE @@ -45,8 +37,6 @@ type PostScanSpec struct { IDs []string } -//easyjson:json type Results []Result -//easyjson:json type Result types.Result diff --git a/pkg/module/serialize/types_easyjson.go b/pkg/module/serialize/types_easyjson.go deleted file mode 100644 index 988347841c28..000000000000 --- a/pkg/module/serialize/types_easyjson.go +++ /dev/null @@ -1,3024 +0,0 @@ -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. - -package serialize - -import ( - json "encoding/json" - types2 "github.com/aquasecurity/trivy-db/pkg/types" - digest "github.com/aquasecurity/trivy/pkg/digest" - types1 "github.com/aquasecurity/trivy/pkg/fanal/types" - types "github.com/aquasecurity/trivy/pkg/types" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" - time "time" -) - -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize(in *jlexer.Lexer, out *StringSlice) { - isTopLevel := in.IsStart() - if in.IsNull() { - in.Skip() - *out = nil - } else { - in.Delim('[') - if *out == nil { - if !in.IsDelim(']') { - *out = make(StringSlice, 0, 4) - } else { - *out = StringSlice{} - } - } else { - *out = (*out)[:0] - } - for !in.IsDelim(']') { - var v1 string - v1 = string(in.String()) - *out = append(*out, v1) - in.WantComma() - } - in.Delim(']') - } - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize(out *jwriter.Writer, in StringSlice) { - if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v2, v3 := range in { - if v2 > 0 { - out.RawByte(',') - } - out.String(string(v3)) - } - out.RawByte(']') - } -} - -// MarshalJSON supports json.Marshaler interface -func (v StringSlice) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v StringSlice) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *StringSlice) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *StringSlice) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize(l, v) -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize1(in *jlexer.Lexer, out *Results) { - isTopLevel := in.IsStart() - if in.IsNull() { - in.Skip() - *out = nil - } else { - in.Delim('[') - if *out == nil { - if !in.IsDelim(']') { - *out = make(Results, 0, 0) - } else { - *out = Results{} - } - } else { - *out = (*out)[:0] - } - for !in.IsDelim(']') { - var v4 Result - (v4).UnmarshalEasyJSON(in) - *out = append(*out, v4) - in.WantComma() - } - in.Delim(']') - } - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize1(out *jwriter.Writer, in Results) { - if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v5, v6 := range in { - if v5 > 0 { - out.RawByte(',') - } - (v6).MarshalEasyJSON(out) - } - out.RawByte(']') - } -} - -// MarshalJSON supports json.Marshaler interface -func (v Results) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize1(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v Results) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize1(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *Results) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize1(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Results) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize1(l, v) -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize2(in *jlexer.Lexer, out *Result) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Target": - out.Target = string(in.String()) - case "Class": - out.Class = types.ResultClass(in.String()) - case "Type": - out.Type = types1.TargetType(in.String()) - case "Packages": - if in.IsNull() { - in.Skip() - out.Packages = nil - } else { - in.Delim('[') - if out.Packages == nil { - if !in.IsDelim(']') { - out.Packages = make([]types1.Package, 0, 0) - } else { - out.Packages = []types1.Package{} - } - } else { - out.Packages = (out.Packages)[:0] - } - for !in.IsDelim(']') { - var v7 types1.Package - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes(in, &v7) - out.Packages = append(out.Packages, v7) - in.WantComma() - } - in.Delim(']') - } - case "Vulnerabilities": - if in.IsNull() { - in.Skip() - out.Vulnerabilities = nil - } else { - in.Delim('[') - if out.Vulnerabilities == nil { - if !in.IsDelim(']') { - out.Vulnerabilities = make([]types.DetectedVulnerability, 0, 0) - } else { - out.Vulnerabilities = []types.DetectedVulnerability{} - } - } else { - out.Vulnerabilities = (out.Vulnerabilities)[:0] - } - for !in.IsDelim(']') { - var v8 types.DetectedVulnerability - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes(in, &v8) - out.Vulnerabilities = append(out.Vulnerabilities, v8) - in.WantComma() - } - in.Delim(']') - } - case "MisconfSummary": - if in.IsNull() { - in.Skip() - out.MisconfSummary = nil - } else { - if out.MisconfSummary == nil { - out.MisconfSummary = new(types.MisconfSummary) - } - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes1(in, out.MisconfSummary) - } - case "Misconfigurations": - if in.IsNull() { - in.Skip() - out.Misconfigurations = nil - } else { - in.Delim('[') - if out.Misconfigurations == nil { - if !in.IsDelim(']') { - out.Misconfigurations = make([]types.DetectedMisconfiguration, 0, 0) - } else { - out.Misconfigurations = []types.DetectedMisconfiguration{} - } - } else { - out.Misconfigurations = (out.Misconfigurations)[:0] - } - for !in.IsDelim(']') { - var v9 types.DetectedMisconfiguration - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes2(in, &v9) - out.Misconfigurations = append(out.Misconfigurations, v9) - in.WantComma() - } - in.Delim(']') - } - case "Secrets": - if in.IsNull() { - in.Skip() - out.Secrets = nil - } else { - in.Delim('[') - if out.Secrets == nil { - if !in.IsDelim(']') { - out.Secrets = make([]types.DetectedSecret, 0, 0) - } else { - out.Secrets = []types.DetectedSecret{} - } - } else { - out.Secrets = (out.Secrets)[:0] - } - for !in.IsDelim(']') { - var v10 types.DetectedSecret - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes3(in, &v10) - out.Secrets = append(out.Secrets, v10) - in.WantComma() - } - in.Delim(']') - } - case "Licenses": - if in.IsNull() { - in.Skip() - out.Licenses = nil - } else { - in.Delim('[') - if out.Licenses == nil { - if !in.IsDelim(']') { - out.Licenses = make([]types.DetectedLicense, 0, 0) - } else { - out.Licenses = []types.DetectedLicense{} - } - } else { - out.Licenses = (out.Licenses)[:0] - } - for !in.IsDelim(']') { - var v11 types.DetectedLicense - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes4(in, &v11) - out.Licenses = append(out.Licenses, v11) - in.WantComma() - } - in.Delim(']') - } - case "CustomResources": - if in.IsNull() { - in.Skip() - out.CustomResources = nil - } else { - in.Delim('[') - if out.CustomResources == nil { - if !in.IsDelim(']') { - out.CustomResources = make([]types1.CustomResource, 0, 0) - } else { - out.CustomResources = []types1.CustomResource{} - } - } else { - out.CustomResources = (out.CustomResources)[:0] - } - for !in.IsDelim(']') { - var v12 types1.CustomResource - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes1(in, &v12) - out.CustomResources = append(out.CustomResources, v12) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize2(out *jwriter.Writer, in Result) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Target\":" - out.RawString(prefix[1:]) - out.String(string(in.Target)) - } - if in.Class != "" { - const prefix string = ",\"Class\":" - out.RawString(prefix) - out.String(string(in.Class)) - } - if in.Type != "" { - const prefix string = ",\"Type\":" - out.RawString(prefix) - out.String(string(in.Type)) - } - if len(in.Packages) != 0 { - const prefix string = ",\"Packages\":" - out.RawString(prefix) - { - out.RawByte('[') - for v13, v14 := range in.Packages { - if v13 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes(out, v14) - } - out.RawByte(']') - } - } - if len(in.Vulnerabilities) != 0 { - const prefix string = ",\"Vulnerabilities\":" - out.RawString(prefix) - { - out.RawByte('[') - for v15, v16 := range in.Vulnerabilities { - if v15 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes(out, v16) - } - out.RawByte(']') - } - } - if in.MisconfSummary != nil { - const prefix string = ",\"MisconfSummary\":" - out.RawString(prefix) - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes1(out, *in.MisconfSummary) - } - if len(in.Misconfigurations) != 0 { - const prefix string = ",\"Misconfigurations\":" - out.RawString(prefix) - { - out.RawByte('[') - for v17, v18 := range in.Misconfigurations { - if v17 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes2(out, v18) - } - out.RawByte(']') - } - } - if len(in.Secrets) != 0 { - const prefix string = ",\"Secrets\":" - out.RawString(prefix) - { - out.RawByte('[') - for v19, v20 := range in.Secrets { - if v19 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes3(out, v20) - } - out.RawByte(']') - } - } - if len(in.Licenses) != 0 { - const prefix string = ",\"Licenses\":" - out.RawString(prefix) - { - out.RawByte('[') - for v21, v22 := range in.Licenses { - if v21 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes4(out, v22) - } - out.RawByte(']') - } - } - if len(in.CustomResources) != 0 { - const prefix string = ",\"CustomResources\":" - out.RawString(prefix) - { - out.RawByte('[') - for v23, v24 := range in.CustomResources { - if v23 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes1(out, v24) - } - out.RawByte(']') - } - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v Result) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize2(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v Result) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize2(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *Result) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize2(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Result) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize2(l, v) -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes1(in *jlexer.Lexer, out *types1.CustomResource) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Type": - out.Type = string(in.String()) - case "FilePath": - out.FilePath = string(in.String()) - case "Layer": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes2(in, &out.Layer) - case "Data": - if m, ok := out.Data.(easyjson.Unmarshaler); ok { - m.UnmarshalEasyJSON(in) - } else if m, ok := out.Data.(json.Unmarshaler); ok { - _ = m.UnmarshalJSON(in.Raw()) - } else { - out.Data = in.Interface() - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes1(out *jwriter.Writer, in types1.CustomResource) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Type\":" - out.RawString(prefix[1:]) - out.String(string(in.Type)) - } - { - const prefix string = ",\"FilePath\":" - out.RawString(prefix) - out.String(string(in.FilePath)) - } - { - const prefix string = ",\"Layer\":" - out.RawString(prefix) - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes2(out, in.Layer) - } - { - const prefix string = ",\"Data\":" - out.RawString(prefix) - if m, ok := in.Data.(easyjson.Marshaler); ok { - m.MarshalEasyJSON(out) - } else if m, ok := in.Data.(json.Marshaler); ok { - out.Raw(m.MarshalJSON()) - } else { - out.Raw(json.Marshal(in.Data)) - } - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes2(in *jlexer.Lexer, out *types1.Layer) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Digest": - out.Digest = string(in.String()) - case "DiffID": - out.DiffID = string(in.String()) - case "CreatedBy": - out.CreatedBy = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes2(out *jwriter.Writer, in types1.Layer) { - out.RawByte('{') - first := true - _ = first - if in.Digest != "" { - const prefix string = ",\"Digest\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.Digest)) - } - if in.DiffID != "" { - const prefix string = ",\"DiffID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.DiffID)) - } - if in.CreatedBy != "" { - const prefix string = ",\"CreatedBy\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.CreatedBy)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes4(in *jlexer.Lexer, out *types.DetectedLicense) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Severity": - out.Severity = string(in.String()) - case "Category": - out.Category = types1.LicenseCategory(in.String()) - case "PkgName": - out.PkgName = string(in.String()) - case "FilePath": - out.FilePath = string(in.String()) - case "Name": - out.Name = string(in.String()) - case "Confidence": - out.Confidence = float64(in.Float64()) - case "Link": - out.Link = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes4(out *jwriter.Writer, in types.DetectedLicense) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Severity\":" - out.RawString(prefix[1:]) - out.String(string(in.Severity)) - } - { - const prefix string = ",\"Category\":" - out.RawString(prefix) - out.String(string(in.Category)) - } - { - const prefix string = ",\"PkgName\":" - out.RawString(prefix) - out.String(string(in.PkgName)) - } - { - const prefix string = ",\"FilePath\":" - out.RawString(prefix) - out.String(string(in.FilePath)) - } - { - const prefix string = ",\"Name\":" - out.RawString(prefix) - out.String(string(in.Name)) - } - { - const prefix string = ",\"Confidence\":" - out.RawString(prefix) - out.Float64(float64(in.Confidence)) - } - { - const prefix string = ",\"Link\":" - out.RawString(prefix) - out.String(string(in.Link)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes3(in *jlexer.Lexer, out *types.DetectedSecret) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "RuleID": - out.RuleID = string(in.String()) - case "Category": - out.Category = types1.SecretRuleCategory(in.String()) - case "Severity": - out.Severity = string(in.String()) - case "Title": - out.Title = string(in.String()) - case "StartLine": - out.StartLine = int(in.Int()) - case "EndLine": - out.EndLine = int(in.Int()) - case "Code": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes3(in, &out.Code) - case "Match": - out.Match = string(in.String()) - case "Layer": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes2(in, &out.Layer) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes3(out *jwriter.Writer, in types.DetectedSecret) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"RuleID\":" - out.RawString(prefix[1:]) - out.String(string(in.RuleID)) - } - { - const prefix string = ",\"Category\":" - out.RawString(prefix) - out.String(string(in.Category)) - } - { - const prefix string = ",\"Severity\":" - out.RawString(prefix) - out.String(string(in.Severity)) - } - { - const prefix string = ",\"Title\":" - out.RawString(prefix) - out.String(string(in.Title)) - } - { - const prefix string = ",\"StartLine\":" - out.RawString(prefix) - out.Int(int(in.StartLine)) - } - { - const prefix string = ",\"EndLine\":" - out.RawString(prefix) - out.Int(int(in.EndLine)) - } - { - const prefix string = ",\"Code\":" - out.RawString(prefix) - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes3(out, in.Code) - } - { - const prefix string = ",\"Match\":" - out.RawString(prefix) - out.String(string(in.Match)) - } - if true { - const prefix string = ",\"Layer\":" - out.RawString(prefix) - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes2(out, in.Layer) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes3(in *jlexer.Lexer, out *types1.Code) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Lines": - if in.IsNull() { - in.Skip() - out.Lines = nil - } else { - in.Delim('[') - if out.Lines == nil { - if !in.IsDelim(']') { - out.Lines = make([]types1.Line, 0, 0) - } else { - out.Lines = []types1.Line{} - } - } else { - out.Lines = (out.Lines)[:0] - } - for !in.IsDelim(']') { - var v25 types1.Line - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes4(in, &v25) - out.Lines = append(out.Lines, v25) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes3(out *jwriter.Writer, in types1.Code) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Lines\":" - out.RawString(prefix[1:]) - if in.Lines == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v26, v27 := range in.Lines { - if v26 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes4(out, v27) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes4(in *jlexer.Lexer, out *types1.Line) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Number": - out.Number = int(in.Int()) - case "Content": - out.Content = string(in.String()) - case "IsCause": - out.IsCause = bool(in.Bool()) - case "Annotation": - out.Annotation = string(in.String()) - case "Truncated": - out.Truncated = bool(in.Bool()) - case "Highlighted": - out.Highlighted = string(in.String()) - case "FirstCause": - out.FirstCause = bool(in.Bool()) - case "LastCause": - out.LastCause = bool(in.Bool()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes4(out *jwriter.Writer, in types1.Line) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Number\":" - out.RawString(prefix[1:]) - out.Int(int(in.Number)) - } - { - const prefix string = ",\"Content\":" - out.RawString(prefix) - out.String(string(in.Content)) - } - { - const prefix string = ",\"IsCause\":" - out.RawString(prefix) - out.Bool(bool(in.IsCause)) - } - { - const prefix string = ",\"Annotation\":" - out.RawString(prefix) - out.String(string(in.Annotation)) - } - { - const prefix string = ",\"Truncated\":" - out.RawString(prefix) - out.Bool(bool(in.Truncated)) - } - if in.Highlighted != "" { - const prefix string = ",\"Highlighted\":" - out.RawString(prefix) - out.String(string(in.Highlighted)) - } - { - const prefix string = ",\"FirstCause\":" - out.RawString(prefix) - out.Bool(bool(in.FirstCause)) - } - { - const prefix string = ",\"LastCause\":" - out.RawString(prefix) - out.Bool(bool(in.LastCause)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes2(in *jlexer.Lexer, out *types.DetectedMisconfiguration) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Type": - out.Type = string(in.String()) - case "ID": - out.ID = string(in.String()) - case "AVDID": - out.AVDID = string(in.String()) - case "Title": - out.Title = string(in.String()) - case "Description": - out.Description = string(in.String()) - case "Message": - out.Message = string(in.String()) - case "Namespace": - out.Namespace = string(in.String()) - case "Query": - out.Query = string(in.String()) - case "Resolution": - out.Resolution = string(in.String()) - case "Severity": - out.Severity = string(in.String()) - case "PrimaryURL": - out.PrimaryURL = string(in.String()) - case "References": - if in.IsNull() { - in.Skip() - out.References = nil - } else { - in.Delim('[') - if out.References == nil { - if !in.IsDelim(']') { - out.References = make([]string, 0, 4) - } else { - out.References = []string{} - } - } else { - out.References = (out.References)[:0] - } - for !in.IsDelim(']') { - var v28 string - v28 = string(in.String()) - out.References = append(out.References, v28) - in.WantComma() - } - in.Delim(']') - } - case "Status": - out.Status = types.MisconfStatus(in.String()) - case "Layer": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes2(in, &out.Layer) - case "CauseMetadata": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes5(in, &out.CauseMetadata) - case "Traces": - if in.IsNull() { - in.Skip() - out.Traces = nil - } else { - in.Delim('[') - if out.Traces == nil { - if !in.IsDelim(']') { - out.Traces = make([]string, 0, 4) - } else { - out.Traces = []string{} - } - } else { - out.Traces = (out.Traces)[:0] - } - for !in.IsDelim(']') { - var v29 string - v29 = string(in.String()) - out.Traces = append(out.Traces, v29) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes2(out *jwriter.Writer, in types.DetectedMisconfiguration) { - out.RawByte('{') - first := true - _ = first - if in.Type != "" { - const prefix string = ",\"Type\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.Type)) - } - if in.ID != "" { - const prefix string = ",\"ID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ID)) - } - if in.AVDID != "" { - const prefix string = ",\"AVDID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.AVDID)) - } - if in.Title != "" { - const prefix string = ",\"Title\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Title)) - } - if in.Description != "" { - const prefix string = ",\"Description\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Description)) - } - if in.Message != "" { - const prefix string = ",\"Message\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Message)) - } - if in.Namespace != "" { - const prefix string = ",\"Namespace\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Namespace)) - } - if in.Query != "" { - const prefix string = ",\"Query\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Query)) - } - if in.Resolution != "" { - const prefix string = ",\"Resolution\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Resolution)) - } - if in.Severity != "" { - const prefix string = ",\"Severity\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Severity)) - } - if in.PrimaryURL != "" { - const prefix string = ",\"PrimaryURL\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.PrimaryURL)) - } - if len(in.References) != 0 { - const prefix string = ",\"References\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v30, v31 := range in.References { - if v30 > 0 { - out.RawByte(',') - } - out.String(string(v31)) - } - out.RawByte(']') - } - } - if in.Status != "" { - const prefix string = ",\"Status\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Status)) - } - if true { - const prefix string = ",\"Layer\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes2(out, in.Layer) - } - if true { - const prefix string = ",\"CauseMetadata\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes5(out, in.CauseMetadata) - } - if len(in.Traces) != 0 { - const prefix string = ",\"Traces\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v32, v33 := range in.Traces { - if v32 > 0 { - out.RawByte(',') - } - out.String(string(v33)) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes5(in *jlexer.Lexer, out *types1.CauseMetadata) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Resource": - out.Resource = string(in.String()) - case "Provider": - out.Provider = string(in.String()) - case "Service": - out.Service = string(in.String()) - case "StartLine": - out.StartLine = int(in.Int()) - case "EndLine": - out.EndLine = int(in.Int()) - case "Code": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes3(in, &out.Code) - case "Occurrences": - if in.IsNull() { - in.Skip() - out.Occurrences = nil - } else { - in.Delim('[') - if out.Occurrences == nil { - if !in.IsDelim(']') { - out.Occurrences = make([]types1.Occurrence, 0, 1) - } else { - out.Occurrences = []types1.Occurrence{} - } - } else { - out.Occurrences = (out.Occurrences)[:0] - } - for !in.IsDelim(']') { - var v34 types1.Occurrence - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes6(in, &v34) - out.Occurrences = append(out.Occurrences, v34) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes5(out *jwriter.Writer, in types1.CauseMetadata) { - out.RawByte('{') - first := true - _ = first - if in.Resource != "" { - const prefix string = ",\"Resource\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.Resource)) - } - if in.Provider != "" { - const prefix string = ",\"Provider\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Provider)) - } - if in.Service != "" { - const prefix string = ",\"Service\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Service)) - } - if in.StartLine != 0 { - const prefix string = ",\"StartLine\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.StartLine)) - } - if in.EndLine != 0 { - const prefix string = ",\"EndLine\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.EndLine)) - } - if true { - const prefix string = ",\"Code\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes3(out, in.Code) - } - if len(in.Occurrences) != 0 { - const prefix string = ",\"Occurrences\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v35, v36 := range in.Occurrences { - if v35 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes6(out, v36) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes6(in *jlexer.Lexer, out *types1.Occurrence) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Resource": - out.Resource = string(in.String()) - case "Filename": - out.Filename = string(in.String()) - case "Location": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes7(in, &out.Location) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes6(out *jwriter.Writer, in types1.Occurrence) { - out.RawByte('{') - first := true - _ = first - if in.Resource != "" { - const prefix string = ",\"Resource\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.Resource)) - } - if in.Filename != "" { - const prefix string = ",\"Filename\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Filename)) - } - { - const prefix string = ",\"Location\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes7(out, in.Location) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes7(in *jlexer.Lexer, out *types1.Location) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "StartLine": - out.StartLine = int(in.Int()) - case "EndLine": - out.EndLine = int(in.Int()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes7(out *jwriter.Writer, in types1.Location) { - out.RawByte('{') - first := true - _ = first - if in.StartLine != 0 { - const prefix string = ",\"StartLine\":" - first = false - out.RawString(prefix[1:]) - out.Int(int(in.StartLine)) - } - if in.EndLine != 0 { - const prefix string = ",\"EndLine\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.EndLine)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes1(in *jlexer.Lexer, out *types.MisconfSummary) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Successes": - out.Successes = int(in.Int()) - case "Failures": - out.Failures = int(in.Int()) - case "Exceptions": - out.Exceptions = int(in.Int()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes1(out *jwriter.Writer, in types.MisconfSummary) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Successes\":" - out.RawString(prefix[1:]) - out.Int(int(in.Successes)) - } - { - const prefix string = ",\"Failures\":" - out.RawString(prefix) - out.Int(int(in.Failures)) - } - { - const prefix string = ",\"Exceptions\":" - out.RawString(prefix) - out.Int(int(in.Exceptions)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgTypes(in *jlexer.Lexer, out *types.DetectedVulnerability) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "VulnerabilityID": - out.VulnerabilityID = string(in.String()) - case "VendorIDs": - if in.IsNull() { - in.Skip() - out.VendorIDs = nil - } else { - in.Delim('[') - if out.VendorIDs == nil { - if !in.IsDelim(']') { - out.VendorIDs = make([]string, 0, 4) - } else { - out.VendorIDs = []string{} - } - } else { - out.VendorIDs = (out.VendorIDs)[:0] - } - for !in.IsDelim(']') { - var v37 string - v37 = string(in.String()) - out.VendorIDs = append(out.VendorIDs, v37) - in.WantComma() - } - in.Delim(']') - } - case "PkgID": - out.PkgID = string(in.String()) - case "PkgName": - out.PkgName = string(in.String()) - case "PkgPath": - out.PkgPath = string(in.String()) - case "PkgIdentifier": - if data := in.Raw(); in.Ok() { - in.AddError((out.PkgIdentifier).UnmarshalJSON(data)) - } - case "InstalledVersion": - out.InstalledVersion = string(in.String()) - case "FixedVersion": - out.FixedVersion = string(in.String()) - case "Status": - if data := in.Raw(); in.Ok() { - in.AddError((out.Status).UnmarshalJSON(data)) - } - case "Layer": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes2(in, &out.Layer) - case "SeveritySource": - out.SeveritySource = types2.SourceID(in.String()) - case "PrimaryURL": - out.PrimaryURL = string(in.String()) - case "DataSource": - if in.IsNull() { - in.Skip() - out.DataSource = nil - } else { - if out.DataSource == nil { - out.DataSource = new(types2.DataSource) - } - easyjson6601e8cdDecodeGithubComAquasecurityTrivyDbPkgTypes(in, out.DataSource) - } - case "Custom": - if m, ok := out.Custom.(easyjson.Unmarshaler); ok { - m.UnmarshalEasyJSON(in) - } else if m, ok := out.Custom.(json.Unmarshaler); ok { - _ = m.UnmarshalJSON(in.Raw()) - } else { - out.Custom = in.Interface() - } - case "Title": - out.Title = string(in.String()) - case "Description": - out.Description = string(in.String()) - case "Severity": - out.Severity = string(in.String()) - case "CweIDs": - if in.IsNull() { - in.Skip() - out.CweIDs = nil - } else { - in.Delim('[') - if out.CweIDs == nil { - if !in.IsDelim(']') { - out.CweIDs = make([]string, 0, 4) - } else { - out.CweIDs = []string{} - } - } else { - out.CweIDs = (out.CweIDs)[:0] - } - for !in.IsDelim(']') { - var v38 string - v38 = string(in.String()) - out.CweIDs = append(out.CweIDs, v38) - in.WantComma() - } - in.Delim(']') - } - case "VendorSeverity": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.VendorSeverity = make(types2.VendorSeverity) - } else { - out.VendorSeverity = nil - } - for !in.IsDelim('}') { - key := types2.SourceID(in.String()) - in.WantColon() - var v39 types2.Severity - v39 = types2.Severity(in.Int()) - (out.VendorSeverity)[key] = v39 - in.WantComma() - } - in.Delim('}') - } - case "CVSS": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.CVSS = make(types2.VendorCVSS) - } else { - out.CVSS = nil - } - for !in.IsDelim('}') { - key := types2.SourceID(in.String()) - in.WantColon() - var v40 types2.CVSS - easyjson6601e8cdDecodeGithubComAquasecurityTrivyDbPkgTypes1(in, &v40) - (out.CVSS)[key] = v40 - in.WantComma() - } - in.Delim('}') - } - case "References": - if in.IsNull() { - in.Skip() - out.References = nil - } else { - in.Delim('[') - if out.References == nil { - if !in.IsDelim(']') { - out.References = make([]string, 0, 4) - } else { - out.References = []string{} - } - } else { - out.References = (out.References)[:0] - } - for !in.IsDelim(']') { - var v41 string - v41 = string(in.String()) - out.References = append(out.References, v41) - in.WantComma() - } - in.Delim(']') - } - case "PublishedDate": - if in.IsNull() { - in.Skip() - out.PublishedDate = nil - } else { - if out.PublishedDate == nil { - out.PublishedDate = new(time.Time) - } - if data := in.Raw(); in.Ok() { - in.AddError((*out.PublishedDate).UnmarshalJSON(data)) - } - } - case "LastModifiedDate": - if in.IsNull() { - in.Skip() - out.LastModifiedDate = nil - } else { - if out.LastModifiedDate == nil { - out.LastModifiedDate = new(time.Time) - } - if data := in.Raw(); in.Ok() { - in.AddError((*out.LastModifiedDate).UnmarshalJSON(data)) - } - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgTypes(out *jwriter.Writer, in types.DetectedVulnerability) { - out.RawByte('{') - first := true - _ = first - if in.VulnerabilityID != "" { - const prefix string = ",\"VulnerabilityID\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.VulnerabilityID)) - } - if len(in.VendorIDs) != 0 { - const prefix string = ",\"VendorIDs\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v42, v43 := range in.VendorIDs { - if v42 > 0 { - out.RawByte(',') - } - out.String(string(v43)) - } - out.RawByte(']') - } - } - if in.PkgID != "" { - const prefix string = ",\"PkgID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.PkgID)) - } - if in.PkgName != "" { - const prefix string = ",\"PkgName\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.PkgName)) - } - if in.PkgPath != "" { - const prefix string = ",\"PkgPath\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.PkgPath)) - } - if true { - const prefix string = ",\"PkgIdentifier\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((in.PkgIdentifier).MarshalJSON()) - } - if in.InstalledVersion != "" { - const prefix string = ",\"InstalledVersion\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.InstalledVersion)) - } - if in.FixedVersion != "" { - const prefix string = ",\"FixedVersion\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.FixedVersion)) - } - if in.Status != 0 { - const prefix string = ",\"Status\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((in.Status).MarshalJSON()) - } - if true { - const prefix string = ",\"Layer\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes2(out, in.Layer) - } - if in.SeveritySource != "" { - const prefix string = ",\"SeveritySource\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.SeveritySource)) - } - if in.PrimaryURL != "" { - const prefix string = ",\"PrimaryURL\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.PrimaryURL)) - } - if in.DataSource != nil { - const prefix string = ",\"DataSource\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyDbPkgTypes(out, *in.DataSource) - } - if in.Custom != nil { - const prefix string = ",\"Custom\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if m, ok := in.Custom.(easyjson.Marshaler); ok { - m.MarshalEasyJSON(out) - } else if m, ok := in.Custom.(json.Marshaler); ok { - out.Raw(m.MarshalJSON()) - } else { - out.Raw(json.Marshal(in.Custom)) - } - } - if in.Title != "" { - const prefix string = ",\"Title\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Title)) - } - if in.Description != "" { - const prefix string = ",\"Description\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Description)) - } - if in.Severity != "" { - const prefix string = ",\"Severity\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Severity)) - } - if len(in.CweIDs) != 0 { - const prefix string = ",\"CweIDs\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v44, v45 := range in.CweIDs { - if v44 > 0 { - out.RawByte(',') - } - out.String(string(v45)) - } - out.RawByte(']') - } - } - if len(in.VendorSeverity) != 0 { - const prefix string = ",\"VendorSeverity\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v46First := true - for v46Name, v46Value := range in.VendorSeverity { - if v46First { - v46First = false - } else { - out.RawByte(',') - } - out.String(string(v46Name)) - out.RawByte(':') - out.Int(int(v46Value)) - } - out.RawByte('}') - } - } - if len(in.CVSS) != 0 { - const prefix string = ",\"CVSS\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v47First := true - for v47Name, v47Value := range in.CVSS { - if v47First { - v47First = false - } else { - out.RawByte(',') - } - out.String(string(v47Name)) - out.RawByte(':') - easyjson6601e8cdEncodeGithubComAquasecurityTrivyDbPkgTypes1(out, v47Value) - } - out.RawByte('}') - } - } - if len(in.References) != 0 { - const prefix string = ",\"References\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v48, v49 := range in.References { - if v48 > 0 { - out.RawByte(',') - } - out.String(string(v49)) - } - out.RawByte(']') - } - } - if in.PublishedDate != nil { - const prefix string = ",\"PublishedDate\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((*in.PublishedDate).MarshalJSON()) - } - if in.LastModifiedDate != nil { - const prefix string = ",\"LastModifiedDate\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((*in.LastModifiedDate).MarshalJSON()) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyDbPkgTypes1(in *jlexer.Lexer, out *types2.CVSS) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "V2Vector": - out.V2Vector = string(in.String()) - case "V3Vector": - out.V3Vector = string(in.String()) - case "V2Score": - out.V2Score = float64(in.Float64()) - case "V3Score": - out.V3Score = float64(in.Float64()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyDbPkgTypes1(out *jwriter.Writer, in types2.CVSS) { - out.RawByte('{') - first := true - _ = first - if in.V2Vector != "" { - const prefix string = ",\"V2Vector\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.V2Vector)) - } - if in.V3Vector != "" { - const prefix string = ",\"V3Vector\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.V3Vector)) - } - if in.V2Score != 0 { - const prefix string = ",\"V2Score\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Float64(float64(in.V2Score)) - } - if in.V3Score != 0 { - const prefix string = ",\"V3Score\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Float64(float64(in.V3Score)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyDbPkgTypes(in *jlexer.Lexer, out *types2.DataSource) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "ID": - out.ID = types2.SourceID(in.String()) - case "Name": - out.Name = string(in.String()) - case "URL": - out.URL = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyDbPkgTypes(out *jwriter.Writer, in types2.DataSource) { - out.RawByte('{') - first := true - _ = first - if in.ID != "" { - const prefix string = ",\"ID\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.ID)) - } - if in.Name != "" { - const prefix string = ",\"Name\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Name)) - } - if in.URL != "" { - const prefix string = ",\"URL\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.URL)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes(in *jlexer.Lexer, out *types1.Package) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "ID": - out.ID = string(in.String()) - case "Name": - out.Name = string(in.String()) - case "Identifier": - if data := in.Raw(); in.Ok() { - in.AddError((out.Identifier).UnmarshalJSON(data)) - } - case "Version": - out.Version = string(in.String()) - case "Release": - out.Release = string(in.String()) - case "Epoch": - out.Epoch = int(in.Int()) - case "Arch": - out.Arch = string(in.String()) - case "Dev": - out.Dev = bool(in.Bool()) - case "SrcName": - out.SrcName = string(in.String()) - case "SrcVersion": - out.SrcVersion = string(in.String()) - case "SrcRelease": - out.SrcRelease = string(in.String()) - case "SrcEpoch": - out.SrcEpoch = int(in.Int()) - case "Licenses": - if in.IsNull() { - in.Skip() - out.Licenses = nil - } else { - in.Delim('[') - if out.Licenses == nil { - if !in.IsDelim(']') { - out.Licenses = make([]string, 0, 4) - } else { - out.Licenses = []string{} - } - } else { - out.Licenses = (out.Licenses)[:0] - } - for !in.IsDelim(']') { - var v50 string - v50 = string(in.String()) - out.Licenses = append(out.Licenses, v50) - in.WantComma() - } - in.Delim(']') - } - case "Maintainer": - out.Maintainer = string(in.String()) - case "Modularitylabel": - out.Modularitylabel = string(in.String()) - case "BuildInfo": - if in.IsNull() { - in.Skip() - out.BuildInfo = nil - } else { - if out.BuildInfo == nil { - out.BuildInfo = new(types1.BuildInfo) - } - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes8(in, out.BuildInfo) - } - case "Indirect": - out.Indirect = bool(in.Bool()) - case "DependsOn": - if in.IsNull() { - in.Skip() - out.DependsOn = nil - } else { - in.Delim('[') - if out.DependsOn == nil { - if !in.IsDelim(']') { - out.DependsOn = make([]string, 0, 4) - } else { - out.DependsOn = []string{} - } - } else { - out.DependsOn = (out.DependsOn)[:0] - } - for !in.IsDelim(']') { - var v51 string - v51 = string(in.String()) - out.DependsOn = append(out.DependsOn, v51) - in.WantComma() - } - in.Delim(']') - } - case "Layer": - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes2(in, &out.Layer) - case "FilePath": - out.FilePath = string(in.String()) - case "Digest": - out.Digest = digest.Digest(in.String()) - case "Locations": - if in.IsNull() { - in.Skip() - out.Locations = nil - } else { - in.Delim('[') - if out.Locations == nil { - if !in.IsDelim(']') { - out.Locations = make([]types1.Location, 0, 4) - } else { - out.Locations = []types1.Location{} - } - } else { - out.Locations = (out.Locations)[:0] - } - for !in.IsDelim(']') { - var v52 types1.Location - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes7(in, &v52) - out.Locations = append(out.Locations, v52) - in.WantComma() - } - in.Delim(']') - } - case "InstalledFiles": - if in.IsNull() { - in.Skip() - out.InstalledFiles = nil - } else { - in.Delim('[') - if out.InstalledFiles == nil { - if !in.IsDelim(']') { - out.InstalledFiles = make([]string, 0, 4) - } else { - out.InstalledFiles = []string{} - } - } else { - out.InstalledFiles = (out.InstalledFiles)[:0] - } - for !in.IsDelim(']') { - var v53 string - v53 = string(in.String()) - out.InstalledFiles = append(out.InstalledFiles, v53) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes(out *jwriter.Writer, in types1.Package) { - out.RawByte('{') - first := true - _ = first - if in.ID != "" { - const prefix string = ",\"ID\":" - first = false - out.RawString(prefix[1:]) - out.String(string(in.ID)) - } - if in.Name != "" { - const prefix string = ",\"Name\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Name)) - } - if true { - const prefix string = ",\"Identifier\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((in.Identifier).MarshalJSON()) - } - if in.Version != "" { - const prefix string = ",\"Version\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Version)) - } - if in.Release != "" { - const prefix string = ",\"Release\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Release)) - } - if in.Epoch != 0 { - const prefix string = ",\"Epoch\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.Epoch)) - } - if in.Arch != "" { - const prefix string = ",\"Arch\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Arch)) - } - if in.Dev { - const prefix string = ",\"Dev\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Dev)) - } - if in.SrcName != "" { - const prefix string = ",\"SrcName\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.SrcName)) - } - if in.SrcVersion != "" { - const prefix string = ",\"SrcVersion\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.SrcVersion)) - } - if in.SrcRelease != "" { - const prefix string = ",\"SrcRelease\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.SrcRelease)) - } - if in.SrcEpoch != 0 { - const prefix string = ",\"SrcEpoch\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.SrcEpoch)) - } - if len(in.Licenses) != 0 { - const prefix string = ",\"Licenses\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v54, v55 := range in.Licenses { - if v54 > 0 { - out.RawByte(',') - } - out.String(string(v55)) - } - out.RawByte(']') - } - } - if in.Maintainer != "" { - const prefix string = ",\"Maintainer\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Maintainer)) - } - if in.Modularitylabel != "" { - const prefix string = ",\"Modularitylabel\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Modularitylabel)) - } - if in.BuildInfo != nil { - const prefix string = ",\"BuildInfo\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes8(out, *in.BuildInfo) - } - if in.Indirect { - const prefix string = ",\"Indirect\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Indirect)) - } - if len(in.DependsOn) != 0 { - const prefix string = ",\"DependsOn\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v56, v57 := range in.DependsOn { - if v56 > 0 { - out.RawByte(',') - } - out.String(string(v57)) - } - out.RawByte(']') - } - } - if true { - const prefix string = ",\"Layer\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes2(out, in.Layer) - } - if in.FilePath != "" { - const prefix string = ",\"FilePath\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.FilePath)) - } - if in.Digest != "" { - const prefix string = ",\"Digest\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Digest)) - } - if len(in.Locations) != 0 { - const prefix string = ",\"Locations\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v58, v59 := range in.Locations { - if v58 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes7(out, v59) - } - out.RawByte(']') - } - } - if len(in.InstalledFiles) != 0 { - const prefix string = ",\"InstalledFiles\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v60, v61 := range in.InstalledFiles { - if v60 > 0 { - out.RawByte(',') - } - out.String(string(v61)) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgFanalTypes8(in *jlexer.Lexer, out *types1.BuildInfo) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "ContentSets": - if in.IsNull() { - in.Skip() - out.ContentSets = nil - } else { - in.Delim('[') - if out.ContentSets == nil { - if !in.IsDelim(']') { - out.ContentSets = make([]string, 0, 4) - } else { - out.ContentSets = []string{} - } - } else { - out.ContentSets = (out.ContentSets)[:0] - } - for !in.IsDelim(']') { - var v62 string - v62 = string(in.String()) - out.ContentSets = append(out.ContentSets, v62) - in.WantComma() - } - in.Delim(']') - } - case "Nvr": - out.Nvr = string(in.String()) - case "Arch": - out.Arch = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgFanalTypes8(out *jwriter.Writer, in types1.BuildInfo) { - out.RawByte('{') - first := true - _ = first - if len(in.ContentSets) != 0 { - const prefix string = ",\"ContentSets\":" - first = false - out.RawString(prefix[1:]) - { - out.RawByte('[') - for v63, v64 := range in.ContentSets { - if v63 > 0 { - out.RawByte(',') - } - out.String(string(v64)) - } - out.RawByte(']') - } - } - if in.Nvr != "" { - const prefix string = ",\"Nvr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Nvr)) - } - if in.Arch != "" { - const prefix string = ",\"Arch\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Arch)) - } - out.RawByte('}') -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize3(in *jlexer.Lexer, out *PostScanSpec) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Action": - out.Action = PostScanAction(in.String()) - case "IDs": - if in.IsNull() { - in.Skip() - out.IDs = nil - } else { - in.Delim('[') - if out.IDs == nil { - if !in.IsDelim(']') { - out.IDs = make([]string, 0, 4) - } else { - out.IDs = []string{} - } - } else { - out.IDs = (out.IDs)[:0] - } - for !in.IsDelim(']') { - var v65 string - v65 = string(in.String()) - out.IDs = append(out.IDs, v65) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize3(out *jwriter.Writer, in PostScanSpec) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Action\":" - out.RawString(prefix[1:]) - out.String(string(in.Action)) - } - { - const prefix string = ",\"IDs\":" - out.RawString(prefix) - if in.IDs == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v66, v67 := range in.IDs { - if v66 > 0 { - out.RawByte(',') - } - out.String(string(v67)) - } - out.RawByte(']') - } - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v PostScanSpec) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize3(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v PostScanSpec) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize3(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *PostScanSpec) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize3(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *PostScanSpec) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize3(l, v) -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize4(in *jlexer.Lexer, out *AnalysisResult) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "CustomResources": - if in.IsNull() { - in.Skip() - out.CustomResources = nil - } else { - in.Delim('[') - if out.CustomResources == nil { - if !in.IsDelim(']') { - out.CustomResources = make([]CustomResource, 0, 1) - } else { - out.CustomResources = []CustomResource{} - } - } else { - out.CustomResources = (out.CustomResources)[:0] - } - for !in.IsDelim(']') { - var v68 CustomResource - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize5(in, &v68) - out.CustomResources = append(out.CustomResources, v68) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize4(out *jwriter.Writer, in AnalysisResult) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"CustomResources\":" - out.RawString(prefix[1:]) - if in.CustomResources == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v69, v70 := range in.CustomResources { - if v69 > 0 { - out.RawByte(',') - } - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize5(out, v70) - } - out.RawByte(']') - } - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v AnalysisResult) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize4(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v AnalysisResult) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize4(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *AnalysisResult) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize4(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *AnalysisResult) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize4(l, v) -} -func easyjson6601e8cdDecodeGithubComAquasecurityTrivyPkgModuleSerialize5(in *jlexer.Lexer, out *CustomResource) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "Type": - out.Type = string(in.String()) - case "FilePath": - out.FilePath = string(in.String()) - case "Data": - if m, ok := out.Data.(easyjson.Unmarshaler); ok { - m.UnmarshalEasyJSON(in) - } else if m, ok := out.Data.(json.Unmarshaler); ok { - _ = m.UnmarshalJSON(in.Raw()) - } else { - out.Data = in.Interface() - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeGithubComAquasecurityTrivyPkgModuleSerialize5(out *jwriter.Writer, in CustomResource) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"Type\":" - out.RawString(prefix[1:]) - out.String(string(in.Type)) - } - { - const prefix string = ",\"FilePath\":" - out.RawString(prefix) - out.String(string(in.FilePath)) - } - { - const prefix string = ",\"Data\":" - out.RawString(prefix) - if m, ok := in.Data.(easyjson.Marshaler); ok { - m.MarshalEasyJSON(out) - } else if m, ok := in.Data.(json.Marshaler); ok { - out.Raw(m.MarshalJSON()) - } else { - out.Raw(json.Marshal(in.Data)) - } - } - out.RawByte('}') -} diff --git a/pkg/module/wasm/sdk.go b/pkg/module/wasm/sdk.go index dab28a88497c..25b9f1e777c3 100644 --- a/pkg/module/wasm/sdk.go +++ b/pkg/module/wasm/sdk.go @@ -6,12 +6,11 @@ package wasm // TinyGo can build this package, but Go cannot. import ( + "encoding/json" "fmt" "reflect" "unsafe" - "github.com/mailru/easyjson" - "github.com/aquasecurity/trivy/pkg/module/api" "github.com/aquasecurity/trivy/pkg/module/serialize" ) @@ -40,20 +39,16 @@ func Error(message string) { _error(ptr, size) } -//go:wasm-module env -//export debug +//go:wasmimport env debug func _debug(ptr uint32, size uint32) -//go:wasm-module env -//export info +//go:wasmimport env info func _info(ptr uint32, size uint32) -//go:wasm-module env -//export warn +//go:wasmimport env warn func _warn(ptr uint32, size uint32) -//go:wasm-module env -//export error +//go:wasmimport env error func _error(ptr uint32, size uint32) var module api.Module @@ -134,8 +129,8 @@ func _post_scan(ptr, size uint32) uint64 { return marshal(results) } -func marshal(v easyjson.Marshaler) uint64 { - b, err := easyjson.Marshal(v) +func marshal(v any) uint64 { + b, err := json.Marshal(v) if err != nil { Error(fmt.Sprintf("marshal error: %s", err)) return 0 @@ -145,14 +140,14 @@ func marshal(v easyjson.Marshaler) uint64 { return (uint64(p) << uint64(32)) | uint64(len(b)) } -func unmarshal(ptr, size uint32, v easyjson.Unmarshaler) error { +func unmarshal(ptr, size uint32, v any) error { var b []byte s := (*reflect.SliceHeader)(unsafe.Pointer(&b)) s.Len = uintptr(size) s.Cap = uintptr(size) s.Data = uintptr(ptr) - if err := easyjson.Unmarshal(b, v); err != nil { + if err := json.Unmarshal(b, v); err != nil { return fmt.Errorf("unmarshal error: %s", err) }