forked from aquasecurity/trivy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(spdx): use the
hasExtractedLicensingInfos
field for licenses th…
…at are not listed in the SPDX (aquasecurity#8077)
- Loading branch information
1 parent
715575d
commit aec8885
Showing
11 changed files
with
637 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: SPDX licenses cron | ||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' # every Sunday at 00:00 | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Check if SPDX exceptions | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4.1.6 | ||
|
||
- name: Check if SPDX exceptions are up-to-date | ||
run: | | ||
mage spdx:updateLicenseExceptions | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "Run 'mage spdx:updateLicenseExceptions' and push it" | ||
exit 1 | ||
fi | ||
- name: Microsoft Teams Notification | ||
## Until the PR with the fix for the AdaptivCard version is merged yet | ||
## https://github.com/Skitionek/notify-microsoft-teams/pull/96 | ||
## Use the aquasecurity fork | ||
uses: aquasecurity/notify-microsoft-teams@master | ||
if: failure() | ||
with: | ||
webhook_url: ${{ secrets.TRIVY_MSTEAMS_WEBHOOK }} | ||
needs: ${{ toJson(needs) }} | ||
job: ${{ toJson(job) }} | ||
steps: ${{ toJson(steps) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//go:build mage_spdx | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"os" | ||
"path/filepath" | ||
"sort" | ||
|
||
"github.com/samber/lo" | ||
"golang.org/x/xerrors" | ||
|
||
"github.com/aquasecurity/trivy/pkg/downloader" | ||
"github.com/aquasecurity/trivy/pkg/log" | ||
) | ||
|
||
const ( | ||
exceptionFileName = "exceptions.json" | ||
exceptionDir = "./pkg/licensing/expression" | ||
exceptionURL = "https://spdx.org/licenses/exceptions.json" | ||
) | ||
|
||
type Exceptions struct { | ||
Exceptions []Exception `json:"exceptions"` | ||
} | ||
|
||
type Exception struct { | ||
ID string `json:"licenseExceptionId"` | ||
} | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
log.Fatal("Fatal error", log.Err(err)) | ||
} | ||
|
||
} | ||
|
||
// run downloads exceptions.json file, takes only IDs and saves into `expression` package. | ||
func run() error { | ||
tmpDir, err := downloader.DownloadToTempDir(context.Background(), exceptionURL, downloader.Options{}) | ||
if err != nil { | ||
return xerrors.Errorf("unable to download exceptions.json file: %w", err) | ||
} | ||
tmpFile, err := os.ReadFile(filepath.Join(tmpDir, exceptionFileName)) | ||
if err != nil { | ||
return xerrors.Errorf("unable to read exceptions.json file: %w", err) | ||
} | ||
|
||
exceptions := Exceptions{} | ||
if err = json.Unmarshal(tmpFile, &exceptions); err != nil { | ||
return xerrors.Errorf("unable to unmarshal exceptions.json file: %w", err) | ||
} | ||
|
||
exs := lo.Map(exceptions.Exceptions, func(ex Exception, _ int) string { | ||
return ex.ID | ||
}) | ||
sort.Strings(exs) | ||
|
||
exceptionFile := filepath.Join(exceptionDir, exceptionFileName) | ||
f, err := os.Create(exceptionFile) | ||
if err != nil { | ||
return xerrors.Errorf("unable to create file %s: %w", exceptionFile, err) | ||
} | ||
defer f.Close() | ||
|
||
e, err := json.Marshal(exs) | ||
if err != nil { | ||
return xerrors.Errorf("unable to marshal exceptions list: %w", err) | ||
} | ||
|
||
if _, err = f.Write(e); err != nil { | ||
return xerrors.Errorf("unable to write exceptions list: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["389-exception","Asterisk-exception","Asterisk-linking-protocols-exception","Autoconf-exception-2.0","Autoconf-exception-3.0","Autoconf-exception-generic","Autoconf-exception-generic-3.0","Autoconf-exception-macro","Bison-exception-1.24","Bison-exception-2.2","Bootloader-exception","CGAL-linking-exception","CLISP-exception-2.0","Classpath-exception-2.0","DigiRule-FOSS-exception","FLTK-exception","Fawkes-Runtime-exception","Font-exception-2.0","GCC-exception-2.0","GCC-exception-2.0-note","GCC-exception-3.1","GNAT-exception","GNOME-examples-exception","GNU-compiler-exception","GPL-3.0-389-ds-base-exception","GPL-3.0-interface-exception","GPL-3.0-linking-exception","GPL-3.0-linking-source-exception","GPL-CC-1.0","GStreamer-exception-2005","GStreamer-exception-2008","Gmsh-exception","Independent-modules-exception","KiCad-libraries-exception","LGPL-3.0-linking-exception","LLGPL","LLVM-exception","LZMA-exception","Libtool-exception","Linux-syscall-note","Nokia-Qt-exception-1.1","OCCT-exception-1.0","OCaml-LGPL-linking-exception","OpenJDK-assembly-exception-1.0","PCRE2-exception","PS-or-PDF-font-exception-20170817","QPL-1.0-INRIA-2004-exception","Qt-GPL-exception-1.0","Qt-LGPL-exception-1.1","Qwt-exception-1.0","RRDtool-FLOSS-exception-2.0","SANE-exception","SHL-2.0","SHL-2.1","SWI-exception","Swift-exception","Texinfo-exception","UBDL-exception","Universal-FOSS-exception-1.0","WxWindows-exception-3.1","cryptsetup-OpenSSL-exception","eCos-exception-2.0","erlang-otp-linking-exception","fmt-exception","freertos-exception-2.0","gnu-javamail-exception","harbour-exception","i2p-gpl-java-exception","libpri-OpenH323-exception","mif-exception","mxml-exception","openvpn-openssl-exception","romic-exception","stunnel-exception","u-boot-exception-2.0","vsftpd-openssl-exception","x11vnc-openssl-exception"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.