| 35 | const Probe = "hasPermissiveLicense" |
| 36 | |
| 37 | func Run(raw *checker.RawResults) ([]finding.Finding, string, error) { |
| 38 | if raw == nil { |
| 39 | return nil, "", fmt.Errorf("%w: raw", uerror.ErrNil) |
| 40 | } |
| 41 | |
| 42 | if len(raw.LicenseResults.LicenseFiles) == 0 { |
| 43 | f, err := finding.NewWith(fs, Probe, |
| 44 | "project does not have a license file", nil, |
| 45 | finding.OutcomeFalse) |
| 46 | if err != nil { |
| 47 | return nil, Probe, fmt.Errorf("create finding: %w", err) |
| 48 | } |
| 49 | return []finding.Finding{*f}, Probe, nil |
| 50 | } |
| 51 | |
| 52 | for i := range raw.LicenseResults.LicenseFiles { |
| 53 | licenseFile := raw.LicenseResults.LicenseFiles[i] |
| 54 | spdxID := licenseFile.LicenseInformation.SpdxID |
| 55 | switch spdxID { |
| 56 | case |
| 57 | "Unlicense", |
| 58 | "Beerware", |
| 59 | "Apache-2.0", |
| 60 | "MIT", |
| 61 | "0BSD", |
| 62 | "BSD-1-Clause", |
| 63 | "BSD-2-Clause", |
| 64 | "BSD-3-Clause", |
| 65 | "BSD-4-Clause", |
| 66 | "APSL-1.0", |
| 67 | "APSL-1.1", |
| 68 | "APSL-1.2", |
| 69 | "APSL-2.0", |
| 70 | "ECL-1.0", |
| 71 | "ECL-2.0", |
| 72 | "EFL-1.0", |
| 73 | "EFL-2.0", |
| 74 | "Fair", |
| 75 | "FSFAP", |
| 76 | "WTFPL", |
| 77 | "Zlib", |
| 78 | "CNRI-Python", |
| 79 | "ISC", |
| 80 | "Intel": |
| 81 | // Store the license name in the msg |
| 82 | msg := licenseFile.LicenseInformation.Name |
| 83 | loc := &finding.Location{ |
| 84 | Type: licenseFile.File.Type, |
| 85 | Path: licenseFile.File.Path, |
| 86 | LineStart: &licenseFile.File.Offset, |
| 87 | LineEnd: &licenseFile.File.EndOffset, |
| 88 | Snippet: &licenseFile.File.Snippet, |
| 89 | } |
| 90 | f, err := finding.NewWith(fs, Probe, |
| 91 | msg, loc, |
| 92 | finding.OutcomeTrue) |
| 93 | if err != nil { |
| 94 | return nil, Probe, fmt.Errorf("create finding: %w", err) |