Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
* Test coverage
* Docs
* Raw results

Signed-off-by: Raghav Kaul <[email protected]>
  • Loading branch information
raghavkaul committed Dec 17, 2022
1 parent 3e91332 commit 75920f9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
16 changes: 16 additions & 0 deletions checks/evaluation/code_review_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ func TestCodeReview(t *testing.T) {
},
},
},
{
name: "Unreviewed human and bot changes",
expected: scut.TestReturn{
Score: checker.MinResultScore,
},
rawData: &checker.CodeReviewData{
DefaultBranchChangesets: []checker.Changeset{
{
Commits: []clients.Commit{{SHA: "a", Committer: clients.User{IsBot: true}}},
},
{
Commits: []clients.Commit{{SHA: "b"}},
},
},
},
},
{
name: "all human changesets reviewed, missing review on bot changeset",
expected: scut.TestReturn{
Expand Down
2 changes: 2 additions & 0 deletions clients/githubrepo/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ func commitsFrom(data *graphqlData, repoOwner, repoName string) ([]clients.Commi
string(pr.Repository.Name) != repoName {
continue
}
// ResourcePath: e.g., for dependabot, "/apps/dependabot", or "/apps/renovate"
// Path that can be appended to "https://github.com" for a Github resource
openedByBot := strings.HasPrefix(string(pr.Author.ResourcePath), "/apps/")
associatedPR = clients.PullRequest{
Number: int(pr.Number),
Expand Down
3 changes: 2 additions & 1 deletion docs/checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ malicious code (either as a malicious contributor or as an attacker who has
subverted a contributor's account), because a reviewer might detect the
subversion.

The check determines whether the most recent (~30) commits have a Github-approved review
The check determines whether the most recent changes (over the last ~30 commits) have
an approval on GitHub
or if the merger is different from the committer (implicit review). It also
performs a similar check for reviews using
[Prow](https://github.com/kubernetes/test-infra/tree/master/prow#readme) (labels
Expand Down
3 changes: 2 additions & 1 deletion docs/checks/internal/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ checks:
subverted a contributor's account), because a reviewer might detect the
subversion.
The check determines whether the most recent (~30) commits have a Github-approved review
The check determines whether the most recent changes (over the last ~30 commits) have
an approval on GitHub
or if the merger is different from the committer (implicit review). It also
performs a similar check for reviews using
[Prow](https://github.com/kubernetes/test-infra/tree/master/prow#readme) (labels
Expand Down
2 changes: 2 additions & 0 deletions pkg/json_raw_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type jsonUser struct {
// Companies refer to a claim by a user in their profile.
Companies []jsonCompany `json:"company,omitempty"`
NumContributions int `json:"NumContributions,omitempty"`
IsBot bool `json:"isBot"`
}

type jsonContributors struct {
Expand Down Expand Up @@ -555,6 +556,7 @@ func (r *jsonScorecardRawResult) setDefaultCommitData(changesets []checker.Chang
State: r.State,
Reviewer: jsonUser{
Login: r.Author.Login,
IsBot: r.Author.IsBot,
},
})
}
Expand Down

0 comments on commit 75920f9

Please sign in to comment.