mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 23:46:35 +01:00
chore(deps): update Go version (#4773)
Signed-off-by: anchore-oss-update-bot <anchore-oss-update-bot@users.noreply.github.com> Co-authored-by: anchore-oss-update-bot <anchore-oss-update-bot@users.noreply.github.com>
This commit is contained in:
co-authored by
anchore-oss-update-bot
parent
26e87c7cd3
commit
5b58ec96b7
@@ -76,7 +76,7 @@ func TestGGUFCataloger(t *testing.T) {
|
||||
GGUFVersion: 3,
|
||||
TensorCount: 0,
|
||||
MetadataKeyValuesHash: "6e3d368066455ce4",
|
||||
RemainingKeyValues: map[string]interface{}{
|
||||
RemainingKeyValues: map[string]any{
|
||||
"general.some_random_kv": "foobar",
|
||||
},
|
||||
},
|
||||
@@ -113,7 +113,7 @@ func TestGGUFCataloger(t *testing.T) {
|
||||
GGUFVersion: 3,
|
||||
TensorCount: 0,
|
||||
MetadataKeyValuesHash: "9dc6f23591062a27",
|
||||
RemainingKeyValues: map[string]interface{}{
|
||||
RemainingKeyValues: map[string]any{
|
||||
"gpt2.context_length": "1024",
|
||||
"gpt2.embedding_length": uint32(768),
|
||||
},
|
||||
|
||||
@@ -46,8 +46,8 @@ func copyHeader(w io.Writer, r io.Reader) error {
|
||||
}
|
||||
|
||||
// Helper to convert gguf_parser metadata to simpler types
|
||||
func convertGGUFMetadataKVs(kvs gguf_parser.GGUFMetadataKVs) map[string]interface{} {
|
||||
result := make(map[string]interface{})
|
||||
func convertGGUFMetadataKVs(kvs gguf_parser.GGUFMetadataKVs) map[string]any {
|
||||
result := make(map[string]any)
|
||||
|
||||
for _, kv := range kvs {
|
||||
// Skip standard fields that are extracted separately
|
||||
|
||||
@@ -35,7 +35,7 @@ type testGGUFBuilder struct {
|
||||
type testKVPair struct {
|
||||
key string
|
||||
valueType uint32
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
func newTestGGUFBuilder() *testGGUFBuilder {
|
||||
|
||||
@@ -153,7 +153,7 @@ func newScanner(reader io.Reader) *bufio.Scanner {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
scanner.Buffer(bufScan, maxScannerCapacity)
|
||||
onDoubleLF := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
|
||||
for i := 0; i < len(data); i++ {
|
||||
for i := range data {
|
||||
if i > 0 && data[i-1] == '\n' && data[i] == '\n' {
|
||||
return i + 1, data[:i-1], nil
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func getLocation(path string, resolver file.Resolver) (file.Location, error) {
|
||||
|
||||
func parseDatabase(b *bufio.Scanner) (*parsedData, error) {
|
||||
var err error
|
||||
pkgFields := make(map[string]interface{})
|
||||
pkgFields := make(map[string]any)
|
||||
for b.Scan() {
|
||||
fields := strings.SplitN(b.Text(), "\n", 2)
|
||||
|
||||
@@ -213,12 +213,12 @@ func parseDatabase(b *bufio.Scanner) (*parsedData, error) {
|
||||
}
|
||||
pkgFields[key] = files
|
||||
case "backup":
|
||||
var backup []map[string]interface{}
|
||||
var backup []map[string]any
|
||||
for _, f := range strings.Split(value, "\n") {
|
||||
fields := strings.SplitN(f, "\t", 2)
|
||||
p := fmt.Sprintf("/%s", fields[0])
|
||||
if ok := ignoredFiles[p]; !ok {
|
||||
backup = append(backup, map[string]interface{}{
|
||||
backup = append(backup, map[string]any{
|
||||
"path": p,
|
||||
"digests": []file.Digest{{
|
||||
Algorithm: "md5",
|
||||
@@ -257,7 +257,7 @@ func processLibrarySpecs(value string) []string {
|
||||
return librarySpecs
|
||||
}
|
||||
|
||||
func parsePkgFiles(pkgFields map[string]interface{}) (*parsedData, error) {
|
||||
func parsePkgFiles(pkgFields map[string]any) (*parsedData, error) {
|
||||
var entry parsedData
|
||||
if err := mapstructure.Decode(pkgFields, &entry); err != nil {
|
||||
return nil, fmt.Errorf("unable to parse ALPM metadata: %w", err)
|
||||
@@ -292,7 +292,7 @@ func parseMtree(r io.Reader) ([]pkg.AlpmFileRecord, error) {
|
||||
for _, f := range specDh.Entries {
|
||||
var entry pkg.AlpmFileRecord
|
||||
entry.Digests = make([]file.Digest, 0)
|
||||
fileFields := make(map[string]interface{})
|
||||
fileFields := make(map[string]any)
|
||||
if ok := ignoredFiles[f.Name]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ func Test_CondaCataloger(t *testing.T) {
|
||||
name: "badly formatted conda meta json file",
|
||||
fixture: "testdata/conda-meta-bad-json",
|
||||
expectedPackages: nil,
|
||||
wantErr: func(t require.TestingT, err error, msgAndArgs ...interface{}) {
|
||||
wantErr: func(t require.TestingT, err error, msgAndArgs ...any) {
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "failed to parse conda-meta package file at conda-meta/package-1.2.3-pyhd8ed1ab_0.json")
|
||||
require.Contains(t, err.Error(), "invalid character")
|
||||
|
||||
@@ -194,8 +194,8 @@ func splitPkgList(pkgList string) (ret []string) {
|
||||
return ret
|
||||
}
|
||||
|
||||
func extractAllFields(reader *bufio.Reader) (map[string]interface{}, error) {
|
||||
dpkgFields := make(map[string]interface{})
|
||||
func extractAllFields(reader *bufio.Reader) (map[string]any, error) {
|
||||
dpkgFields := make(map[string]any)
|
||||
var key string
|
||||
|
||||
for {
|
||||
@@ -234,7 +234,7 @@ func extractAllFields(reader *bufio.Reader) (map[string]interface{}, error) {
|
||||
dpkgFields[key] = val
|
||||
default:
|
||||
// parse a new key
|
||||
var val interface{}
|
||||
var val any
|
||||
key, val, err = handleNewKeyValue(line)
|
||||
if err != nil {
|
||||
log.Tracef("parsing dpkg status: extracting key-value from line: %s err: %v", line, err)
|
||||
@@ -259,7 +259,7 @@ func extractSourceVersion(source string) (string, string) {
|
||||
}
|
||||
|
||||
// handleNewKeyValue parse a new key-value pair from the given unprocessed line
|
||||
func handleNewKeyValue(line string) (key string, val interface{}, err error) {
|
||||
func handleNewKeyValue(line string) (key string, val any, err error) {
|
||||
if i := strings.Index(line, ":"); i > 0 {
|
||||
key = strings.TrimSpace(line[0:i])
|
||||
// mapstruct cant handle "-"
|
||||
|
||||
@@ -339,7 +339,7 @@ func TestSourceVersionExtract(t *testing.T) {
|
||||
}
|
||||
|
||||
func requireAs(expected error) require.ErrorAssertionFunc {
|
||||
return func(t require.TestingT, err error, i ...interface{}) {
|
||||
return func(t require.TestingT, err error, i ...any) {
|
||||
require.ErrorAs(t, err, &expected)
|
||||
}
|
||||
}
|
||||
@@ -413,7 +413,7 @@ func Test_handleNewKeyValue(t *testing.T) {
|
||||
name string
|
||||
line string
|
||||
wantKey string
|
||||
wantVal interface{}
|
||||
wantVal any
|
||||
wantErr require.ErrorAssertionFunc
|
||||
}{
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type erlangNode struct {
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
var errSkipComments = errors.New("")
|
||||
@@ -39,7 +39,7 @@ func (e erlangNode) Get(index int) erlangNode {
|
||||
return erlangNode{}
|
||||
}
|
||||
|
||||
func node(value interface{}) erlangNode {
|
||||
func node(value any) erlangNode {
|
||||
return erlangNode{
|
||||
value: value,
|
||||
}
|
||||
|
||||
@@ -143,9 +143,9 @@ func replaceLicenseGroups(licenses []string, groups map[string][]string) []strin
|
||||
|
||||
result := make([]string, 0, len(licenses))
|
||||
for _, license := range licenses {
|
||||
if strings.HasPrefix(license, "@") {
|
||||
if after, ok := strings.CutPrefix(license, "@"); ok {
|
||||
// this is a license group...
|
||||
name := strings.TrimPrefix(license, "@")
|
||||
name := after
|
||||
if expandedLicenses, ok := groups[name]; ok {
|
||||
result = append(result, expandedLicenses...)
|
||||
} else {
|
||||
|
||||
@@ -346,7 +346,7 @@ func parseELFPTLoadOffsets(elfHeader []byte) []uint64 {
|
||||
phnum := binary.LittleEndian.Uint16(elfHeader[0x38:0x3a])
|
||||
|
||||
var offsets []uint64
|
||||
for i := uint16(0); i < phnum; i++ {
|
||||
for i := range phnum {
|
||||
phStart := phoff + uint64(i)*uint64(phentsize)
|
||||
if phStart+uint64(phentsize) > uint64(len(elfHeader)) {
|
||||
break
|
||||
@@ -499,10 +499,7 @@ func decompressLZMA(compressedData []byte, uncompressedSize uint32) ([]byte, err
|
||||
// it may be that the dictionary size was not considered properly in this code.
|
||||
const minDictSize = 64 * 1024 // 64KB minimum
|
||||
const maxDictSize = 128 * 1024 * 1024 // 128MB maximum
|
||||
dictSize := nextPowerOf2(uncompressedSize)
|
||||
if dictSize < minDictSize {
|
||||
dictSize = minDictSize
|
||||
}
|
||||
dictSize := max(nextPowerOf2(uncompressedSize), minDictSize)
|
||||
if dictSize > maxDictSize {
|
||||
dictSize = maxDictSize
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ func upstreamCandidates(m pkg.ApkDBEntry) (candidates []upstreamCandidate) {
|
||||
}
|
||||
|
||||
for prefix, typ := range prefixesToPackageType {
|
||||
if strings.HasPrefix(name, prefix) {
|
||||
t := strings.TrimPrefix(name, prefix)
|
||||
if after, ok0 := strings.CutPrefix(name, prefix); ok0 {
|
||||
t := after
|
||||
if t != "" {
|
||||
candidates = append(candidates, upstreamCandidate{Name: t, Type: typ})
|
||||
return candidates
|
||||
|
||||
@@ -260,8 +260,8 @@ func addEntryForNPMPackage(indexed *dictionary.Indexed, ref string, cpeItemName
|
||||
}
|
||||
|
||||
func phpExtensionPackageFromURLFragment(ref string) string {
|
||||
if strings.HasPrefix(ref, "package/") { // package/HTML_QuickForm/download
|
||||
ref = strings.TrimPrefix(ref, "package/")
|
||||
if after, ok := strings.CutPrefix(ref, "package/"); ok { // package/HTML_QuickForm/download
|
||||
ref = after
|
||||
components := strings.Split(ref, "/")
|
||||
|
||||
if len(components) < 1 {
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ func (c *NVDAPIClient) fetchDateRange(ctx context.Context, start, end time.Time)
|
||||
func (c *NVDAPIClient) fetchPage(ctx context.Context, startIndex int, start, end time.Time) (NVDProductsResponse, error) {
|
||||
var lastErr error
|
||||
|
||||
for attempt := 0; attempt < maxRetries; attempt++ {
|
||||
for attempt := range maxRetries {
|
||||
// wait for rate limiter
|
||||
if err := c.rateLimiter.Wait(ctx); err != nil {
|
||||
return NVDProductsResponse{}, fmt.Errorf("rate limiter error: %w", err)
|
||||
|
||||
@@ -33,7 +33,6 @@ func Test_IsLicenseFile(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
got := IsLicenseFile(tt.input)
|
||||
|
||||
@@ -206,7 +206,7 @@ func readDepsJSONAtOffset(r io.ReadSeeker, offset, size int64) (string, error) {
|
||||
|
||||
// findDepsJSONInManifest parses manifest entries to find deps.json (for V1 bundles or fallback)
|
||||
func findDepsJSONInManifest(r io.ReadSeeker, numFiles int32, majorVersion uint32) (string, error) {
|
||||
for i := int32(0); i < numFiles; i++ {
|
||||
for range numFiles {
|
||||
var offset, size int64
|
||||
|
||||
if err := binary.Read(r, binary.LittleEndian, &offset); err != nil {
|
||||
|
||||
@@ -422,7 +422,7 @@ func parseResourceDirectory(sec *extractedSection, dirs *u32set.Set, fields map[
|
||||
return fmt.Errorf("invalid number of entries in resource directory: %d", numEntries)
|
||||
}
|
||||
|
||||
for i := 0; i < numEntries; i++ {
|
||||
for i := range numEntries {
|
||||
var entry peImageResourceDirectoryEntry
|
||||
|
||||
entryOffset := offset + int64(binary.Size(directoryHeader)) + int64(i*binary.Size(entry))
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"slices"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -322,7 +323,7 @@ func (t *MetadataTracker) RecordCatalogerObservations(
|
||||
|
||||
// getMetadataTypeName returns the fully qualified type name of metadata (e.g., "pkg.ApkDBEntry").
|
||||
// extracts just the last package path segment to keep names concise.
|
||||
func getMetadataTypeName(metadata interface{}) string {
|
||||
func getMetadataTypeName(metadata any) string {
|
||||
if metadata == nil {
|
||||
return ""
|
||||
}
|
||||
@@ -361,7 +362,7 @@ func lastPathSegment(path string) string {
|
||||
// hasIntegrityHash checks if metadata contains an integrity hash field.
|
||||
// note: this uses a best-effort approach checking common field names.
|
||||
// DO NOT depend on these values in auto-generated capabilities definitions - use for test validation only.
|
||||
func hasIntegrityHash(metadata interface{}) bool {
|
||||
func hasIntegrityHash(metadata any) bool {
|
||||
v := dereferenceToStruct(metadata)
|
||||
if !v.IsValid() || v.Kind() != reflect.Struct {
|
||||
return false
|
||||
@@ -378,7 +379,7 @@ func hasIntegrityHash(metadata interface{}) bool {
|
||||
// hasFileDigests checks if metadata contains file records with digests.
|
||||
// note: uses a best-effort approach for detection.
|
||||
// DO NOT depend on these values in auto-generated capabilities definitions - use for test validation only.
|
||||
func hasFileDigests(metadata interface{}) bool {
|
||||
func hasFileDigests(metadata any) bool {
|
||||
v := dereferenceToStruct(metadata)
|
||||
if !v.IsValid() || v.Kind() != reflect.Struct {
|
||||
return false
|
||||
@@ -400,7 +401,7 @@ func hasFileDigests(metadata interface{}) bool {
|
||||
|
||||
// dereferenceToStruct handles pointer dereferencing and returns the underlying value.
|
||||
// returns an invalid value if the input is nil or not convertible to a struct.
|
||||
func dereferenceToStruct(v interface{}) reflect.Value {
|
||||
func dereferenceToStruct(v any) reflect.Value {
|
||||
if v == nil {
|
||||
return reflect.Value{}
|
||||
}
|
||||
@@ -460,12 +461,7 @@ func countDependencyRelationships(relationships []artifact.Relationship) int {
|
||||
|
||||
// contains checks if a string slice contains a specific string.
|
||||
func contains(slice []string, item string) bool {
|
||||
for _, s := range slice {
|
||||
if s == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(slice, item)
|
||||
}
|
||||
|
||||
// ===== Result Writing =====
|
||||
@@ -494,7 +490,7 @@ func (t *MetadataTracker) WriteResults() error {
|
||||
}
|
||||
|
||||
// writeJSONFile writes data as pretty-printed JSON to the specified path.
|
||||
func writeJSONFile(path string, data interface{}) error {
|
||||
func writeJSONFile(path string, data any) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"slices"
|
||||
"sort"
|
||||
|
||||
"github.com/scylladb/go-set/strset"
|
||||
@@ -43,10 +44,8 @@ func NewObservingResolver(resolver file.Resolver) *ObservingResolver {
|
||||
// ObservedPathQuery checks if a specific path pattern was queried.
|
||||
func (r *ObservingResolver) ObservedPathQuery(input string) bool {
|
||||
for _, queries := range r.pathQueries {
|
||||
for _, query := range queries {
|
||||
if query == input {
|
||||
return true
|
||||
}
|
||||
if slices.Contains(queries, input) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -498,7 +498,7 @@ func stringPackage(p pkg.Package) string {
|
||||
}
|
||||
|
||||
// getFunctionName extracts the function name from a function pointer using reflection
|
||||
func getFunctionName(fn interface{}) string {
|
||||
func getFunctionName(fn any) string {
|
||||
// get the function pointer
|
||||
ptr := reflect.ValueOf(fn).Pointer()
|
||||
|
||||
@@ -532,7 +532,7 @@ func getCatalogerName(_ *testing.T, cataloger pkg.Cataloger) string {
|
||||
|
||||
// getPackagePath extracts the package path from a function name
|
||||
// e.g., "github.com/anchore/syft/syft/pkg/cataloger/python.parseRequirementsTxt" -> "python"
|
||||
func getPackagePath(fn interface{}) string {
|
||||
func getPackagePath(fn any) string {
|
||||
ptr := reflect.ValueOf(fn).Pointer()
|
||||
funcForPC := runtime.FuncForPC(ptr)
|
||||
if funcForPC == nil {
|
||||
@@ -566,7 +566,7 @@ func getPackagePath(fn interface{}) string {
|
||||
func getPackagePathFromCataloger(_ pkg.Cataloger) string {
|
||||
// walk up the call stack to find the test file
|
||||
// we're looking for a file in the cataloger directory structure
|
||||
for i := 0; i < 10; i++ {
|
||||
for i := range 10 {
|
||||
_, file, _, ok := runtime.Caller(i)
|
||||
if !ok {
|
||||
break
|
||||
|
||||
@@ -395,7 +395,6 @@ func TestParseJar(t *testing.T) {
|
||||
|
||||
var parent *pkg.Package
|
||||
for _, a := range actual {
|
||||
a := a
|
||||
if strings.Contains(a.Name, "example-") {
|
||||
parent = &a
|
||||
}
|
||||
@@ -682,7 +681,6 @@ func TestParseNestedJar(t *testing.T) {
|
||||
|
||||
actualNameVersionPairSet := strset.New()
|
||||
for _, a := range actual {
|
||||
a := a
|
||||
key := makeKey(&a)
|
||||
actualNameVersionPairSet.Add(key)
|
||||
if !expectedNameVersionPairSet.Has(key) {
|
||||
@@ -701,7 +699,6 @@ func TestParseNestedJar(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, a := range actual {
|
||||
a := a
|
||||
actualKey := makeKey(&a)
|
||||
|
||||
metadata := a.Metadata.(pkg.JavaArchive)
|
||||
@@ -1493,7 +1490,7 @@ func Test_deterministicMatchingPomProperties(t *testing.T) {
|
||||
t.Run(test.fixture, func(t *testing.T) {
|
||||
fixturePath := generateJavaMetadataJarFixture(t, test.fixture, "jar")
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
func() {
|
||||
fixture, err := os.Open(fixturePath)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -58,14 +58,14 @@ func parseJavaManifest(path string, reader io.Reader) (*pkg.JavaManifest, error)
|
||||
}
|
||||
|
||||
// this is a new key-value pair
|
||||
idx := strings.Index(line, ":")
|
||||
if idx == -1 {
|
||||
before, after, ok := strings.Cut(line, ":")
|
||||
if !ok {
|
||||
log.Debugf("java manifest %q: unable to split java manifest key-value pairs: %q", path, line)
|
||||
continue
|
||||
}
|
||||
|
||||
key := strings.TrimSpace(line[0:idx])
|
||||
value := strings.TrimSpace(line[idx+1:])
|
||||
key := strings.TrimSpace(before)
|
||||
value := strings.TrimSpace(after)
|
||||
|
||||
if key == "" {
|
||||
// don't attempt to add new keys or sections unless there is a non-empty key
|
||||
|
||||
@@ -446,7 +446,7 @@ func Test_resolveLicenses(t *testing.T) {
|
||||
require.Equal(t, "child-one", child1.Name)
|
||||
|
||||
got := child1.Licenses.ToSlice()
|
||||
for i := 0; i < len(got); i++ {
|
||||
for i := range got {
|
||||
// ignore locations, just check license text
|
||||
(&got[i]).Locations = file.LocationSet{}
|
||||
}
|
||||
@@ -810,7 +810,7 @@ func expectedTransientPackageData() expected {
|
||||
}
|
||||
|
||||
pkgs := make([]pkg.Package, len(allPackages))
|
||||
for i := 0; i < len(allPackages); i++ {
|
||||
for i := range allPackages {
|
||||
pkgs[i] = *allPackages[i]
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/go-viper/mapstructure/v2"
|
||||
@@ -95,7 +96,7 @@ func (p *person) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
} else {
|
||||
// it's a map that may contain fields of various data types (not just strings)
|
||||
var fields map[string]interface{}
|
||||
var fields map[string]any
|
||||
if err := json.Unmarshal(b, &fields); err != nil {
|
||||
return fmt.Errorf("unable to parse package.json author: %w", err)
|
||||
}
|
||||
@@ -210,12 +211,7 @@ func licensesFromJSON(b []byte) ([]npmPackageLicense, error) {
|
||||
var filepathSeparator = regexp.MustCompile(`[\\/]`)
|
||||
|
||||
func pathContainsNodeModulesDirectory(p string) bool {
|
||||
for _, subPath := range filepathSeparator.Split(p, -1) {
|
||||
if subPath == "node_modules" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(filepathSeparator.Split(p, -1), "node_modules")
|
||||
}
|
||||
|
||||
func (p *people) UnmarshalJSON(b []byte) error {
|
||||
@@ -242,7 +238,7 @@ func (p *people) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
// Try to unmarshal as an array of objects
|
||||
var authorObjs []map[string]interface{}
|
||||
var authorObjs []map[string]any
|
||||
if err := json.Unmarshal(b, &authorObjs); err == nil {
|
||||
// Successfully parsed as an array of objects
|
||||
auths := make([]person, len(authorObjs))
|
||||
|
||||
@@ -41,7 +41,7 @@ type pnpmV6PackageEntry struct {
|
||||
|
||||
// pnpmV6LockYaml represents the structure of pnpm lockfiles for versions < 9.0.
|
||||
type pnpmV6LockYaml struct {
|
||||
Dependencies map[string]interface{} `yaml:"dependencies"`
|
||||
Dependencies map[string]any `yaml:"dependencies"`
|
||||
Packages map[string]pnpmV6PackageEntry `yaml:"packages"`
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ type pnpmV9PackageEntry struct {
|
||||
// pnpmV9LockYaml represents the structure of pnpm lockfiles for versions >= 9.0.
|
||||
type pnpmV9LockYaml struct {
|
||||
LockfileVersion string `yaml:"lockfileVersion"`
|
||||
Importers map[string]interface{} `yaml:"importers"` // Using interface{} for forward compatibility
|
||||
Importers map[string]any `yaml:"importers"` // Using interface{} for forward compatibility
|
||||
Packages map[string]pnpmV9PackageEntry `yaml:"packages"`
|
||||
Snapshots map[string]pnpmV9SnapshotEntry `yaml:"snapshots"`
|
||||
}
|
||||
@@ -214,11 +214,11 @@ func (a genericPnpmLockAdapter) parsePnpmLock(ctx context.Context, resolver file
|
||||
}
|
||||
|
||||
// parseVersionField extracts the version string from a dependency entry.
|
||||
func parseVersionField(name string, info interface{}) (string, error) {
|
||||
func parseVersionField(name string, info any) (string, error) {
|
||||
switch v := info.(type) {
|
||||
case string:
|
||||
return v, nil
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
if ver, ok := v["version"].(string); ok {
|
||||
// e.g., "1.2.3(react@17.0.0)" -> "1.2.3"
|
||||
return strings.SplitN(ver, "(", 2)[0], nil
|
||||
|
||||
@@ -14,7 +14,7 @@ type rockspec struct {
|
||||
|
||||
type rockspecNode struct {
|
||||
key string
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
func (r rockspecNode) Slice() []rockspecNode {
|
||||
|
||||
@@ -37,7 +37,7 @@ func newPackageForIndex(ctx context.Context, lr pythonLicenseResolver, name, ver
|
||||
return p
|
||||
}
|
||||
|
||||
func newPackageForIndexWithMetadata(ctx context.Context, lr pythonLicenseResolver, name, version string, metadata interface{}, locations ...file.Location) pkg.Package {
|
||||
func newPackageForIndexWithMetadata(ctx context.Context, lr pythonLicenseResolver, name, version string, metadata any, locations ...file.Location) pkg.Package {
|
||||
name = normalize(name)
|
||||
licenseSet := lr.getLicenses(ctx, name, version)
|
||||
|
||||
|
||||
@@ -111,9 +111,9 @@ func (rp requirementsParser) parseRequirementsTxt(ctx context.Context, _ file.Re
|
||||
}
|
||||
|
||||
// remove line continuations... smashes the file into a single line
|
||||
if strings.HasSuffix(line, "\\") {
|
||||
if before, ok := strings.CutSuffix(line, "\\"); ok {
|
||||
// this line is a continuation of the previous line
|
||||
lastLine += strings.TrimSuffix(line, "\\")
|
||||
lastLine += before
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -255,12 +255,12 @@ func removeTrailingComment(line string) string {
|
||||
}
|
||||
|
||||
func removeExtras(packageName string) string {
|
||||
start := strings.Index(packageName, "[")
|
||||
if start == -1 {
|
||||
before, _, ok := strings.Cut(packageName, "[")
|
||||
if !ok {
|
||||
return packageName
|
||||
}
|
||||
|
||||
return strings.TrimSpace(packageName[:start])
|
||||
return strings.TrimSpace(before)
|
||||
}
|
||||
|
||||
func parseExtras(packageName string) []string {
|
||||
|
||||
@@ -68,7 +68,7 @@ func processList(s string) []string {
|
||||
// parseGemSpecEntries parses the gemspec file and returns the packages and relationships found.
|
||||
func parseGemSpecEntries(ctx context.Context, resolver file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||
var pkgs []pkg.Package
|
||||
var fields = make(map[string]interface{})
|
||||
var fields = make(map[string]any)
|
||||
scanner := bufio.NewScanner(reader)
|
||||
|
||||
for scanner.Scan() {
|
||||
|
||||
@@ -61,7 +61,7 @@ type packageState struct {
|
||||
// parsePackageResolved is a parser for the contents of a Package.resolved file, which is generated by Xcode after it's resolved Swift Package Manger packages.
|
||||
func parsePackageResolved(_ context.Context, _ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||
dec := json.NewDecoder(reader)
|
||||
var packageResolvedData map[string]interface{}
|
||||
var packageResolvedData map[string]any
|
||||
for {
|
||||
if err := dec.Decode(&packageResolvedData); errors.Is(err, io.EOF) {
|
||||
break
|
||||
@@ -101,7 +101,7 @@ func parsePackageResolved(_ context.Context, _ file.Resolver, _ *generic.Environ
|
||||
return pkgs, nil, unknown.IfEmptyf(pkgs, "unable to determine packages")
|
||||
}
|
||||
|
||||
func pinsForVersion(data map[string]interface{}, version float64) ([]packagePin, error) {
|
||||
func pinsForVersion(data map[string]any, version float64) ([]packagePin, error) {
|
||||
var genericPins []packagePin
|
||||
switch version {
|
||||
case 1:
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
var _ generic.Parser = parsePodfileLock
|
||||
|
||||
type podfileLock struct {
|
||||
Pods []interface{} `yaml:"PODS"`
|
||||
Pods []any `yaml:"PODS"`
|
||||
Dependencies []string `yaml:"DEPENDENCIES"`
|
||||
SpecRepos map[string][]string `yaml:"SPEC REPOS"`
|
||||
SpecChecksums map[string]string `yaml:"SPEC CHECKSUMS"`
|
||||
@@ -36,7 +36,7 @@ func parsePodfileLock(_ context.Context, _ file.Resolver, _ *generic.Environment
|
||||
for _, podInterface := range podfile.Pods {
|
||||
var podBlob string
|
||||
switch v := podInterface.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
for k := range v {
|
||||
podBlob = k
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func parseWordpressPluginFiles(ctx context.Context, resolver file.Resolver, _ *g
|
||||
}
|
||||
|
||||
func extractFields(in string) map[string]any {
|
||||
var fields = make(map[string]interface{})
|
||||
var fields = make(map[string]any)
|
||||
|
||||
for field, pattern := range patterns {
|
||||
matchMap := internal.MatchNamedCaptureGroups(pattern, in)
|
||||
|
||||
Reference in New Issue
Block a user