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

feat: guided remediation dependency resolution #432

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michaelkedar
Copy link
Member

@michaelkedar michaelkedar commented Feb 4, 2025

Beginning the move of guided remediation from osv-scanner. Started with the dependency resolution & vulnerability detection.

I've also removed the DependencyClient interface, since we only really need the deps.dev resolve.Client (this will conflict with the change in #441, I'll fix it here after that's merged).

Trying to keep this stuff mostly self-contained in internal/guidedremediation as I work on it, but it I will have to move some things around eventually.

@michaelkedar michaelkedar force-pushed the guided-remediation/resolve branch from d50b67f to 47998ea Compare February 6, 2025 06:01
@michaelkedar michaelkedar changed the title feat: guided remediation dependency resolution (WIP) feat: guided remediation dependency resolution Feb 6, 2025
Comment on lines +32 to +34
// OSVRecord is a representation of an OSV record.
// TODO: replace with https://github.com/ossf/osv-schema/pull/333
type OSVRecord struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

I should be able to do this soon

Copy link
Collaborator

Choose a reason for hiding this comment

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

internally we have a policy that all TODOs need to have a bug attached - can you create a github issue for moving Guided Remediation and refer to it here?

@michaelkedar michaelkedar marked this pull request as ready for review February 6, 2025 06:17
Copy link
Collaborator

@erikvarga erikvarga left a comment

Choose a reason for hiding this comment

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

Initial pass, mostly just internal policy specific nits

)

// Temporarily internal while migration is in progress.
// Will need to be moved to publicly accessible location once external interface is created.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a TODO here and link to a github issue about moving guided remediation

Comment on lines +32 to +34
// OSVRecord is a representation of an OSV record.
// TODO: replace with https://github.com/ossf/osv-schema/pull/333
type OSVRecord struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

internally we have a policy that all TODOs need to have a bug attached - can you create a github issue for moving Guided Remediation and refer to it here?

} `yaml:"affected,omitempty"`
}

type OSVEvent struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add comment


type mockVulnerabilityMatcher []*matcher.OSVRecord

func (mvc mockVulnerabilityMatcher) MatchVulnerabilities(ctx context.Context, invs []*extractor.Inventory) ([][]*matcher.OSVRecord, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add comment

return mockVulnerabilityMatcher(vulns.Vulns)
}

// TODO: similar logic will need to be used elsewhere in guided remediation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add issue

// See the License for the specific language governing permissions and
// limitations under the License.

// Package resolution provides dependency graph resolution and vulnerability findings
Copy link
Collaborator

Choose a reason for hiding this comment

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

Our internal linters only expect this comment for just one of the package's files (so it'll complain if it's there for multiple files)

Copy link
Collaborator

@cuixq cuixq left a comment

Choose a reason for hiding this comment

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

LGTM - probably need to patch #442 (sorry for the trouble!)

Agree with Erik's suggestions on code styles. maybe we should find a way to implement the linter equivalent to the internal one, so we don't rely on manual review on these.

// See the License for the specific language governing permissions and
// limitations under the License.

// Package maven provides the manifest parsing and writing for the npm package.json format.
Copy link
Collaborator

Choose a reason for hiding this comment

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

npm

Comment on lines +27 to +28
mavenResolve "deps.dev/util/resolve/maven"
npmResolve "deps.dev/util/resolve/npm"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the convention is mavenresolve and npmresolve - though not sure whether the internal linter will alarm this or not...

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.

3 participants