-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dismiss stale reviews when reviewing PRs with vulnerable dependencies
When the user accepts mediator's suggestions on PRs that container vulnerable dependencies, we need to re-review the PR. This patch dismisses the earlier review and adds a new one, either just commenting that no vulnerable packages were found or listing the remainign vulnerabilities. Also moves the package review code behind an interface that will be used later to just add comments and optionally set commit status to prevent merge with vulnerable commits. Fixes: #914
- Loading branch information
Showing
6 changed files
with
223 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2023 Stacklok, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.role/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package vulncheck provides the vulnerability check evaluator | ||
package vulncheck | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1" | ||
ghclient "github.com/stacklok/mediator/pkg/providers/github" | ||
) | ||
|
||
type prStatusHandler interface { | ||
trackVulnerableDep( | ||
ctx context.Context, | ||
dep *pb.PrDependencies_ContextualDependency, | ||
patch patchFormatter, | ||
) error | ||
submit(ctx context.Context) error | ||
} | ||
|
||
func newPrStatusHandler(action action, pr *pb.PullRequest, client ghclient.RestAPI) (prStatusHandler, error) { | ||
switch action { | ||
case actionRejectPr: | ||
return newReviewPrHandler(pr, client) | ||
default: | ||
return nil, fmt.Errorf("unknown action: %s", action) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters