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

     1  package javascript
     2  
     3  const npmBaseURL = "https://registry.npmjs.org"
     4  
     5  type CatalogerConfig struct {
     6  	// SearchRemoteLicenses enables querying the NPM registry API to retrieve license information for packages that are missing license data in their local metadata.
     7  	// app-config: javascript.search-remote-licenses
     8  	SearchRemoteLicenses bool `json:"search-remote-licenses" yaml:"search-remote-licenses" mapstructure:"search-remote-licenses"`
     9  	// NPMBaseURL specifies the base URL for the NPM registry API used when searching for remote license information.
    10  	// app-config: javascript.npm-base-url
    11  	NPMBaseURL string `json:"npm-base-url" yaml:"npm-base-url" mapstructure:"npm-base-url"`
    12  	// IncludeDevDependencies controls whether development dependencies should be included in the catalog results, in addition to production dependencies.
    13  	// app-config: javascript.include-dev-dependencies
    14  	IncludeDevDependencies bool `json:"include-dev-dependencies" yaml:"include-dev-dependencies" mapstructure:"include-dev-dependencies"`
    15  }
    16  
    17  func DefaultCatalogerConfig() CatalogerConfig {
    18  	return CatalogerConfig{
    19  		SearchRemoteLicenses: false,
    20  		NPMBaseURL:           npmBaseURL,
    21  	}
    22  }
    23  
    24  func (j CatalogerConfig) WithSearchRemoteLicenses(input bool) CatalogerConfig {
    25  	j.SearchRemoteLicenses = input
    26  	return j
    27  }
    28  
    29  func (j CatalogerConfig) WithNpmBaseURL(input string) CatalogerConfig {
    30  	if input != "" {
    31  		j.NPMBaseURL = input
    32  	}
    33  	return j
    34  }
    35  
    36  func (j CatalogerConfig) WithIncludeDevDependencies(input bool) CatalogerConfig {
    37  	j.IncludeDevDependencies = input
    38  	return j
    39  }