Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix GitHub workflows failing #1172

Merged
merged 2 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
uses: actions/setup-go@331ce1d993939866bb63c32c6cbbfd48fa76fc57 # v2.1.3
with:
go-version: '^1.17'
azeemshaikh38 marked this conversation as resolved.
Show resolved Hide resolved
- name: Install tools
run: make install
- name: Run presubmit tests
run: |
go env -w GOFLAGS=-mod=mod
Expand All @@ -50,6 +52,7 @@ jobs:
- name: Check license headers
run: |
go env -w GOFLAGS=-mod=mod
make install
make all
set -e
addlicense -ignore "**/script-empty.sh" -ignore "pkg/testdata/*" -ignore "checks/testdata/*" -l apache -c 'Security Scorecard Authors' -v *
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ dockerbuild: ## Runs docker build
DOCKER_BUILDKIT=1 docker build . --file Dockerfile --tag $(IMAGE_NAME)
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) KO_DOCKER_REPO=${KO_PREFIX}/scorecard-ko CGO_ENABLED=0 LDFLAGS="$(LDFLAGS)" \
ko publish -B --bare --local \
--platform=all \
azeemshaikh38 marked this conversation as resolved.
Show resolved Hide resolved
--platform=linux/amd64,linux/arm64,linux/386,linux/arm,darwin/amd64,darwin/arm64,windows/amd64,windows/386,windows/arm64,windows/arm \
--push=false \
--tags latest,$(GIT_VERSION),$(GIT_HASH) github.com/ossf/scorecard/v3
DOCKER_BUILDKIT=1 docker build . --file cron/controller/Dockerfile --tag $(IMAGE_NAME)-batch-controller
Expand Down
1 change: 1 addition & 0 deletions checks/pinned_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ func getOSesForJob(job *gitHubActionWorkflowJob) ([]string, error) {
return job.RunsOn, nil
}
jobOSes := make([]string, 0)
// nolint: nestif
if m, ok := job.Strategy.Matrix.(map[string]interface{}); ok {
if osVal, ok := m["os"]; ok {
if oses, ok := osVal.([]interface{}); ok {
Expand Down
31 changes: 15 additions & 16 deletions checks/pinned_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package checks

import (
"fmt"
"io/ioutil"
"strings"
"testing"
Expand Down Expand Up @@ -111,7 +110,7 @@ func TestGithubWorkflowPinning(t *testing.T) {

content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}

dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -202,7 +201,7 @@ func TestNonGithubWorkflowPinning(t *testing.T) {
} else {
content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}
}
dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -247,7 +246,7 @@ func TestGithubWorkflowPkgManagerPinning(t *testing.T) {

content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}

dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -371,7 +370,7 @@ func TestDockerfilePinning(t *testing.T) {
} else {
content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}
}
dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -415,7 +414,7 @@ func TestDockerfilePinningWihoutHash(t *testing.T) {

content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}
dl := scut.TestDetailLogger{}
s, e := testValidateDockerfileIsPinned(tt.filename, content, &dl)
Expand Down Expand Up @@ -600,7 +599,7 @@ func TestDockerfileScriptDownload(t *testing.T) {
} else {
content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}
}
dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -644,7 +643,7 @@ func TestDockerfileScriptDownloadInfo(t *testing.T) {

content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}
dl := scut.TestDetailLogger{}
s, e := testValidateDockerfileIsFreeOfInsecureDownloads(tt.filename, content, &dl)
Expand Down Expand Up @@ -753,7 +752,7 @@ func TestShellScriptDownload(t *testing.T) {
} else {
content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}
}
dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -808,7 +807,7 @@ func TestShellScriptDownloadPinned(t *testing.T) {

content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}

dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -885,7 +884,7 @@ func TestGitHubWorflowRunDownload(t *testing.T) {
} else {
content, err = ioutil.ReadFile(tt.filename)
if err != nil {
panic(fmt.Errorf("cannot read file: %w", err))
t.Errorf("cannot read file: %v", err)
}
}
dl := scut.TestDetailLogger{}
Expand Down Expand Up @@ -948,13 +947,13 @@ func TestGitHubWorkflowUsesLineNumber(t *testing.T) {
t.Parallel()
content, err := ioutil.ReadFile(tt.filename)
if err != nil {
t.Errorf("cannot read file: %w", err)
t.Errorf("cannot read file: %v", err)
}
dl := scut.TestDetailLogger{}
var pinned worklowPinningResult
_, err = validateGitHubActionWorkflow(tt.filename, content, &dl, &pinned)
if err != nil {
t.Errorf("error during validateGitHubActionWorkflow: %w", err)
t.Errorf("error during validateGitHubActionWorkflow: %v", err)
}
for _, expectedLog := range tt.expected {
isExpectedLog := func(logMessage checker.LogMessage, logType checker.DetailType) bool {
Expand Down Expand Up @@ -1059,12 +1058,12 @@ func TestGitHubWorkflowShell(t *testing.T) {
t.Parallel()
content, err := ioutil.ReadFile(tt.filename)
if err != nil {
t.Errorf("cannot read file: %w", err)
t.Errorf("cannot read file: %v", err)
}
var workflow gitHubActionWorkflowConfig
err = yaml.Unmarshal(content, &workflow)
if err != nil {
t.Errorf("cannot unmarshal file: %w", err)
t.Errorf("cannot unmarshal file: %v", err)
}
actualShells := make([]string, 0)
for _, job := range workflow.Jobs {
Expand All @@ -1073,7 +1072,7 @@ func TestGitHubWorkflowShell(t *testing.T) {
step := step
shell, err := getShellForStep(&step, &job)
if err != nil {
t.Errorf("error getting shell: %w", err)
t.Errorf("error getting shell: %v", err)
}
actualShells = append(actualShells, shell)
}
Expand Down
2 changes: 1 addition & 1 deletion checks/shell_download_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestIsSupportedShellScriptFile(t *testing.T) {
var err error
content, err = ioutil.ReadFile(tt.filename)
if err != nil {
t.Errorf("cannot read file: %w", err)
t.Errorf("cannot read file: %v", err)
}
result := isSupportedShellScriptFile(tt.filename, content)
if result != tt.expected {
Expand Down
2 changes: 1 addition & 1 deletion cron/data/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestGetBlobFilename(t *testing.T) {
t.Parallel()
datetime, err := time.Parse(inputTimeFormat, testcase.inputTime)
if err != nil {
t.Errorf("failed to parse testcase.inputTime %s: %w", testcase.inputTime, err)
t.Errorf("failed to parse testcase.inputTime %s: %v", testcase.inputTime, err)
}
gotFilename := GetBlobFilename(testcase.inputFilename, datetime)
if gotFilename != testcase.expectedFilename {
Expand Down
1 change: 0 additions & 1 deletion pkg/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func getRepoCommitHash(r clients.RepoClient, uri *repos.RepoURI) (string, error)
switch uri.RepoType() {
// URL.
case repos.RepoTypeURL:
//nolint:unwrapped
commits, err := r.ListCommits()
if err != nil {
return "", sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("ListCommits:%v", err.Error()))
Expand Down