-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Automatic dependency update checks
* Checks if the dependencies are automatically updated.
- Loading branch information
1 parent
37d979f
commit 0eabcdc
Showing
4 changed files
with
127 additions
and
0 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,52 @@ | ||
// Copyright 2020 Security Scorecard Authors | ||
// | ||
// 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.org/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 checks | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/ossf/scorecard/checker" | ||
) | ||
|
||
const check = "Automatic-Dependency-Update" | ||
|
||
//nolint | ||
func init() { | ||
registerCheck(check, AutomaticDependencyUpdate) | ||
} | ||
|
||
// AutomaticDependencyUpdate will check the repository if it contains Automatic dependency update. | ||
func AutomaticDependencyUpdate(c *checker.CheckRequest) checker.CheckResult { | ||
result := CheckIfFileExists(check, c, fileExists) | ||
if !result.Pass { | ||
result.Confidence = 3 | ||
} | ||
return result | ||
} | ||
|
||
// fileExists will validate the if frozen dependencies file name exists. | ||
func fileExists(name string, logf func(s string, f ...interface{})) (bool, error) { | ||
switch strings.ToLower(name) { | ||
case ".github/dependabot.yml": | ||
logf("dependabot config found: %s", name) | ||
return true, nil | ||
// https://docs.renovatebot.com/configuration-options/ | ||
case ".github/renovate.json", ".github/renovate.json5", ".renovaterc.json", "renovate.json", "renovate.json5", ".renovaterc": | ||
logf("renovate config found: %s", name) | ||
return true, nil | ||
default: | ||
return false, nil | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2021 Security Scorecard Authors | ||
// | ||
// 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.org/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 e2e | ||
|
||
import ( | ||
"context" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/ossf/scorecard/checker" | ||
"github.com/ossf/scorecard/checks" | ||
) | ||
|
||
var _ = Describe("E2E TEST:Automatic-Dependency-Update", func() { | ||
Context("E2E TEST:Validating dependencies are automatically updated", func() { | ||
It("Should return deps are automatically updated for dependabot", func() { | ||
l := log{} | ||
checker := checker.CheckRequest{ | ||
Ctx: context.Background(), | ||
Client: ghClient, | ||
Owner: "ossf", | ||
Repo: "scorecard", | ||
GraphClient: graphClient, | ||
Logf: l.Logf, | ||
} | ||
result := checks.AutomaticDependencyUpdate(&checker) | ||
Expect(result.Error).Should(BeNil()) | ||
Expect(result.Pass).Should(BeTrue()) | ||
}) | ||
It("Should return deps are automatically updated for renovatebot", func() { | ||
l := log{} | ||
checker := checker.CheckRequest{ | ||
Ctx: context.Background(), | ||
Client: ghClient, | ||
Owner: "netlify", | ||
Repo: "netlify-cms", | ||
GraphClient: graphClient, | ||
Logf: l.Logf, | ||
} | ||
result := checks.AutomaticDependencyUpdate(&checker) | ||
Expect(result.Error).Should(BeNil()) | ||
Expect(result.Pass).Should(BeTrue()) | ||
}) | ||
}) | ||
}) |