func (rs *RepoScanner) Scan(ctx context.Context, layer *claircore.Layer) ([]*claircore.Repository, error) {
	defer trace.StartRegion(ctx, "RepoScanner.Scan").End()
	trace.Log(ctx, "layer", layer.Hash.String())
	log := zerolog.Ctx(ctx).With().
		Str("component", "python/RepoScanner.Scan").
		Str("version", rs.Version()).
		Str("layer", layer.Hash.String()).
		Logger()
	ctx = log.WithContext(ctx)
	log.Debug().Msg("start")
	defer log.Debug().Msg("done")
	if err := ctx.Err(); err != nil {
		return nil, err
	}

	r, err := layer.Reader()
	if err != nil {
		return nil, err
	}
	defer r.Close()
	rd, ok := r.(interface {
		io.ReadCloser
		io.Seeker
	})
	if !ok {
		return nil, errors.New("python: cannot seek on returned layer Reader")
	}

	tr := tar.NewReader(rd)
	var h *tar.Header
	for h, err = tr.Next(); err == nil; h, err = tr.Next() {
		n, err := filepath.Rel("/", filepath.Join("/", h.Name))
		if err != nil {
			return nil, err
		}
		switch {
		case h.Typeflag != tar.TypeReg:
			// Should we chase symlinks with the correct name?
			continue
		case strings.HasSuffix(n, `.egg-info/PKG-INFO`):
			log.Debug().Str("file", n).Msg("found egg")
		case strings.HasSuffix(n, `.dist-info/METADATA`):
			log.Debug().Str("file", n).Msg("found wheel")
		default:
			continue
		}

		// Just claim these came from pypi.
		return []*claircore.Repository{&Repository}, nil
	}
	if err != io.EOF {
		return nil, err
	}
	return nil, nil
}
// Scan attempts to find wheel or egg info directories and record the package
// information there.
//
// A return of (nil, nil) is expected if there's nothing found.
Scan attempts to find wheel or egg info directories and record the package
information there.

A return of (nil, nil) is expected if there's nothing found.
// Scan attempts to find wheel or egg info directories and record the package // information there . // // A return of ( nil nil ) is expected if there ' s nothing found .
func (rs *RepoScanner) Scan(ctx context.Context, layer *claircore.Layer) ([]*claircore.Repository, error) {
	defer trace.StartRegion(ctx, "RepoScanner.Scan").End()
	trace.Log(ctx, "layer", layer.Hash.String())
	log := zerolog.Ctx(ctx).With().
		Str("component", "python/RepoScanner.Scan").
		Str("version", rs.Version()).
		Str("layer", layer.Hash.String()).
		Logger()
	ctx = log.WithContext(ctx)
	log.Debug().Msg("start")
	defer log.Debug().Msg("done")
	if err := ctx.Err(); err != nil {
		return nil, err
	}
	r, err := layer.Reader()
	if err != nil {
		return nil, err
	}
	defer r.Close()
	rd, ok := r.(interface {
		io.ReadCloser
		io.Seeker
	})
	if !ok {
		return nil, errors.New("python: cannot seek on returned layer Reader")
	}
	tr := tar.NewReader(rd)
	var h *tar.Header
	for h, err = tr.Next(); err == nil; h, err = tr.Next() {
		n, err := filepath.Rel("/", filepath.Join("/", h.Name))
		if err != nil {
			return nil, err
		}
		switch {
		case h.Typeflag != tar.TypeReg:
			continue
		case strings.HasSuffix(n, `.egg-info/PKG-INFO`):
			log.Debug().Str("file", n).Msg("found egg")
		case strings.HasSuffix(n, `.dist-info/METADATA`):
			log.Debug().Str("file", n).Msg("found wheel")
		default:
			continue
		}
		return []*claircore.Repository{&Repository}, nil
	}
	if err != io.EOF {
		return nil, err
	}
	return nil, nil
}
func ( rs * RepoScanner ) Scan ( ctx context . Context , layer * claircore . Layer ) ( [ ] * claircore . Repository , error ) { defer trace . StartRegion ( ctx , " " ) . End ( ) trace . Log ( ctx , " " , layer . Hash . String ( ) ) log := zerolog . Ctx ( ctx ) . With ( ) . Str ( " " , " " ) . Str ( " " , rs . Version ( ) ) . Str ( " " , layer . Hash . String ( ) ) . Logger ( ) ctx = log . WithContext ( ctx ) log . Debug ( ) . Msg ( " " ) defer log . Debug ( ) . Msg ( " " ) if err := ctx . Err ( ) ; err != nil { return nil , err } r , err := layer . Reader ( ) if err != nil { return nil , err } defer r . Close ( ) rd , ok := r . ( interface { io . ReadCloser io . Seeker } ) if ! ok { return nil , errors . New ( " " ) } tr := tar . NewReader ( rd ) var h * tar . Header for h , err = tr . Next ( ) ; err == nil ; h , err = tr . Next ( ) { n , err := filepath . Rel ( " " , filepath . Join ( " " , h . Name ) ) if err != nil { return nil , err } switch { case h . Typeflag != tar . TypeReg : continue case strings . HasSuffix ( n , `.egg-info/PKG-INFO` ) : log . Debug ( ) . Str ( " " , n ) . Msg ( " " ) case strings . HasSuffix ( n , `.dist-info/METADATA` ) : log . Debug ( ) . Str ( " " , n ) . Msg ( " " ) default : continue } return [ ] * claircore . Repository { & Repository } , nil } if err != io . EOF { return nil , err } return nil , nil }
Scan attempts to find wheel or egg info directories and record the package
information there.
Scan attempts to find wheel or egg info directories and record the package information there .
// Should we chase symlinks with the correct name? // Just claim these came from pypi.