Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External sources configuration #1158

Merged
merged 1 commit into from
Aug 22, 2022
Merged

Conversation

mdeicas
Copy link
Contributor

@mdeicas mdeicas commented Aug 11, 2022

The use of external sources is new to Syft, and they must be managed thoughtfully (i.e. configurability, clear to users what has been used and how). This PR proposes a way to do so. It is motivated by #1159 and #1115.

It adds a new external sources configuration, an additional function that catalogers must implement, and a cli flag to shut off the use of external sources. This approach assumes that external sources will only come into Syft through catalogers.

When catalogers are implemented that use external sources, they must add their own configuration options to the application-wide external sources configuration created here.

Signed-off-by: Marco Deicas <mdeicas@google.com>
Copy link

@lumjjb lumjjb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@spiffcs spiffcs merged commit 1329688 into anchore:main Aug 22, 2022
@spiffcs
Copy link
Contributor

spiffcs commented Aug 22, 2022

Brilliant! I'll get this one merged in first. Thanks a million!

Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I neglected get this in on time! @spiffcs can you tackle follow ups to this?

import "github.com/spf13/viper"

type ExternalSources struct {
ExternalSourcesEnabled bool `yaml:"external-sources-enabled" json:"external-sources-enabled" mapstructure:"external-sources-enabled"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ExternalSourcesEnabled bool `yaml:"external-sources-enabled" json:"external-sources-enabled" mapstructure:"external-sources-enabled"`
Enabled bool `yaml:"enabled" json:"enabled" mapstructure:"enabled"`

}

func (e ExternalSources) loadDefaultValues(v *viper.Viper) {
v.SetDefault("external-sources-enabled", false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
v.SetDefault("external-sources-enabled", false)
v.SetDefault("external-sources.enabled", false)

@@ -41,6 +41,8 @@ type Cataloger interface {
Name() string
// Catalog is given an object to resolve file references and content, this function returns any discovered Packages after analyzing the catalog source.
Catalog(resolver source.FileResolver) ([]pkg.Package, []artifact.Relationship, error)
// UsesExternalSources returns if the cataloger uses external sources, such as querying a database
UsesExternalSources() bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to make this part of the cataloger interface, instead we should be passing in indication of this configuration to cataloger constructors, and constructors that return nil instances and nil error are discarded from the list of package catalogers.

spiffcs added a commit to scothis/syft that referenced this pull request Aug 24, 2022
* main:
  Update syft bootstrap tools to latest versions. (anchore#1171)
  Fix update-bootstrap-tools workflow (anchore#1170)
  workflow to create automated PRs to update bootstrap tools (anchore#1167)
  feat: add support for licenses in package-lock json v2 (anchore#1164)
  External sources configuration (anchore#1158)
  feat: add support for pnpm (anchore#1166)
  Prevent symlinks causing duplicate package-file relationships (anchore#1168)
  Associate node package licenses from node_modules (anchore#1152)
  Give the contributing guide a substantial rework (anchore#1155)

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
spiffcs added a commit that referenced this pull request Aug 25, 2022
* main:
  Update syft bootstrap tools to latest versions. (#1176)
  enhance development support on macOS ARM (#1163)
  Capture if a node module is private (#1161)
  Find version numbers from jars with different naming conventions (#1174)
  Update syft bootstrap tools to latest versions. (#1171)
  Fix update-bootstrap-tools workflow (#1170)
  workflow to create automated PRs to update bootstrap tools (#1167)
  feat: add support for licenses in package-lock json v2 (#1164)
  External sources configuration (#1158)
  feat: add support for pnpm (#1166)
  Prevent symlinks causing duplicate package-file relationships (#1168)
  Associate node package licenses from node_modules (#1152)
spiffcs added a commit that referenced this pull request Sep 1, 2022
spiffcs added a commit that referenced this pull request Sep 1, 2022
This reverts commit 1329688.

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
spiffcs added a commit that referenced this pull request Sep 1, 2022
reverted as functionality is to be merged with dev branch of kubecon draft
cpendery pushed a commit to cpendery/syft that referenced this pull request Sep 11, 2022
reverted as functionality is to be merged with dev branch of kubecon draft
spiffcs added a commit that referenced this pull request Sep 19, 2022
reverted as functionality is to be merged with dev branch of kubecon draft

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
aiwantaozi pushed a commit to aiwantaozi/syft that referenced this pull request Oct 20, 2022
aiwantaozi pushed a commit to aiwantaozi/syft that referenced this pull request Oct 20, 2022
reverted as functionality is to be merged with dev branch of kubecon draft
spiffcs added a commit that referenced this pull request Oct 21, 2022
reverted as functionality is to be merged with dev branch of kubecon draft

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
spiffcs added a commit that referenced this pull request Oct 21, 2022
reverted as functionality is to be merged with dev branch of kubecon draft

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
spiffcs pushed a commit that referenced this pull request Oct 25, 2022
spiffcs pushed a commit that referenced this pull request Oct 25, 2022
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
reverted as functionality is to be merged with dev branch of kubecon draft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants