Skip to content

Commit 0fd1875

Browse files
authored
fixes bad json parsing #547 (#548)
* fixes bad json parsing #547 * lint fix
1 parent 54f0b29 commit 0fd1875

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/kics/service.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package kics
22

33
import (
44
"context"
5+
"encoding/json"
56
"io"
67
"io/ioutil"
78

@@ -11,6 +12,7 @@ import (
1112
"github.com/Checkmarx/kics/pkg/source"
1213
"github.com/google/uuid"
1314
"github.com/pkg/errors"
15+
"github.com/rs/zerolog/log"
1416
)
1517

1618
type SourceProvider interface {
@@ -57,6 +59,12 @@ func (s *Service) StartScan(ctx context.Context, scanID string) error {
5759
}
5860

5961
for _, document := range documents {
62+
_, err = json.Marshal(document)
63+
if err != nil {
64+
log.Err(err).Msgf("failed to marshal document %s", document)
65+
continue
66+
}
67+
6068
file := model.FileMetadata{
6169
ID: uuid.New().String(),
6270
ScanID: scanID,

0 commit comments

Comments
 (0)