@@ -206,7 +206,13 @@ func TestUnifiedFindingPresenter_CliOutput(t *testing.T) {
206206 var p testapi.Problem
207207 err := p .FromSnykLicenseProblem (testapi.SnykLicenseProblem {
208208 Id : licProblemID ,
209- License : string (testapi .SnykLicense ),
209+ License : "LGPL-3.0" ,
210+ Instructions : []testapi.SnykvulndbLicenseInstructions {
211+ {
212+ License : "LGPL-3.0" ,
213+ Content : "This license requires source code disclosure when modified." ,
214+ },
215+ },
210216 })
211217 assert .NoError (t , err )
212218 return []testapi.Problem {p }
@@ -249,6 +255,69 @@ func TestUnifiedFindingPresenter_CliOutput(t *testing.T) {
249255 snaps .MatchSnapshot (t , buffer .String ())
250256 })
251257
258+ t .Run ("snapshot test with multiple license instructions" , func (t * testing.T ) {
259+ config := configuration .New ()
260+ buffer := & bytes.Buffer {}
261+ lipgloss .SetColorProfile (termenv .Ascii )
262+
263+ // Create a dual-licensed package with instructions for each license
264+ dualLicenseFinding := testapi.FindingData {
265+ Id : util .Ptr (uuid .MustParse ("44444444-4444-4444-4444-444444444444" )),
266+ Type : util .Ptr (testapi .Findings ),
267+ Attributes : & testapi.FindingAttributes {
268+ Title : "GPL-3.0 OR MIT license" ,
269+ Rating : testapi.Rating {
270+ Severity : testapi .Severity ("high" ),
271+ },
272+ Problems : func () []testapi.Problem {
273+ var p testapi.Problem
274+ err := p .FromSnykLicenseProblem (testapi.SnykLicenseProblem {
275+ Id : "snyk:lic:npm:dual-pkg:GPL-3.0-OR-MIT" ,
276+ License : "GPL-3.0 OR MIT" ,
277+ Instructions : []testapi.SnykvulndbLicenseInstructions {
278+ {
279+ License : "GPL-3.0" ,
280+ Content : "Strong copyleft license. Requires source code disclosure for modifications." ,
281+ },
282+ {
283+ License : "MIT" ,
284+ Content : "Permissive license. Must include original copyright notice." ,
285+ },
286+ },
287+ })
288+ assert .NoError (t , err )
289+ return []testapi.Problem {p }
290+ }(),
291+ },
292+ }
293+
294+ projectResult := & presenters.UnifiedProjectResult {
295+ Findings : []testapi.FindingData {dualLicenseFinding },
296+ Summary : & json_schemas.TestSummary {
297+ Type : "open-source" ,
298+ Path : "test/path" ,
299+ SeverityOrderAsc : []string {"low" , "medium" , "high" , "critical" },
300+ Results : []json_schemas.TestSummaryResult {
301+ {
302+ Severity : "high" ,
303+ Open : 1 ,
304+ Total : 1 ,
305+ },
306+ },
307+ },
308+ }
309+
310+ presenter := presenters .NewUnifiedFindingsRenderer (
311+ []* presenters.UnifiedProjectResult {projectResult },
312+ config ,
313+ buffer ,
314+ )
315+
316+ err := presenter .RenderTemplate (presenters .DefaultTemplateFiles , presenters .DefaultMimeType )
317+ assert .NoError (t , err )
318+ snaps .MatchSnapshot (t , buffer .String ())
319+ })
320+
252321 // summary shows security only when there are vulnerability findings and no license findings
253322 t .Run ("summary shows only security when no license issues" , func (t * testing.T ) {
254323 config := configuration .New ()
@@ -437,3 +506,53 @@ func TestUnifiedFindingPresenter_Ignored_ShownInIgnoredSectionWithBang(t *testin
437506 // Ignored entries appear with ! and IGNORED label
438507 assert .Contains (t , out , " ! [IGNORED] [MEDIUM] Ignored Suppression Finding" )
439508}
509+
510+ // TestUnifiedFindingPresenter_LicenseInstructions verifies that license instructions appear in output.
511+ func TestUnifiedFindingPresenter_LicenseInstructions (t * testing.T ) {
512+ config := configuration .New ()
513+ buffer := & bytes.Buffer {}
514+ lipgloss .SetColorProfile (termenv .Ascii )
515+
516+ licProblem := testapi.SnykLicenseProblem {
517+ Id : "snyk:lic:npm:web3-core:LGPL-3.0" ,
518+ License : "LGPL-3.0" ,
519+ Instructions : []testapi.SnykvulndbLicenseInstructions {
520+ {
521+ License : "LGPL-3.0" ,
522+ Content : "This license requires you to disclose source code changes." ,
523+ },
524+ },
525+ }
526+
527+ var p testapi.Problem
528+ err := p .FromSnykLicenseProblem (licProblem )
529+ assert .NoError (t , err )
530+
531+ licenseFinding := testapi.FindingData {
532+ Id : util .Ptr (uuid .New ()),
533+ Type : util .Ptr (testapi .Findings ),
534+ Attributes : & testapi.FindingAttributes {
535+ Title : "LGPL-3.0 license" ,
536+ Rating : testapi.Rating {Severity : testapi .Severity ("medium" )},
537+ Problems : []testapi.Problem {p },
538+ },
539+ }
540+
541+ projectResult := & presenters.UnifiedProjectResult {
542+ Findings : []testapi.FindingData {licenseFinding },
543+ Summary : & json_schemas.TestSummary {
544+ Type : "open-source" ,
545+ Path : "test/path" ,
546+ SeverityOrderAsc : []string {"low" , "medium" , "high" , "critical" },
547+ Results : []json_schemas.TestSummaryResult {{Severity : "medium" , Open : 1 , Total : 1 }},
548+ },
549+ }
550+
551+ presenter := presenters .NewUnifiedFindingsRenderer ([]* presenters.UnifiedProjectResult {projectResult }, config , buffer )
552+ err = presenter .RenderTemplate (presenters .DefaultTemplateFiles , presenters .DefaultMimeType )
553+ assert .NoError (t , err )
554+
555+ out := buffer .String ()
556+ assert .Contains (t , out , "Instructions:" )
557+ assert .Contains (t , out , "This license requires you to disclose source code changes." )
558+ }
0 commit comments