mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-17 11:57:12 +03:00
🐛 Fix linting issues (1 of n) (#348)
* Fix lint issues: whitespace linter * Fix lint issues: wrapcheck linter * Fix lint issues: errcheck linter * Fix lint issues: paralleltest linter * Fix lint issues: gocritic linter Most changes from this commit are from passing checker.CheckResult by reference and not by value. gocritic identified that as a huge parameter. gocritic also prefers regexp.MustCompile over Compile when the pattern is a const
This commit is contained in:
parent
df27afd3b3
commit
06993b72ce
@ -134,7 +134,7 @@ Each check is currently just a function of type `CheckFn`.
|
|||||||
The signature is:
|
The signature is:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
type CheckFn func(c.Checker) CheckResult
|
type CheckFn func(*c.Checker) CheckResult
|
||||||
```
|
```
|
||||||
|
|
||||||
Checks are registered in an init function:
|
Checks are registered in an init function:
|
||||||
|
@ -25,7 +25,7 @@ type Runner struct {
|
|||||||
CheckRequest CheckRequest
|
CheckRequest CheckRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
type CheckFn func(CheckRequest) CheckResult
|
type CheckFn func(*CheckRequest) CheckResult
|
||||||
|
|
||||||
type CheckNameToFnMap map[string]CheckFn
|
type CheckNameToFnMap map[string]CheckFn
|
||||||
|
|
||||||
@ -44,13 +44,12 @@ func (r *Runner) Run(f CheckFn) CheckResult {
|
|||||||
checkRequest := r.CheckRequest
|
checkRequest := r.CheckRequest
|
||||||
l = logger{}
|
l = logger{}
|
||||||
checkRequest.Logf = l.Logf
|
checkRequest.Logf = l.Logf
|
||||||
res = f(checkRequest)
|
res = f(&checkRequest)
|
||||||
if res.ShouldRetry && !strings.Contains(res.Error.Error(), "invalid header field value") {
|
if res.ShouldRetry && !strings.Contains(res.Error.Error(), "invalid header field value") {
|
||||||
checkRequest.Logf("error, retrying: %s", res.Error)
|
checkRequest.Logf("error, retrying: %s", res.Error)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
res.Details = l.messages
|
res.Details = l.messages
|
||||||
return res
|
return res
|
||||||
@ -64,7 +63,7 @@ func Bool2int(b bool) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MultiCheck(fns ...CheckFn) CheckFn {
|
func MultiCheck(fns ...CheckFn) CheckFn {
|
||||||
return func(c CheckRequest) CheckResult {
|
return func(c *CheckRequest) CheckResult {
|
||||||
var maxResult CheckResult
|
var maxResult CheckResult
|
||||||
|
|
||||||
for _, fn := range fns {
|
for _, fn := range fns {
|
||||||
|
@ -30,13 +30,16 @@ func init() {
|
|||||||
registerCheck(activeStr, IsActive)
|
registerCheck(activeStr, IsActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsActive(c checker.CheckRequest) checker.CheckResult {
|
func IsActive(c *checker.CheckRequest) checker.CheckResult {
|
||||||
commits, _, err := c.Client.Repositories.ListCommits(c.Ctx, c.Owner, c.Repo, &github.CommitsListOptions{})
|
commits, _, err := c.Client.Repositories.ListCommits(c.Ctx, c.Owner, c.Repo, &github.CommitsListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return checker.MakeRetryResult(activeStr, err)
|
return checker.MakeRetryResult(activeStr, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tz, _ := time.LoadLocation("UTC")
|
tz, err := time.LoadLocation("UTC")
|
||||||
|
if err != nil {
|
||||||
|
return checker.MakeRetryResult(activeStr, err)
|
||||||
|
}
|
||||||
threshold := time.Now().In(tz).AddDate(0, 0, -1*lookbackDays)
|
threshold := time.Now().In(tz).AddDate(0, 0, -1*lookbackDays)
|
||||||
totalCommits := 0
|
totalCommits := 0
|
||||||
for _, commit := range commits {
|
for _, commit := range commits {
|
||||||
|
@ -25,7 +25,7 @@ func init() {
|
|||||||
registerCheck(branchProtectionStr, BranchProtection)
|
registerCheck(branchProtectionStr, BranchProtection)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BranchProtection(c checker.CheckRequest) checker.CheckResult {
|
func BranchProtection(c *checker.CheckRequest) checker.CheckResult {
|
||||||
repo, _, err := c.Client.Repositories.Get(c.Ctx, c.Owner, c.Repo)
|
repo, _, err := c.Client.Repositories.Get(c.Ctx, c.Owner, c.Repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return checker.MakeRetryResult(branchProtectionStr, err)
|
return checker.MakeRetryResult(branchProtectionStr, err)
|
||||||
@ -48,10 +48,9 @@ func BranchProtection(c checker.CheckRequest) checker.CheckResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return IsBranchProtected(protection, c)
|
return IsBranchProtected(protection, c)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsBranchProtected(protection *github.Protection, c checker.CheckRequest) checker.CheckResult {
|
func IsBranchProtected(protection *github.Protection, c *checker.CheckRequest) checker.CheckResult {
|
||||||
totalChecks := 6
|
totalChecks := 6
|
||||||
totalSuccess := 0
|
totalSuccess := 0
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ func (l *log) Logf(s string, f ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIsBranchProtected(t *testing.T) {
|
func TestIsBranchProtected(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
type args struct {
|
type args struct {
|
||||||
protection *github.Protection
|
protection *github.Protection
|
||||||
c checker.CheckRequest
|
c checker.CheckRequest
|
||||||
@ -440,9 +441,11 @@ func TestIsBranchProtected(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt // Re-initializing variable so it is not changed while executing the closure below
|
||||||
l.messages = []string{}
|
l.messages = []string{}
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
got := IsBranchProtected(tt.args.protection, tt.args.c)
|
t.Parallel()
|
||||||
|
got := IsBranchProtected(tt.args.protection, &tt.args.c)
|
||||||
got.Details = l.messages
|
got.Details = l.messages
|
||||||
if got.Confidence != tt.want.Confidence || got.Pass != tt.want.Pass {
|
if got.Confidence != tt.want.Confidence || got.Pass != tt.want.Pass {
|
||||||
t.Errorf("IsBranchProtected() = %s, %v, want %v", tt.name, got, tt.want)
|
t.Errorf("IsBranchProtected() = %s, %v, want %v", tt.name, got, tt.want)
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
// CheckIfFileExists downloads the tar of the repository and calls the predicate to check
|
// CheckIfFileExists downloads the tar of the repository and calls the predicate to check
|
||||||
// for the occurrence.
|
// for the occurrence.
|
||||||
func CheckIfFileExists(checkName string, c checker.CheckRequest, predicate func(name string,
|
func CheckIfFileExists(checkName string, c *checker.CheckRequest, predicate func(name string,
|
||||||
Logf func(s string, f ...interface{})) bool) checker.CheckResult {
|
Logf func(s string, f ...interface{})) bool) checker.CheckResult {
|
||||||
r, _, err := c.Client.Repositories.Get(c.Ctx, c.Owner, c.Repo)
|
r, _, err := c.Client.Repositories.Get(c.Ctx, c.Owner, c.Repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,7 +27,7 @@ func init() {
|
|||||||
registerCheck(ciTestsStr, CITests)
|
registerCheck(ciTestsStr, CITests)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CITests(c checker.CheckRequest) checker.CheckResult {
|
func CITests(c *checker.CheckRequest) checker.CheckResult {
|
||||||
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
||||||
State: "closed",
|
State: "closed",
|
||||||
})
|
})
|
||||||
|
@ -32,7 +32,7 @@ type response struct {
|
|||||||
BadgeLevel string `json:"badge_level"`
|
BadgeLevel string `json:"badge_level"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CIIBestPractices(c checker.CheckRequest) checker.CheckResult {
|
func CIIBestPractices(c *checker.CheckRequest) checker.CheckResult {
|
||||||
repoUrl := fmt.Sprintf("https://github.com/%s/%s", c.Owner, c.Repo)
|
repoUrl := fmt.Sprintf("https://github.com/%s/%s", c.Owner, c.Repo)
|
||||||
url := fmt.Sprintf("https://bestpractices.coreinfrastructure.org/projects.json?url=%s", repoUrl)
|
url := fmt.Sprintf("https://bestpractices.coreinfrastructure.org/projects.json?url=%s", repoUrl)
|
||||||
resp, err := c.HttpClient.Get(url)
|
resp, err := c.HttpClient.Get(url)
|
||||||
|
@ -32,7 +32,7 @@ func init() {
|
|||||||
// - Looking at the repo configuration to see if reviews are required
|
// - Looking at the repo configuration to see if reviews are required
|
||||||
// - Checking if most of the recent merged PRs were "Approved"
|
// - Checking if most of the recent merged PRs were "Approved"
|
||||||
// - Looking for other well-known review labels
|
// - Looking for other well-known review labels
|
||||||
func DoesCodeReview(c checker.CheckRequest) checker.CheckResult {
|
func DoesCodeReview(c *checker.CheckRequest) checker.CheckResult {
|
||||||
return checker.MultiCheck(
|
return checker.MultiCheck(
|
||||||
IsPrReviewRequired,
|
IsPrReviewRequired,
|
||||||
GithubCodeReview,
|
GithubCodeReview,
|
||||||
@ -41,7 +41,7 @@ func DoesCodeReview(c checker.CheckRequest) checker.CheckResult {
|
|||||||
)(c)
|
)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GithubCodeReview(c checker.CheckRequest) checker.CheckResult {
|
func GithubCodeReview(c *checker.CheckRequest) checker.CheckResult {
|
||||||
// Look at some merged PRs to see if they were reviewed
|
// Look at some merged PRs to see if they were reviewed
|
||||||
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
||||||
State: "closed",
|
State: "closed",
|
||||||
@ -87,7 +87,6 @@ func GithubCodeReview(c checker.CheckRequest) checker.CheckResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if totalReviewed > 0 {
|
if totalReviewed > 0 {
|
||||||
@ -96,7 +95,7 @@ func GithubCodeReview(c checker.CheckRequest) checker.CheckResult {
|
|||||||
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, totalMerged, .75)
|
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, totalMerged, .75)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsPrReviewRequired(c checker.CheckRequest) checker.CheckResult {
|
func IsPrReviewRequired(c *checker.CheckRequest) checker.CheckResult {
|
||||||
// Look to see if review is enforced.
|
// Look to see if review is enforced.
|
||||||
r, _, err := c.Client.Repositories.Get(c.Ctx, c.Owner, c.Repo)
|
r, _, err := c.Client.Repositories.Get(c.Ctx, c.Owner, c.Repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -120,7 +119,7 @@ func IsPrReviewRequired(c checker.CheckRequest) checker.CheckResult {
|
|||||||
return checker.MakeInconclusiveResult(codeReviewStr)
|
return checker.MakeInconclusiveResult(codeReviewStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProwCodeReview(c checker.CheckRequest) checker.CheckResult {
|
func ProwCodeReview(c *checker.CheckRequest) checker.CheckResult {
|
||||||
// Look at some merged PRs to see if they were reviewed
|
// Look at some merged PRs to see if they were reviewed
|
||||||
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
||||||
State: "closed",
|
State: "closed",
|
||||||
@ -151,7 +150,7 @@ func ProwCodeReview(c checker.CheckRequest) checker.CheckResult {
|
|||||||
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, totalMerged, .75)
|
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, totalMerged, .75)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CommitMessageHints(c checker.CheckRequest) checker.CheckResult {
|
func CommitMessageHints(c *checker.CheckRequest) checker.CheckResult {
|
||||||
commits, _, err := c.Client.Repositories.ListCommits(c.Ctx, c.Owner, c.Repo, &github.CommitsListOptions{})
|
commits, _, err := c.Client.Repositories.ListCommits(c.Ctx, c.Owner, c.Repo, &github.CommitsListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return checker.MakeRetryResult(codeReviewStr, err)
|
return checker.MakeRetryResult(codeReviewStr, err)
|
||||||
|
@ -31,7 +31,7 @@ func init() {
|
|||||||
registerCheck(contributorsStr, Contributors)
|
registerCheck(contributorsStr, Contributors)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Contributors(c checker.CheckRequest) checker.CheckResult {
|
func Contributors(c *checker.CheckRequest) checker.CheckResult {
|
||||||
contribs, _, err := c.Client.Repositories.ListContributors(c.Ctx, c.Owner, c.Repo, &github.ListContributorsOptions{})
|
contribs, _, err := c.Client.Repositories.ListContributors(c.Ctx, c.Owner, c.Repo, &github.ListContributorsOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return checker.MakeRetryResult(contributorsStr, err)
|
return checker.MakeRetryResult(contributorsStr, err)
|
||||||
@ -40,29 +40,30 @@ func Contributors(c checker.CheckRequest) checker.CheckResult {
|
|||||||
companies := map[string]struct{}{}
|
companies := map[string]struct{}{}
|
||||||
for _, contrib := range contribs {
|
for _, contrib := range contribs {
|
||||||
//nolint:nestif
|
//nolint:nestif
|
||||||
if contrib.GetContributions() >= minContributionsPerUser {
|
if contrib.GetContributions() < minContributionsPerUser {
|
||||||
u, _, err := c.Client.Users.Get(c.Ctx, contrib.GetLogin())
|
continue
|
||||||
if err != nil {
|
}
|
||||||
return checker.MakeRetryResult(contributorsStr, err)
|
u, _, err := c.Client.Users.Get(c.Ctx, contrib.GetLogin())
|
||||||
}
|
if err != nil {
|
||||||
orgs, _, err := c.Client.Organizations.List(c.Ctx, contrib.GetLogin(), nil)
|
return checker.MakeRetryResult(contributorsStr, err)
|
||||||
if err != nil {
|
}
|
||||||
c.Logf("unable to get org members for %s", contrib.GetLogin())
|
orgs, _, err := c.Client.Organizations.List(c.Ctx, contrib.GetLogin(), nil)
|
||||||
} else if len(orgs) > 0 {
|
if err != nil {
|
||||||
companies[*orgs[0].Login] = struct{}{}
|
c.Logf("unable to get org members for %s", contrib.GetLogin())
|
||||||
continue
|
} else if len(orgs) > 0 {
|
||||||
}
|
companies[*orgs[0].Login] = struct{}{}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
company := u.GetCompany()
|
company := u.GetCompany()
|
||||||
if company != "" {
|
if company != "" {
|
||||||
company = strings.ToLower(company)
|
company = strings.ToLower(company)
|
||||||
company = strings.ReplaceAll(company, "inc.", "")
|
company = strings.ReplaceAll(company, "inc.", "")
|
||||||
company = strings.ReplaceAll(company, "llc", "")
|
company = strings.ReplaceAll(company, "llc", "")
|
||||||
company = strings.ReplaceAll(company, ",", "")
|
company = strings.ReplaceAll(company, ",", "")
|
||||||
company = strings.TrimLeft(company, "@")
|
company = strings.TrimLeft(company, "@")
|
||||||
company = strings.Trim(company, " ")
|
company = strings.Trim(company, " ")
|
||||||
companies[company] = struct{}{}
|
companies[company] = struct{}{}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
names := []string{}
|
names := []string{}
|
||||||
|
@ -27,7 +27,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FrozenDeps will check the repository if it contains frozen dependecies.
|
// FrozenDeps will check the repository if it contains frozen dependecies.
|
||||||
func FrozenDeps(c checker.CheckRequest) checker.CheckResult {
|
func FrozenDeps(c *checker.CheckRequest) checker.CheckResult {
|
||||||
return CheckIfFileExists(frozenDepsStr, c, filePredicate)
|
return CheckIfFileExists(frozenDepsStr, c, filePredicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func init() {
|
|||||||
registerCheck(fuzzingStr, Fuzzing)
|
registerCheck(fuzzingStr, Fuzzing)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Fuzzing(c checker.CheckRequest) checker.CheckResult {
|
func Fuzzing(c *checker.CheckRequest) checker.CheckResult {
|
||||||
url := fmt.Sprintf("github.com/%s/%s", c.Owner, c.Repo)
|
url := fmt.Sprintf("github.com/%s/%s", c.Owner, c.Repo)
|
||||||
searchString := url + " repo:google/oss-fuzz in:file filename:project.yaml"
|
searchString := url + " repo:google/oss-fuzz in:file filename:project.yaml"
|
||||||
results, _, err := c.Client.Search.Code(c.Ctx, searchString, &github.SearchOptions{})
|
results, _, err := c.Client.Search.Code(c.Ctx, searchString, &github.SearchOptions{})
|
||||||
|
@ -29,7 +29,7 @@ func init() {
|
|||||||
registerCheck(packagingStr, Packaging)
|
registerCheck(packagingStr, Packaging)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Packaging(c checker.CheckRequest) checker.CheckResult {
|
func Packaging(c *checker.CheckRequest) checker.CheckResult {
|
||||||
_, dc, _, err := c.Client.Repositories.GetContents(c.Ctx, c.Owner, c.Repo, ".github/workflows", &github.RepositoryContentGetOptions{})
|
_, dc, _, err := c.Client.Repositories.GetContents(c.Ctx, c.Owner, c.Repo, ".github/workflows", &github.RepositoryContentGetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return checker.MakeRetryResult(packagingStr, err)
|
return checker.MakeRetryResult(packagingStr, err)
|
||||||
@ -78,11 +78,11 @@ func Packaging(c checker.CheckRequest) checker.CheckResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isPackagingWorkflow(s string, fp string, c checker.CheckRequest) bool {
|
func isPackagingWorkflow(s, fp string, c *checker.CheckRequest) bool {
|
||||||
// nodejs packages
|
// nodejs packages
|
||||||
if strings.Contains(s, "uses: actions/setup-node@") {
|
if strings.Contains(s, "uses: actions/setup-node@") {
|
||||||
r1, _ := regexp.Compile(`(?s)registry-url.*https://registry\.npmjs\.org`)
|
r1 := regexp.MustCompile(`(?s)registry-url.*https://registry\.npmjs\.org`)
|
||||||
r2, _ := regexp.Compile(`(?s)npm.*publish`)
|
r2 := regexp.MustCompile(`(?s)npm.*publish`)
|
||||||
|
|
||||||
if r1.MatchString(s) && r2.MatchString(s) {
|
if r1.MatchString(s) && r2.MatchString(s) {
|
||||||
c.Logf("found node packaging workflow using npm: %s", fp)
|
c.Logf("found node packaging workflow using npm: %s", fp)
|
||||||
@ -92,14 +92,14 @@ func isPackagingWorkflow(s string, fp string, c checker.CheckRequest) bool {
|
|||||||
|
|
||||||
if strings.Contains(s, "uses: actions/setup-java@") {
|
if strings.Contains(s, "uses: actions/setup-java@") {
|
||||||
// java packages with maven
|
// java packages with maven
|
||||||
r1, _ := regexp.Compile(`(?s)mvn.*deploy`)
|
r1 := regexp.MustCompile(`(?s)mvn.*deploy`)
|
||||||
if r1.MatchString(s) {
|
if r1.MatchString(s) {
|
||||||
c.Logf("found java packaging workflow using maven: %s", fp)
|
c.Logf("found java packaging workflow using maven: %s", fp)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// java packages with gradle
|
// java packages with gradle
|
||||||
r2, _ := regexp.Compile(`(?s)gradle.*publish`)
|
r2 := regexp.MustCompile(`(?s)gradle.*publish`)
|
||||||
if r2.MatchString(s) {
|
if r2.MatchString(s) {
|
||||||
c.Logf("found java packaging workflow using gradle: %s", fp)
|
c.Logf("found java packaging workflow using gradle: %s", fp)
|
||||||
return true
|
return true
|
||||||
|
@ -27,7 +27,7 @@ func init() {
|
|||||||
registerCheck(pullRequestsStr, PullRequests)
|
registerCheck(pullRequestsStr, PullRequests)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PullRequests(c checker.CheckRequest) checker.CheckResult {
|
func PullRequests(c *checker.CheckRequest) checker.CheckResult {
|
||||||
commits, _, err := c.Client.Repositories.ListCommits(c.Ctx, c.Owner, c.Repo, &github.CommitsListOptions{})
|
commits, _, err := c.Client.Repositories.ListCommits(c.Ctx, c.Owner, c.Repo, &github.CommitsListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return checker.MakeRetryResult(pullRequestsStr, err)
|
return checker.MakeRetryResult(pullRequestsStr, err)
|
||||||
|
@ -27,14 +27,14 @@ func init() {
|
|||||||
registerCheck(sastStr, SAST)
|
registerCheck(sastStr, SAST)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SAST(c checker.CheckRequest) checker.CheckResult {
|
func SAST(c *checker.CheckRequest) checker.CheckResult {
|
||||||
return checker.MultiCheck(
|
return checker.MultiCheck(
|
||||||
CodeQLInCheckDefinitions,
|
CodeQLInCheckDefinitions,
|
||||||
SASTToolInCheckRuns,
|
SASTToolInCheckRuns,
|
||||||
)(c)
|
)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SASTToolInCheckRuns(c checker.CheckRequest) checker.CheckResult {
|
func SASTToolInCheckRuns(c *checker.CheckRequest) checker.CheckResult {
|
||||||
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
prs, _, err := c.Client.PullRequests.List(c.Ctx, c.Owner, c.Repo, &github.PullRequestListOptions{
|
||||||
State: "closed",
|
State: "closed",
|
||||||
})
|
})
|
||||||
@ -76,7 +76,7 @@ func SASTToolInCheckRuns(c checker.CheckRequest) checker.CheckResult {
|
|||||||
return checker.MakeProportionalResult(sastStr, totalTested, totalMerged, .75)
|
return checker.MakeProportionalResult(sastStr, totalTested, totalMerged, .75)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CodeQLInCheckDefinitions(c checker.CheckRequest) checker.CheckResult {
|
func CodeQLInCheckDefinitions(c *checker.CheckRequest) checker.CheckResult {
|
||||||
searchQuery := ("github/codeql-action path:/.github/workflows repo:" + c.Owner + "/" + c.Repo)
|
searchQuery := ("github/codeql-action path:/.github/workflows repo:" + c.Owner + "/" + c.Repo)
|
||||||
results, _, err := c.Client.Search.Code(c.Ctx, searchQuery, &github.SearchOptions{})
|
results, _, err := c.Client.Search.Code(c.Ctx, searchQuery, &github.SearchOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -26,7 +26,7 @@ func init() {
|
|||||||
registerCheck(securityPolicyStr, SecurityPolicy)
|
registerCheck(securityPolicyStr, SecurityPolicy)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SecurityPolicy(c checker.CheckRequest) checker.CheckResult {
|
func SecurityPolicy(c *checker.CheckRequest) checker.CheckResult {
|
||||||
// check repository for repository-specific policy
|
// check repository for repository-specific policy
|
||||||
result := CheckIfFileExists(securityPolicyStr, c, func(name string, logf func(s string, f ...interface{})) bool {
|
result := CheckIfFileExists(securityPolicyStr, c, func(name string, logf func(s string, f ...interface{})) bool {
|
||||||
if strings.EqualFold(name, "security.md") {
|
if strings.EqualFold(name, "security.md") {
|
||||||
|
@ -30,7 +30,7 @@ func init() {
|
|||||||
registerCheck(signedReleasesStr, SignedReleases)
|
registerCheck(signedReleasesStr, SignedReleases)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SignedReleases(c checker.CheckRequest) checker.CheckResult {
|
func SignedReleases(c *checker.CheckRequest) checker.CheckResult {
|
||||||
releases, _, err := c.Client.Repositories.ListReleases(c.Ctx, c.Owner, c.Repo, &github.ListOptions{})
|
releases, _, err := c.Client.Repositories.ListReleases(c.Ctx, c.Owner, c.Repo, &github.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return checker.MakeRetryResult(signedReleasesStr, err)
|
return checker.MakeRetryResult(signedReleasesStr, err)
|
||||||
|
@ -28,7 +28,7 @@ func init() {
|
|||||||
registerCheck(signedTagsStr, SignedTags)
|
registerCheck(signedTagsStr, SignedTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SignedTags(c checker.CheckRequest) checker.CheckResult {
|
func SignedTags(c *checker.CheckRequest) checker.CheckResult {
|
||||||
type ref struct {
|
type ref struct {
|
||||||
Name githubv4.String
|
Name githubv4.String
|
||||||
Target struct {
|
Target struct {
|
||||||
|
@ -63,7 +63,10 @@ or ./scorecard --{npm,pypi,rubgems}=<package_name> [--checks=check1,...] [--show
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cfg := zap.NewProductionConfig()
|
cfg := zap.NewProductionConfig()
|
||||||
cfg.Level.SetLevel(*logLevel)
|
cfg.Level.SetLevel(*logLevel)
|
||||||
logger, _ := cfg.Build()
|
logger, err := cfg.Build()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("unable to construct logger: %v", err)
|
||||||
|
}
|
||||||
// nolint
|
// nolint
|
||||||
defer logger.Sync() // flushes buffer, if any
|
defer logger.Sync() // flushes buffer, if any
|
||||||
sugar := logger.Sugar()
|
sugar := logger.Sugar()
|
||||||
|
@ -42,7 +42,10 @@ var serveCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cfg := zap.NewProductionConfig()
|
cfg := zap.NewProductionConfig()
|
||||||
cfg.Level.SetLevel(*logLevel)
|
cfg.Level.SetLevel(*logLevel)
|
||||||
logger, _ := cfg.Build()
|
logger, err := cfg.Build()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("unable to construct logger: %v", err)
|
||||||
|
}
|
||||||
//nolint
|
//nolint
|
||||||
defer logger.Sync() // flushes buffer, if any
|
defer logger.Sync() // flushes buffer, if any
|
||||||
sugar := logger.Sugar()
|
sugar := logger.Sugar()
|
||||||
@ -122,7 +125,7 @@ func encodeJson(repo string, results []checker.CheckResult) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
output, err := json.Marshal(or)
|
output, err := json.Marshal(or)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to json encode results: %w", err)
|
||||||
}
|
}
|
||||||
return output, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:Active", func() {
|
var _ = Describe("E2E TEST:Active", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:Active", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.IsActive(checkRequest)
|
result := checks.IsActive(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:Branch Protection", func() {
|
var _ = Describe("E2E TEST:Branch Protection", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:Branch Protection", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.BranchProtection(checkRequest)
|
result := checks.BranchProtection(&checkRequest)
|
||||||
Expect(result.Error).ShouldNot(BeNil())
|
Expect(result.Error).ShouldNot(BeNil())
|
||||||
Expect(result.Pass).Should(BeFalse())
|
Expect(result.Pass).Should(BeFalse())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:CITests", func() {
|
var _ = Describe("E2E TEST:CITests", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:CITests", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.CITests(checkRequest)
|
result := checks.CITests(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:CIIBestPractices", func() {
|
var _ = Describe("E2E TEST:CIIBestPractices", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:CIIBestPractices", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.CIIBestPractices(checkRequest)
|
result := checks.CIIBestPractices(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:CodeReview", func() {
|
var _ = Describe("E2E TEST:CodeReview", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:CodeReview", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.DoesCodeReview(checkRequest)
|
result := checks.DoesCodeReview(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:CodeReview", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.Contributors(checkRequest)
|
result := checks.Contributors(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
@ -51,7 +51,7 @@ var _ = Describe("E2E TEST:CodeReview", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.Contributors(checkRequest)
|
result := checks.Contributors(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -42,6 +42,7 @@ func (l *log) Logf(s string, f ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestE2e(t *testing.T) {
|
func TestE2e(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
RunSpecs(t, "E2e Suite")
|
RunSpecs(t, "E2e Suite")
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:FrozenDeps", func() {
|
var _ = Describe("E2E TEST:FrozenDeps", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:FrozenDeps", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.FrozenDeps(checkRequest)
|
result := checks.FrozenDeps(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:Fuzzing", func() {
|
var _ = Describe("E2E TEST:Fuzzing", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:Fuzzing", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.Fuzzing(checkRequest)
|
result := checks.Fuzzing(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:Packaging", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.Packaging(checkRequest)
|
result := checks.Packaging(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
@ -51,7 +51,7 @@ var _ = Describe("E2E TEST:Packaging", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.Packaging(checkRequest)
|
result := checks.Packaging(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:PullRequests", func() {
|
var _ = Describe("E2E TEST:PullRequests", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:PullRequests", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.PullRequests(checkRequest)
|
result := checks.PullRequests(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:SAST", func() {
|
var _ = Describe("E2E TEST:SAST", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:SAST", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.SAST(checkRequest)
|
result := checks.SAST(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:SecurityPolicy", func() {
|
var _ = Describe("E2E TEST:SecurityPolicy", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:SecurityPolicy", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.SecurityPolicy(checkRequest)
|
result := checks.SecurityPolicy(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:Signedreleases", func() {
|
var _ = Describe("E2E TEST:Signedreleases", func() {
|
||||||
@ -36,7 +36,7 @@ var _ = Describe("E2E TEST:Signedreleases", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.SignedReleases(checkRequest)
|
result := checks.SignedReleases(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/ossf/scorecard/checks"
|
|
||||||
"github.com/ossf/scorecard/checker"
|
"github.com/ossf/scorecard/checker"
|
||||||
|
"github.com/ossf/scorecard/checks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("E2E TEST:Signedtags", func() {
|
var _ = Describe("E2E TEST:Signedtags", func() {
|
||||||
@ -37,7 +37,7 @@ var _ = Describe("E2E TEST:Signedtags", func() {
|
|||||||
GraphClient: graphClient,
|
GraphClient: graphClient,
|
||||||
Logf: l.Logf,
|
Logf: l.Logf,
|
||||||
}
|
}
|
||||||
result := checks.SignedTags(checkRequest)
|
result := checks.SignedTags(&checkRequest)
|
||||||
Expect(result.Error).Should(BeNil())
|
Expect(result.Error).Should(BeNil())
|
||||||
Expect(result.Pass).Should(BeTrue())
|
Expect(result.Pass).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
@ -50,7 +50,7 @@ func (r *RepoURL) Set(s string) error {
|
|||||||
|
|
||||||
u, e := url.Parse(s)
|
u, e := url.Parse(s)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return e
|
return fmt.Errorf("failed to parse repo url: %w", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
const splitLen = 2
|
const splitLen = 2
|
||||||
@ -59,7 +59,7 @@ func (r *RepoURL) Set(s string) error {
|
|||||||
log.Fatalf("invalid repo flag: [%s], pass the full repository URL", s)
|
log.Fatalf("invalid repo flag: [%s], pass the full repository URL", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(strings.TrimSpace(split[0])) == 0 || len(strings.TrimSpace(split[1])) == 0 {
|
if strings.TrimSpace(split[0]) == "" || strings.TrimSpace(split[1]) == "" {
|
||||||
log.Fatalf("invalid repo flag: [%s], pass the full repository URL", s)
|
log.Fatalf("invalid repo flag: [%s], pass the full repository URL", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRepoURL_Set(t *testing.T) {
|
func TestRepoURL_Set(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
type fields struct {
|
type fields struct {
|
||||||
Host string
|
Host string
|
||||||
Owner string
|
Owner string
|
||||||
@ -65,7 +66,9 @@ func TestRepoURL_Set(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt // Re-initializing variable so it is not changed while executing the closure below
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
r := &RepoURL{
|
r := &RepoURL{
|
||||||
Host: tt.fields.Host,
|
Host: tt.fields.Host,
|
||||||
Owner: tt.fields.Owner,
|
Owner: tt.fields.Owner,
|
||||||
|
Loading…
Reference in New Issue
Block a user