Skip to content

Commit 6c3fcf7

Browse files
latortuga71dependabot[bot]raghavkaulspencerschrockshissam
authored andcommitted
✨ Commit depth feature (ossf#2407)
* 🌱 Bump actions/dependency-review-action from 2.4.1 to 2.5.1 Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 2.4.1 to 2.5.1. - [Release notes](https://github.com/actions/dependency-review-action/releases) - [Commits](actions/dependency-review-action@9c96258...0efb1d1) --- updated-dependencies: - dependency-name: actions/dependency-review-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * commit_depth feature Signed-off-by: latortuga71 <[email protected]> * added more descriptive comments, changed numberofcommits variable name, moved paging for commits into seperate function. small changes Signed-off-by: latortuga71 <[email protected]> linter Signed-off-by: latortuga71 <[email protected]> * added unit tests Signed-off-by: latortuga71 <[email protected]> added test in e2e Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/spf13/cobra from 1.6.0 to 1.6.1 (ossf#2397) Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](spf13/cobra@v1.6.0...v1.6.1) --- updated-dependencies: - dependency-name: github.com/spf13/cobra dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/onsi/ginkgo/v2 from 2.1.6 to 2.4.0 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.1.6 to 2.4.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.1.6...v2.4.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump cloud.google.com/go/pubsub from 1.25.1 to 1.26.0 Bumps [cloud.google.com/go/pubsub](https://github.com/googleapis/google-cloud-go) from 1.25.1 to 1.26.0. - [Release notes](https://github.com/googleapis/google-cloud-go/releases) - [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md) - [Commits](googleapis/google-cloud-go@pubsub/v1.25.1...pubsub/v1.26.0) --- updated-dependencies: - dependency-name: cloud.google.com/go/pubsub dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/xanzy/go-gitlab from 0.73.1 to 0.74.0 Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.73.1 to 0.74.0. - [Release notes](https://github.com/xanzy/go-gitlab/releases) - [Changelog](https://github.com/xanzy/go-gitlab/blob/master/releases_test.go) - [Commits](xanzy/go-gitlab@v0.73.1...v0.74.0) --- updated-dependencies: - dependency-name: github.com/xanzy/go-gitlab dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/onsi/gomega from 1.20.2 to 1.23.0 (ossf#2409) Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.20.2 to 1.23.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](onsi/gomega@v1.20.2...v1.23.0) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/onsi/ginkgo/v2 from 2.1.6 to 2.4.0 in /tools Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.1.6 to 2.4.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.1.6...v2.4.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/golangci/golangci-lint in /tools Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.50.0 to 1.50.1. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](golangci/golangci-lint@v1.50.0...v1.50.1) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump goreleaser/goreleaser-action from 2.9.1 to 3.2.0 (ossf#2363) Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 2.9.1 to 3.2.0. - [Release notes](https://github.com/goreleaser/goreleaser-action/releases) - [Commits](goreleaser/goreleaser-action@b953231...b508e2e) --- updated-dependencies: - dependency-name: goreleaser/goreleaser-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/goreleaser/goreleaser in /tools (ossf#2373) Bumps [github.com/goreleaser/goreleaser](https://github.com/goreleaser/goreleaser) from 1.11.5 to 1.12.3. - [Release notes](https://github.com/goreleaser/goreleaser/releases) - [Changelog](https://github.com/goreleaser/goreleaser/blob/main/.goreleaser.yaml) - [Commits](goreleaser/goreleaser@v1.11.5...v1.12.3) --- updated-dependencies: - dependency-name: github.com/goreleaser/goreleaser dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * ✨ CLI for scorecard-attestor (ossf#2309) * Reorganize Signed-off-by: Raghav Kaul <[email protected]> * Working commit Signed-off-by: Raghav Kaul <[email protected]> * Compile with local scorecard; go mod tidy Signed-off-by: Raghav Kaul <[email protected]> * Add signing code Heavily borrowed from https://github.com/grafeas/kritis/blob/master/cmd/kritis/signer/main.go Signed-off-by: Raghav Kaul <[email protected]> * Update deps * Naming * Makefile Signed-off-by: Raghav Kaul <[email protected]> * Edit license, add lint.yml Signed-off-by: Raghav Kaul <[email protected]> * checks: go mod tidy, license Signed-off-by: Raghav Kaul <[email protected]> * Address PR comments * Split into checker/signer files * Naming convention Signed-off-by: Raghav Kaul <[email protected]> * License, remove golangci.yml Signed-off-by: Raghav Kaul <[email protected]> * Address PR comments * Use cobra Signed-off-by: Raghav Kaul <[email protected]> * Add tests for root command Signed-off-by: Raghav Kaul <[email protected]> * Filter out checks that aren't needed for policy evaluation Signed-off-by: Raghav Kaul <[email protected]> * Add `make` targets for attestor; submit coverage stats Signed-off-by: Raghav Kaul <[email protected]> * Improvements * Use sclog instead of glog * Remove unneeded subcommands * Formatting Signed-off-by: Raghav Kaul <[email protected]> * Flags: Make note-name constant and fix messaging Signed-off-by: Raghav Kaul <[email protected]> * Remove SupportedRequestTypes Signed-off-by: Raghav Kaul <[email protected]> * go mod tidy Signed-off-by: Raghav Kaul <[email protected]> * go mod tidy, makefile Signed-off-by: Raghav Kaul <[email protected]> * Fix GH actions run Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: latortuga71 <[email protected]> * fix workflow (ossf#2417) Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Bump scorecard-action (ossf#2416) Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Fail unit-test job if codecov upload fails (ossf#2415) Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Enable comparison for alternative isText implementation (ossf#2414) * use more performant IsText Signed-off-by: Spencer Schrock <[email protected]> * AB test isText implementations Signed-off-by: Spencer Schrock <[email protected]> * Add comparison env var to release test. Signed-off-by: Spencer Schrock <[email protected]> * go mod tidy for attestor Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🐛 modify alternative isText to accept carriage returns (ossf#2421) * modify IsText from golang.org/x/tools/godoc/util to accept carriage returns. Signed-off-by: Spencer Schrock <[email protected]> * add TODO reminder to cleanup after release tests Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/onsi/gomega from 1.23.0 to 1.24.0 Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.23.0 to 1.24.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](onsi/gomega@v1.23.0...v1.24.0) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github/codeql-action from 2.1.29 to 2.1.30 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.29 to 2.1.30. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@ec3cf9c...18fe527) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * revert failing unit-test on ci error (ossf#2422) Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * ✨ Improved Security Policy Check (ossf#2195) * ✨ Improved Security Policy Check (ossf#2137) * Examines and awards points for linked content (URLs / Emails) * Examines and awards points for hints of disclosure and vulnerability practices * Examines and awards points for hints of elaboration of timelines Signed-off-by: Scott Hissam <[email protected]> * Repaired Security Policy to correctly use linked content length for evaluation Signed-off-by: Scott Hissam <[email protected]> * gofmt'ed changes Signed-off-by: Scott Hissam <[email protected]> * Repaired the case in the evaluation which was too sensitive to content length over the length of the linked content for urls and emails Signed-off-by: Scott Hissam <[email protected]> * added unit test cases for the new content-based Security Policy checks Signed-off-by: Scott Hissam <[email protected]> * reverted the direct (mistaken) change to checks.md and updated the checks.yaml for generate-docs Signed-off-by: Scott Hissam <[email protected]> * ✨ Improved Security Policy Check (ossf#2137) (revisted based on comments) * replaced reason strings with log.Info & log.Warn (as seen in --show-details) * internal assertion check for nil (*pinfo) and empty pfile * internal switched to FileTypeText over FileTypeSource * internal implement type SecurityPolicyInformationType/SecurityPolicyInformation revised SecurityPolicyData to support only one file * revised expected unit-test results and revised unit-test to reflect the new SecurityPolicyData type Signed-off-by: Scott Hissam <[email protected]> * revised the score value based on observation of one *or more* url(s) or one email(s) found; unit tests update accordingly Signed-off-by: Scott Hissam <[email protected]> * revised the score value based on observation of one *or more* url(s) or one email(s) found; unit tests update accordingly Signed-off-by: Scott Hissam <[email protected]> * revised the score value based on observation of one *or more* url(s) or one email(s) found; e2e tests update accordingly Signed-off-by: Scott Hissam <[email protected]> * Addressed PR comments; added telemetry for policy hits in security policy file to track hits by line number Signed-off-by: Scott Hissam <[email protected]> * Resolved merge conflict with checks.yaml Signed-off-by: Scott Hissam <[email protected]> * updated raw results to emit all the raw information for the new security policy check Signed-off-by: Scott Hissam <[email protected]> * Resolved merge conflicts and lint errors with json_raw_results.go Signed-off-by: Scott Hissam <[email protected]> * Addressed review comments to reorganize security policy data struct to support the potential for multiple security policy files. Signed-off-by: Scott Hissam <[email protected]> * Added logic to the security policy to process multiple security policy files only after future improvements to aggregating scoring across such files are designed. For now the security policy behaves as originally designed to stop once one of the expected policy files are found in the repo Signed-off-by: Scott Hissam <[email protected]> * added comments regarding the capacity to support multiple policy files and removed unneeded break statements in the code Signed-off-by: Scott Hissam <[email protected]> * Addressed review comments to remove the dependency on the path in the filename from the code and introduced FileSize to checker.File type and removed the SecurityContentLength which was used to hold that information for the new security policy assessment Signed-off-by: Scott Hissam <[email protected]> * restored reporting full security policy path and filename for policies found in the org level repos Signed-off-by: Scott Hissam <[email protected]> * Resolved conflicts in checks.yaml for documentation Signed-off-by: Scott Hissam <[email protected]> * ✨ CLI for scorecard-attestor (ossf#2309) * Reorganize Signed-off-by: Raghav Kaul <[email protected]> * Working commit Signed-off-by: Raghav Kaul <[email protected]> * Compile with local scorecard; go mod tidy Signed-off-by: Raghav Kaul <[email protected]> * Add signing code Heavily borrowed from https://github.com/grafeas/kritis/blob/master/cmd/kritis/signer/main.go Signed-off-by: Raghav Kaul <[email protected]> * Update deps * Naming * Makefile Signed-off-by: Raghav Kaul <[email protected]> * Edit license, add lint.yml Signed-off-by: Raghav Kaul <[email protected]> * checks: go mod tidy, license Signed-off-by: Raghav Kaul <[email protected]> * Address PR comments * Split into checker/signer files * Naming convention Signed-off-by: Raghav Kaul <[email protected]> * License, remove golangci.yml Signed-off-by: Raghav Kaul <[email protected]> * Address PR comments * Use cobra Signed-off-by: Raghav Kaul <[email protected]> * Add tests for root command Signed-off-by: Raghav Kaul <[email protected]> * Filter out checks that aren't needed for policy evaluation Signed-off-by: Raghav Kaul <[email protected]> * Add `make` targets for attestor; submit coverage stats Signed-off-by: Raghav Kaul <[email protected]> * Improvements * Use sclog instead of glog * Remove unneeded subcommands * Formatting Signed-off-by: Raghav Kaul <[email protected]> * Flags: Make note-name constant and fix messaging Signed-off-by: Raghav Kaul <[email protected]> * Remove SupportedRequestTypes Signed-off-by: Raghav Kaul <[email protected]> * go mod tidy Signed-off-by: Raghav Kaul <[email protected]> * go mod tidy, makefile Signed-off-by: Raghav Kaul <[email protected]> * Fix GH actions run Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: Scott Hissam <[email protected]> * removed whitespace before stanza for Run attestor e2e Signed-off-by: Scott Hissam <[email protected]> * resolved code review and doc review comments Signed-off-by: Scott Hissam <[email protected]> * repaired the link for the maintainer's guide for supporting the coordinated vulnerability disclosure guidelines Signed-off-by: Scott Hissam <[email protected]> Signed-off-by: Scott Hissam <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github/codeql-action from 2.1.30 to 2.1.31 (ossf#2431) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.30 to 2.1.31. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@18fe527...c3b6fce) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * enable more performant isText (ossf#2433) Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * modified tests,InitRepo Function, Added GetCommitDepth Function to Client Interface Signed-off-by: latortuga71 <[email protected]> * removed getcommitdepth function Signed-off-by: latortuga71 <[email protected]> * added TODO Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/onsi/ginkgo/v2 from 2.4.0 to 2.5.0 in /tools (ossf#2436) Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.4.0 to 2.5.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.4.0...v2.5.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/onsi/ginkgo/v2 from 2.4.0 to 2.5.0 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.4.0 to 2.5.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.4.0...v2.5.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Code Review: treat merging a PR as code review (ossf#2413) * Merges on Github count as a code review by the maintainer Signed-off-by: Raghav Kaul <[email protected]> * Update Raw Results * More detailed information for Changesets * If there's no Revision ID, use the Commit SHA instead Signed-off-by: Raghav Kaul <[email protected]> * Check that pull request had atleast one reviewer that wasn't its author * Add field for Pull Request Merged-By to Github and Gitlab * Note, this check can be bypassed if an author opens a PR with other people's commits Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Trivial: Fix typo (exepted -> expected) (ossf#2440) Signed-off-by: Michael Scovetta <[email protected]> Signed-off-by: Michael Scovetta <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump step-security/harden-runner from 1.5.0 to 2.0.0 (ossf#2443) Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 1.5.0 to 2.0.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](step-security/harden-runner@2e205a2...ebacdc2) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * 🌱 cron: support reading prefix from file for controller input files (7/n) (ossf#2445) * add prefix marker file to config Signed-off-by: Spencer Schrock <[email protected]> * Read the new config values, if they exist. Signed-off-by: Spencer Schrock <[email protected]> * Add function to fetch prefix file config value. Signed-off-by: Spencer Schrock <[email protected]> * Read prefix file if prefix not set. Signed-off-by: Spencer Schrock <[email protected]> * Add tests to verify how List works with various prefixes Signed-off-by: Spencer Schrock <[email protected]> * Add tests for getPrefix Signed-off-by: Spencer Schrock <[email protected]> * Remove panics from iterator helper functions Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Detect SECURITY.markdown in addition to SECURITY.md (ossf#2447) GitHub probably supports many more file extensions for Markdown files, but at the very least, `.md` and `.markdown` have been standardized in RFC 7763. Signed-off-by: favonia <[email protected]> Signed-off-by: favonia <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Add Pinned-Dependency, Vulnerability, and Code-Review checks to attestor (ossf#2430) Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 cron: expose the stackdriver prefix as a config variable so it can be changed. (ossf#2446) * Expose the stackdriver prefix as a config variable so it can be changed. Signed-off-by: Caleb Brown <[email protected]> * fix linter warning Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: Caleb Brown <[email protected]> Co-authored-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Only write to the rawBucket if the value exists. (ossf#2451) Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump golang.org/x/tools from 0.2.0 to 0.3.0 (ossf#2448) * 🌱 Bump golang.org/x/tools from 0.2.0 to 0.3.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.2.0 to 0.3.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](golang/tools@v0.2.0...v0.3.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * bump attestor modules Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Move cron monitoring to a non-internal location. (ossf#2453) This allows external workers (e.g. criticality_score) to use the same monitoring code. Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump actions/dependency-review-action from 2.5.1 to 3.0.0 (ossf#2455) Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/actions/dependency-review-action/releases) - [Commits](actions/dependency-review-action@0efb1d1...30d5821) --- updated-dependencies: - dependency-name: actions/dependency-review-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * 🌱 [cron] generalize some of the transfer logic so it is easy to build new transfer agents (ossf#2454) * Generalize the transfer logic so it is easy to build new transfer agents This change moves code that reads shards and produces summaries into the data package so that it can be reused to create new transfer agents, similar to the BigQuery transfer agent in cron/internal/bq. Signed-off-by: Caleb Brown <[email protected]> * Lint fix and commentary. Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/google/addlicense in /tools (ossf#2459) Bumps [github.com/google/addlicense](https://github.com/google/addlicense) from 1.0.0 to 1.1.0. - [Release notes](https://github.com/google/addlicense/releases) - [Changelog](https://github.com/google/addlicense/blob/master/.goreleaser.yaml) - [Commits](google/addlicense@v1.0.0...v1.1.0) --- updated-dependencies: - dependency-name: github.com/google/addlicense dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: latortuga71 <[email protected]> * 🌱 Bump github.com/google/go-containerregistry Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.12.0 to 0.12.1. - [Release notes](https://github.com/google/go-containerregistry/releases) - [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml) - [Commits](google/go-containerregistry@v0.12.0...v0.12.1) --- updated-dependencies: - dependency-name: github.com/google/go-containerregistry dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> * go mod tidy Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: latortuga71 <[email protected]> * Added <= instead of == incase negative int is passed Signed-off-by: latortuga71 <[email protected]> * missed test fix Signed-off-by: latortuga71 <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: latortuga71 <[email protected]> Signed-off-by: Raghav Kaul <[email protected]> Signed-off-by: Spencer Schrock <[email protected]> Signed-off-by: Scott Hissam <[email protected]> Signed-off-by: Michael Scovetta <[email protected]> Signed-off-by: favonia <[email protected]> Signed-off-by: Caleb Brown <[email protected]> Signed-off-by: Latortuga <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: raghavkaul <[email protected]> Co-authored-by: Spencer Schrock <[email protected]> Co-authored-by: scott hissam <[email protected]> Co-authored-by: Michael Scovetta <[email protected]> Co-authored-by: favonia <[email protected]> Co-authored-by: Caleb Brown <[email protected]>
1 parent 85335ad commit 6c3fcf7

40 files changed

Lines changed: 275 additions & 101 deletions

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161

6262
# Initializes the CodeQL tools for scanning.
6363
- name: Initialize CodeQL
64+
6465
uses: github/codeql-action/init@678fc3afe258fb2e0cdc165ccf77b85719de7b3c # v1
6566
with:
6667
languages: ${{ matrix.language }}

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ build-attestor: ## Runs go build on scorecard attestor
243243
# Run go build on scorecard attestor
244244
cd attestor/; CGO_ENABLED=0 go build -trimpath -a -tags netgo -ldflags '$(LDFLAGS)' -o scorecard-attestor
245245

246+
246247
build-attestor-docker: ## Build scorecard-attestor Docker image
247248
build-attestor-docker:
248249
DOCKER_BUILDKIT=1 docker build . --file attestor/Dockerfile \

attestor/command/check.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func runCheck() (policy.PolicyResult, error) {
9797
ctx,
9898
repo,
9999
commitSHA,
100+
0,
100101
enabledChecks,
101102
repoClient,
102103
ossFuzzRepoClient,

attestor/e2e/command_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"strings"
1919
"testing"
2020

21+
2122
"github.com/spf13/cobra"
2223

2324
"github.com/ossf/scorecard-attestor/command"

checks/binary_artifact_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestBinaryArtifacts(t *testing.T) {
7171
ctx := context.Background()
7272

7373
client := localdir.CreateLocalDirClient(ctx, logger)
74-
if err := client.InitRepo(repo, clients.HeadSHA); err != nil {
74+
if err := client.InitRepo(repo, clients.HeadSHA, 0); err != nil {
7575
t.Errorf("InitRepo: %v", err)
7676
}
7777

checks/license_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestLicenseFileSubdirectory(t *testing.T) {
7575
ctx := context.Background()
7676

7777
client := localdir.CreateLocalDirClient(ctx, logger)
78-
if err := client.InitRepo(repo, clients.HeadSHA); err != nil {
78+
if err := client.InitRepo(repo, clients.HeadSHA, 0); err != nil {
7979
t.Errorf("InitRepo: %v", err)
8080
}
8181

checks/raw/security_policy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ func SecurityPolicy(c *checker.CheckRequest) (checker.SecurityPolicyData, error)
7272
if err != nil {
7373
return checker.SecurityPolicyData{}, fmt.Errorf("unable to create gitlab client: %w", err)
7474
}
75-
err = client.InitRepo(c.Repo, clients.HeadSHA)
75+
err = client.InitRepo(c.Repo, clients.HeadSHA, 0)
7676
} else {
7777
client = githubrepo.CreateGithubRepoClient(c.Ctx, logger)
78-
err = client.InitRepo(c.Repo.Org(), clients.HeadSHA)
78+
err = client.InitRepo(c.Repo.Org(), clients.HeadSHA, 0)
7979
}
8080
switch {
8181
case err == nil:

clients/githubrepo/client.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ type Client struct {
5555
languages *languagesHandler
5656
ctx context.Context
5757
tarball tarballHandler
58+
commitDepth int
5859
}
5960

6061
// InitRepo sets up the GitHub repo in local storage for improving performance and GitHub token usage efficiency.
61-
func (client *Client) InitRepo(inputRepo clients.Repo, commitSHA string) error {
62+
func (client *Client) InitRepo(inputRepo clients.Repo, commitSHA string, commitDepth int) error {
6263
ghRepo, ok := inputRepo.(*repoURL)
6364
if !ok {
6465
return fmt.Errorf("%w: %v", errInputRepoType, inputRepo)
@@ -69,7 +70,11 @@ func (client *Client) InitRepo(inputRepo clients.Repo, commitSHA string) error {
6970
if err != nil {
7071
return sce.WithMessage(sce.ErrRepoUnreachable, err.Error())
7172
}
72-
73+
if commitDepth <= 0 {
74+
client.commitDepth = 30 // default
75+
} else {
76+
client.commitDepth = commitDepth
77+
}
7378
client.repo = repo
7479
client.repourl = &repoURL{
7580
owner: repo.Owner.GetLogin(),
@@ -82,7 +87,7 @@ func (client *Client) InitRepo(inputRepo clients.Repo, commitSHA string) error {
8287
client.tarball.init(client.ctx, client.repo, commitSHA)
8388

8489
// Setup GraphQL.
85-
client.graphClient.init(client.ctx, client.repourl)
90+
client.graphClient.init(client.ctx, client.repourl, client.commitDepth)
8691

8792
// Setup contributorsHandler.
8893
client.contributors.init(client.ctx, client.repourl)
@@ -138,6 +143,7 @@ func (client *Client) ListCommits() ([]clients.Commit, error) {
138143

139144
// ListIssues implements RepoClient.ListIssues.
140145
func (client *Client) ListIssues() ([]clients.Issue, error) {
146+
// here you would need to pass commitDepth or something
141147
return client.graphClient.getIssues()
142148
}
143149

@@ -295,7 +301,7 @@ func CreateOssFuzzRepoClient(ctx context.Context, logger *log.Logger) (clients.R
295301
}
296302

297303
ossFuzzRepoClient := CreateGithubRepoClient(ctx, logger)
298-
if err := ossFuzzRepoClient.InitRepo(ossFuzzRepo, clients.HeadSHA); err != nil {
304+
if err := ossFuzzRepoClient.InitRepo(ossFuzzRepo, clients.HeadSHA, 0); err != nil {
299305
return nil, fmt.Errorf("error during InitRepo: %w", err)
300306
}
301307
return ossFuzzRepoClient, nil

clients/githubrepo/graphql.go

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const (
3636
issueCommentsToAnalyze = 30
3737
reviewsToAnalyze = 30
3838
labelsToAnalyze = 30
39-
commitsToAnalyze = 30
4039
)
4140

4241
var errNotCached = errors.New("result not cached")
@@ -100,7 +99,12 @@ type graphqlData struct {
10099
}
101100
} `graphql:"associatedPullRequests(first: $pullRequestsToAnalyze)"`
102101
}
103-
} `graphql:"history(first: $commitsToAnalyze)"`
102+
PageInfo struct {
103+
StartCursor githubv4.String
104+
EndCursor githubv4.String
105+
HasNextPage bool
106+
}
107+
} `graphql:"history(first: $commitsToAnalyze, after: $historyCursor)"`
104108
} `graphql:"... on Commit"`
105109
} `graphql:"object(expression: $commitExpression)"`
106110
Issues struct {
@@ -183,9 +187,10 @@ type graphqlHandler struct {
183187
commits []clients.Commit
184188
issues []clients.Issue
185189
archived bool
190+
commitDepth int
186191
}
187192

188-
func (handler *graphqlHandler) init(ctx context.Context, repourl *repoURL) {
193+
func (handler *graphqlHandler) init(ctx context.Context, repourl *repoURL, commitDepth int) {
189194
handler.ctx = ctx
190195
handler.repourl = repourl
191196
handler.data = new(graphqlData)
@@ -195,6 +200,32 @@ func (handler *graphqlHandler) init(ctx context.Context, repourl *repoURL) {
195200
handler.setupCheckRunsOnce = new(sync.Once)
196201
handler.checkRuns = checkRunCache{}
197202
handler.logger = log.NewLogger(log.DefaultLevel)
203+
handler.commitDepth = commitDepth
204+
}
205+
206+
func populateCommits(handler *graphqlHandler, vars map[string]interface{}) ([]clients.Commit, error) {
207+
var allCommits []clients.Commit
208+
var commitsLeft githubv4.Int
209+
commitsLeft, ok := vars["commitsToAnalyze"].(githubv4.Int)
210+
if !ok {
211+
return nil, nil
212+
}
213+
for vars["commitsToAnalyze"] = githubv4.Int(100); commitsLeft > 0; commitsLeft = commitsLeft - 100 {
214+
if commitsLeft < 100 {
215+
vars["commitsToAnalyze"] = commitsLeft
216+
}
217+
err := handler.client.Query(handler.ctx, handler.data, vars)
218+
if err != nil {
219+
return nil, fmt.Errorf("failed to populate commits: %w", err)
220+
}
221+
vars["historyCursor"] = handler.data.Repository.Object.Commit.History.PageInfo.EndCursor
222+
tmp, err := commitsFrom(handler.data, handler.repourl.owner, handler.repourl.repo)
223+
if err != nil {
224+
return nil, fmt.Errorf("failed to populate commits: %w", err)
225+
}
226+
allCommits = append(allCommits, tmp...)
227+
}
228+
return allCommits, nil
198229
}
199230

200231
func (handler *graphqlHandler) setup() error {
@@ -208,19 +239,24 @@ func (handler *graphqlHandler) setup() error {
208239
"issueCommentsToAnalyze": githubv4.Int(issueCommentsToAnalyze),
209240
"reviewsToAnalyze": githubv4.Int(reviewsToAnalyze),
210241
"labelsToAnalyze": githubv4.Int(labelsToAnalyze),
211-
"commitsToAnalyze": githubv4.Int(commitsToAnalyze),
242+
"commitsToAnalyze": githubv4.Int(handler.commitDepth),
212243
"commitExpression": githubv4.String(commitExpression),
244+
"historyCursor": (*githubv4.String)(nil),
245+
}
246+
// if NumberOfCommits set to < 99 we are required by the graphql to page by 100 commits.
247+
if handler.commitDepth > 99 {
248+
handler.commits, handler.errSetup = populateCommits(handler, vars)
249+
handler.issues = issuesFrom(handler.data)
250+
handler.archived = bool(handler.data.Repository.IsArchived)
251+
return
213252
}
214253
if err := handler.client.Query(handler.ctx, handler.data, vars); err != nil {
215254
handler.errSetup = sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("githubv4.Query: %v", err))
216255
return
217256
}
218-
handler.archived = bool(handler.data.Repository.IsArchived)
219257
handler.commits, handler.errSetup = commitsFrom(handler.data, handler.repourl.owner, handler.repourl.repo)
220-
if handler.errSetup != nil {
221-
return
222-
}
223258
handler.issues = issuesFrom(handler.data)
259+
handler.archived = bool(handler.data.Repository.IsArchived)
224260
})
225261
return handler.errSetup
226262
}
@@ -232,10 +268,16 @@ func (handler *graphqlHandler) setupCheckRuns() error {
232268
"owner": githubv4.String(handler.repourl.owner),
233269
"name": githubv4.String(handler.repourl.repo),
234270
"pullRequestsToAnalyze": githubv4.Int(pullRequestsToAnalyze),
235-
"commitsToAnalyze": githubv4.Int(commitsToAnalyze),
271+
"commitsToAnalyze": githubv4.Int(handler.commitDepth),
236272
"commitExpression": githubv4.String(commitExpression),
237273
"checksToAnalyze": githubv4.Int(checksToAnalyze),
238274
}
275+
// TODO(#2224):
276+
// sast and ci checks causes cache miss if commits dont match number of check runs.
277+
// paging for this needs to be implemented if using higher than 100 --number-of-commits
278+
if handler.commitDepth > 99 {
279+
vars["commitsToAnalyze"] = githubv4.Int(99)
280+
}
239281
if err := handler.client.Query(handler.ctx, handler.checkData, vars); err != nil {
240282
// quit early without setting crsErrSetup for "Resource not accessible by integration" error
241283
// for whatever reason, this check doesn't work with a GITHUB_TOKEN, only a PAT
@@ -325,7 +367,7 @@ func parseCheckRuns(data *checkRunsGraphqlData) checkRunCache {
325367
return checkCache
326368
}
327369

328-
//nolint
370+
// nolint
329371
func commitsFrom(data *graphqlData, repoOwner, repoName string) ([]clients.Commit, error) {
330372
ret := make([]clients.Commit, 0)
331373
for _, commit := range data.Repository.Object.Commit.History.Nodes {

clients/githubrepo/graphql_e2e_test.go

Lines changed: 109 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ package githubrepo
1616

1717
import (
1818
"context"
19+
"net/http"
1920

2021
. "github.com/onsi/ginkgo/v2"
2122
. "github.com/onsi/gomega"
23+
"github.com/shurcooL/githubv4"
2224

2325
"github.com/ossf/scorecard/v4/clients"
26+
"github.com/ossf/scorecard/v4/clients/githubrepo/roundtripper"
27+
"github.com/ossf/scorecard/v4/log"
2428
)
2529

2630
var _ = Describe("E2E TEST: githubrepo.graphqlHandler", func() {
@@ -32,14 +36,116 @@ var _ = Describe("E2E TEST: githubrepo.graphqlHandler", func() {
3236
}
3337
})
3438

39+
Context("E2E TEST: Confirm Paging Commits Works", func() {
40+
It("Should only have 1 commit", func() {
41+
_repourl := &repoURL{
42+
owner: "ossf",
43+
repo: "scorecard",
44+
commitSHA: clients.HeadSHA,
45+
}
46+
_vars := map[string]interface{}{
47+
"owner": githubv4.String("ossf"),
48+
"name": githubv4.String("scorecard"),
49+
"pullRequestsToAnalyze": githubv4.Int(1),
50+
"issuesToAnalyze": githubv4.Int(30),
51+
"issueCommentsToAnalyze": githubv4.Int(30),
52+
"reviewsToAnalyze": githubv4.Int(30),
53+
"labelsToAnalyze": githubv4.Int(30),
54+
"commitsToAnalyze": githubv4.Int(1),
55+
"commitExpression": githubv4.String("heads/main"),
56+
"historyCursor": (*githubv4.String)(nil),
57+
}
58+
_ctx := context.Background()
59+
_logger := log.NewLogger(log.DebugLevel)
60+
_rt := roundtripper.NewTransport(_ctx, _logger)
61+
_httpClient := &http.Client{
62+
Transport: _rt,
63+
}
64+
_graphClient := githubv4.NewClient(_httpClient)
65+
_handler := &graphqlHandler{
66+
client: _graphClient,
67+
}
68+
_handler.init(context.Background(), _repourl, 1)
69+
commits, err := populateCommits(_handler, _vars)
70+
Expect(err).To(BeNil())
71+
Expect(len(commits)).Should(BeEquivalentTo(1))
72+
})
73+
It("Should have 30 commits", func() {
74+
_repourl := &repoURL{
75+
owner: "ossf",
76+
repo: "scorecard",
77+
commitSHA: clients.HeadSHA,
78+
}
79+
_vars := map[string]interface{}{
80+
"owner": githubv4.String("ossf"),
81+
"name": githubv4.String("scorecard"),
82+
"pullRequestsToAnalyze": githubv4.Int(1),
83+
"issuesToAnalyze": githubv4.Int(30),
84+
"issueCommentsToAnalyze": githubv4.Int(30),
85+
"reviewsToAnalyze": githubv4.Int(30),
86+
"labelsToAnalyze": githubv4.Int(30),
87+
"commitsToAnalyze": githubv4.Int(30),
88+
"commitExpression": githubv4.String("heads/main"),
89+
"historyCursor": (*githubv4.String)(nil),
90+
}
91+
_ctx := context.Background()
92+
_logger := log.NewLogger(log.DebugLevel)
93+
_rt := roundtripper.NewTransport(_ctx, _logger)
94+
_httpClient := &http.Client{
95+
Transport: _rt,
96+
}
97+
_graphClient := githubv4.NewClient(_httpClient)
98+
_handler := &graphqlHandler{
99+
client: _graphClient,
100+
}
101+
_handler.init(context.Background(), _repourl, 30)
102+
commits, err := populateCommits(_handler, _vars)
103+
Expect(err).To(BeNil())
104+
Expect(len(commits)).Should(BeEquivalentTo(30))
105+
})
106+
It("Should have 101 commits", func() {
107+
_repourl := &repoURL{
108+
owner: "ossf",
109+
repo: "scorecard",
110+
commitSHA: clients.HeadSHA,
111+
}
112+
_vars := map[string]interface{}{
113+
"owner": githubv4.String("ossf"),
114+
"name": githubv4.String("scorecard"),
115+
"pullRequestsToAnalyze": githubv4.Int(1),
116+
"issuesToAnalyze": githubv4.Int(30),
117+
"issueCommentsToAnalyze": githubv4.Int(30),
118+
"reviewsToAnalyze": githubv4.Int(30),
119+
"labelsToAnalyze": githubv4.Int(30),
120+
"commitsToAnalyze": githubv4.Int(101),
121+
"commitExpression": githubv4.String("heads/main"),
122+
"historyCursor": (*githubv4.String)(nil),
123+
}
124+
_ctx := context.Background()
125+
_logger := log.NewLogger(log.DebugLevel)
126+
_rt := roundtripper.NewTransport(_ctx, _logger)
127+
_httpClient := &http.Client{
128+
Transport: _rt,
129+
}
130+
_graphClient := githubv4.NewClient(_httpClient)
131+
_handler := &graphqlHandler{
132+
client: _graphClient,
133+
}
134+
_handler.init(context.Background(), _repourl, 101)
135+
commits, err := populateCommits(_handler, _vars)
136+
Expect(err).To(BeNil())
137+
Expect(len(commits)).Should(BeEquivalentTo(101))
138+
})
139+
})
140+
35141
Context("E2E TEST: Validate query cost", func() {
36142
It("Should not have increased for HEAD query", func() {
37143
repourl := &repoURL{
38144
owner: "ossf",
39145
repo: "scorecard",
40146
commitSHA: clients.HeadSHA,
41147
}
42-
graphqlhandler.init(context.Background(), repourl)
148+
graphqlhandler.init(context.Background(), repourl, 30)
43149
Expect(graphqlhandler.setup()).Should(BeNil())
44150
Expect(graphqlhandler.data).ShouldNot(BeNil())
45151
Expect(graphqlhandler.data.RateLimit.Cost).ShouldNot(BeNil())
@@ -51,7 +157,7 @@ var _ = Describe("E2E TEST: githubrepo.graphqlHandler", func() {
51157
repo: "scorecard",
52158
commitSHA: "de5224bbc56eceb7a25aece55d2d53bbc561ed2d",
53159
}
54-
graphqlhandler.init(context.Background(), repourl)
160+
graphqlhandler.init(context.Background(), repourl, 30)
55161
Expect(graphqlhandler.setup()).Should(BeNil())
56162
Expect(graphqlhandler.data).ShouldNot(BeNil())
57163
Expect(graphqlhandler.data.RateLimit.Cost).ShouldNot(BeNil())
@@ -63,7 +169,7 @@ var _ = Describe("E2E TEST: githubrepo.graphqlHandler", func() {
63169
repo: "scorecard",
64170
commitSHA: clients.HeadSHA,
65171
}
66-
graphqlhandler.init(context.Background(), repourl)
172+
graphqlhandler.init(context.Background(), repourl, 30)
67173
Expect(graphqlhandler.setupCheckRuns()).Should(BeNil())
68174
Expect(graphqlhandler.checkData).ShouldNot(BeNil())
69175
Expect(graphqlhandler.checkData.RateLimit.Cost).ShouldNot(BeNil())

0 commit comments

Comments
 (0)