github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/python/config.go (about)

     1  package python
     2  
     3  const pypiBaseURL = "https://pypi.org/pypi"
     4  
     5  type CatalogerConfig struct {
     6  	// GuessUnpinnedRequirements attempts to infer package versions from version constraints when no explicit version is specified in requirements files.
     7  	// app-config: python.guess-unpinned-requirements
     8  	GuessUnpinnedRequirements bool `yaml:"guess-unpinned-requirements" json:"guess-unpinned-requirements" mapstructure:"guess-unpinned-requirements"`
     9  	// SearchRemoteLicenses enables querying the NPM registry API to retrieve license information for packages that are missing license data in their local metadata.
    10  	// app-config: python.search-remote-licenses
    11  	SearchRemoteLicenses bool `json:"search-remote-licenses" yaml:"search-remote-licenses" mapstructure:"search-remote-licenses"`
    12  	// PypiBaseURL specifies the base URL for the Pypi registry API used when searching for remote license information.
    13  	// app-config: python.pypi-base-url
    14  	PypiBaseURL string `json:"pypi-base-url" yaml:"pypi-base-url" mapstructure:"pypi-base-url"`
    15  }
    16  
    17  func DefaultCatalogerConfig() CatalogerConfig {
    18  	return CatalogerConfig{
    19  		GuessUnpinnedRequirements: false,
    20  		SearchRemoteLicenses:      false,
    21  		PypiBaseURL:               pypiBaseURL,
    22  	}
    23  }
    24  
    25  func (c CatalogerConfig) WithSearchRemoteLicenses(input bool) CatalogerConfig {
    26  	c.SearchRemoteLicenses = input
    27  	return c
    28  }
    29  
    30  func (c CatalogerConfig) WithGuessUnpinnedRequirements(input bool) CatalogerConfig {
    31  	c.GuessUnpinnedRequirements = input
    32  	return c
    33  }
    34  
    35  func (c CatalogerConfig) WithPypiBaseURL(input string) CatalogerConfig {
    36  	if input != "" {
    37  		c.PypiBaseURL = input
    38  	}
    39  	return c
    40  }