@@ -45,13 +45,13 @@ func init() {
4545// provided protobom Document with results from ClearlyDefined Warnings and
4646// updates are printed to stdout. TODO: Update to use a provided io.Writer or
4747// logger, also to use provided http client/transport and context.
48- func Do (ctx context.Context , s * sbom.Document ) error {
48+ func Do (ctx context.Context , s * sbom.Document , minScore int ) error {
4949 coords := CoordList (s )
5050 defs , err := getDefs (ctx , coords )
5151 if err != nil {
5252 return err
5353 }
54- updateLicenses (s , defs )
54+ updateLicenses (s , defs , minScore )
5555 return nil
5656}
5757
@@ -121,13 +121,13 @@ func getDefsFromService(ctx context.Context, coords []string) (map[string]*cd.De
121121 return defs , nil
122122}
123123
124- func updateLicenses (s * sbom.Document , defs map [string ]* cd.Definition ) {
124+ func updateLicenses (s * sbom.Document , defs map [string ]* cd.Definition , minScore int ) {
125125 for _ , node := range s .GetNodeList ().GetNodes () {
126- updateNode (node , defs )
126+ updateNode (node , defs , minScore )
127127 }
128128}
129129
130- func updateNode (n * sbom.Node , defs map [string ]* cd.Definition ) {
130+ func updateNode (n * sbom.Node , defs map [string ]* cd.Definition , minScore int ) {
131131 p := n .GetIdentifiers ()[int32 (sbom .SoftwareIdentifierType_PURL )]
132132 if p == "" {
133133 return
@@ -145,7 +145,7 @@ func updateNode(n *sbom.Node, defs map[string]*cd.Definition) {
145145 }
146146 old := strings .Join (n .GetLicenses (), " AND " )
147147 new := d .Licensed .Declared
148- if old != new {
148+ if old != new && d . Scores . Effective >= minScore {
149149 fmt .Printf ("Update Declared License\n " )
150150 fmt .Printf ("Name: %v\t Version: %v\n " , n .GetName (), n .GetVersion ())
151151 fmt .Printf ("\t \t \t \t SBOM License: %q\t CD License: %q\n " , old , new )
@@ -154,7 +154,7 @@ func updateNode(n *sbom.Node, defs map[string]*cd.Definition) {
154154
155155 oldDisc := n .GetLicenseConcluded ()
156156 newDisc := strings .Join (d .Licensed .Facets .Core .Discovered .Expressions , " AND " )
157- if oldDisc != newDisc {
157+ if oldDisc != newDisc && d . Scores . Effective >= minScore {
158158 fmt .Printf ("Update Discovered License\n " )
159159 fmt .Printf ("Name: %v\t Version: %v\n " , n .GetName (), n .GetVersion ())
160160 fmt .Printf ("\t \t \t \t SBOM License: %q\t CD License: %q\n " , oldDisc , newDisc )
0 commit comments