@@ -72,16 +72,15 @@ the environment: https://go.dev/ref/mod#module-cache`,
7272 // [proxy]: https://go.dev/ref/mod#module-proxy
7373 // [replace]: https://go.dev/ref/mod#go-mod-file-replace
7474 modules = slices .DeleteFunc (modules , func (s string ) bool {
75- return strings .HasPrefix (s , "git.crunchydata.com/" ) ||
76- strings .HasPrefix (s , "github.com/crunchydata/" )
75+ return strings .HasPrefix (s , "github.com/crunchydata/" )
7776 })
7877
7978 // Download modules to the Go module cache.
8079 directories := downloadModules (ctx , modules ... )
8180
8281 // Gather license files from every module into the target directory.
8382 for module , directory := range directories {
84- for _ , license := range findLicenses (ctx , directory ) {
83+ for _ , license := range findLicenses (directory ) {
8584 relative := module + strings .TrimPrefix (license , directory )
8685 destination := filepath .Join (flags .Arg (0 ), relative )
8786
@@ -95,9 +94,12 @@ the environment: https://go.dev/ref/mod#module-cache`,
9594 data , err = os .ReadFile (license )
9695 }
9796 if err == nil {
97+ //nolint:gosec // gosec warns on permissions more open than 600
98+ // but we need these licenses to be readable by all
9899 err = os .WriteFile (destination , data , 0o644 )
99100 }
100101 if err == nil {
102+ //nolint:forbidigo // This is an intentional print to console to inform the user
101103 fmt .Println (license , "=>" , destination )
102104 }
103105 if err != nil {
@@ -113,6 +115,7 @@ func downloadModules(ctx context.Context, modules ...string) map[string]string {
113115
114116 // Download modules and read their details into a series of JSON objects.
115117 // - https://go.dev/ref/mod#go-mod-download
118+ //nolint:gosec // Suppressing unnecessary warning re: potentially tainted inputs (G204)
116119 cmd := exec .CommandContext (ctx , os .Getenv ("GO" ), append ([]string {"mod" , "download" , "-json" }, modules ... )... )
117120 if cmd .Path == "" {
118121 cmd .Path , cmd .Err = exec .LookPath ("go" )
@@ -132,7 +135,11 @@ func downloadModules(ctx context.Context, modules ...string) map[string]string {
132135 // - https://go.dev/ref/mod#module-cache
133136 // - https://go.dev/ref/mod#module-path
134137 for {
135- var module struct { Path , Version , Dir string }
138+ var module struct {
139+ Path string `json:"path,omitempty"`
140+ Version string `json:"version,omitempty"`
141+ Dir string `json:"dir,omitempty"`
142+ }
136143 err := decoder .Decode (& module )
137144
138145 if err == nil {
@@ -150,7 +157,7 @@ func downloadModules(ctx context.Context, modules ...string) map[string]string {
150157 return results
151158}
152159
153- func findLicenses (ctx context. Context , directory string ) []string {
160+ func findLicenses (directory string ) []string {
154161 var results []string
155162
156163 // Syft maintains a list of license filenames that began as a list maintained by
@@ -188,6 +195,7 @@ func identifyModules(ctx context.Context, executables ...string) []string {
188195
189196 // Use `go version -m` to read the embedded module information as a text table.
190197 // - https://go.dev/ref/mod#go-version-m
198+ //nolint:gosec // Suppressing unnecessary warning re: potentially tainted inputs (G204)
191199 cmd := exec .CommandContext (ctx , os .Getenv ("GO" ), append ([]string {"version" , "-m" }, executables ... )... )
192200 if cmd .Path == "" {
193201 cmd .Path , cmd .Err = exec .LookPath ("go" )
0 commit comments