Skip to content

Commit

Permalink
Merge branch 'main' into lint/gomoddirectives
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerschrock authored Oct 23, 2023
2 parents 76ed6b4 + 2391edf commit ae0379d
Show file tree
Hide file tree
Showing 46 changed files with 409 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/depsreview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: 'Dependency Review'
uses: actions/dependency-review-action@6c5ccdad469c9f8a2996bfecaec55a631a347034
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
docs_only: ${{ steps.docs_only_check.outputs.docs_only }}
steps:
- name: Check out code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 #v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 2 # needed to diff changed files
- id: files
name: Get changed files
uses: tj-actions/changed-files@db153baf731265ad02cd490b07f470e2d55e3345 #v39.2.1
uses: tj-actions/changed-files@95690f9ece77c1740f4a55b7f1de9023ed6b1f87 #v39.2.3
with:
files_ignore: '**.md'
- id: docs_only_check
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Clone the code
if: (needs.docs_only_check.outputs.docs_only != 'true')
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go # needed for some of the Makefile evaluations, even if building happens in Docker
if: (needs.docs_only_check.outputs.docs_only != 'true')
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }} # head SHA if PR, else fallback to push SHA
- name: Setup Go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Set up Go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: ${{ env.GO_VERSION }}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Go
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
version: ${{ env.PROTOC_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Go
Expand Down Expand Up @@ -237,7 +237,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Go
Expand Down Expand Up @@ -324,7 +324,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Go
Expand Down Expand Up @@ -359,7 +359,7 @@ jobs:
version: ${{ env.PROTOC_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Go
Expand Down Expand Up @@ -388,7 +388,7 @@ jobs:
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v2.2.0
with:
go-version: ${{ env.GO_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publishimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Clone the code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: "Run analysis"
uses: ossf/scorecard-action@483ef80eb98fb506c348f7d62e28055e49fe2398 # v2.3.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/slsa-goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-binary-name: ${{ steps.build.outputs.go-binary-name }}
steps:
- id: checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- id: ldflags
Expand Down
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ linters:
- errorlint
- exhaustive
- exportloopref
- forbidigo
- gci
- gochecknoinits
- gocognit
Expand All @@ -53,18 +54,23 @@ linters:
- ineffassign
- lll
- makezero
- mirror
- misspell
- nakedret
- nestif
- predeclared
- staticcheck
- stylecheck
- tenv
- thelper
- typecheck
- unconvert
- unused
- usestdlibvars
- whitespace
- wrapcheck
presets:
- bugs
linters-settings:
errcheck:
check-type-assertions: true
Expand All @@ -76,6 +82,10 @@ linters-settings:
exhaustive:
# https://golangci-lint.run/usage/linters/#exhaustive
default-signifies-exhaustive: true
forbidigo:
forbid:
- p: "^fmt\\.Print.*$"
msg: "Do not commit print statements. Output to stdout interferes with users who redirect JSON results to files."
govet:
enable:
- fieldalignment
Expand Down
2 changes: 1 addition & 1 deletion attestor/command/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func init() {

func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
2 changes: 1 addition & 1 deletion attestor/policy/attestation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
sclog "github.com/ossf/scorecard/v4/log"
)

//nolint:govet
//nolint:govet,musttag // JSON usage is test only
type AttestationPolicy struct {
// PreventBinaryArtifacts : set to true to require that this project's SCM repo is
// free of binary artifacts
Expand Down
5 changes: 2 additions & 3 deletions attestor/policy/attestation_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package policy
import (
"encoding/json"
"errors"
"fmt"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -533,8 +532,8 @@ func TestAttestationPolicyRead(t *testing.T) {
// Compare outputs only if the error is nil.
// TODO: compare objects.
if p.ToJSON() != tt.result.ToJSON() {
fmt.Printf("p.ToJSON(): %v\n", p.ToJSON())
fmt.Printf("tt.result.ToJSON(): %v\n", tt.result.ToJSON())
t.Logf("p.ToJSON(): %v\n", p.ToJSON())
t.Logf("tt.result.ToJSON(): %v\n", tt.result.ToJSON())
t.Fatalf("%s: invalid result", tt.name)
}
})
Expand Down
19 changes: 12 additions & 7 deletions checks/raw/fuzzing.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,28 @@ var languageFuzzSpecs = map[clients.LanguageName]languageFuzzConfig{
// Fuzz patterns for JavaScript and TypeScript based on property-based testing.
//
// Based on the import of one of these packages:
// * https://fast-check.dev/
// * https://github.com/dubzzz/fast-check/tree/main/packages/fast-check#readme
// * https://github.com/dubzzz/fast-check/tree/main/packages/ava#readme
// * https://github.com/dubzzz/fast-check/tree/main/packages/jest#readme
// * https://github.com/dubzzz/fast-check/tree/main/packages/vitest#readme
//
// This is not an exhaustive list.
clients.JavaScript: {
filePatterns: []string{"*.js"},
// Look for direct imports of fast-check.
funcPattern: `(from\s+['"]fast-check['"]|require\(\s*['"]fast-check['"]\s*\))`,
Name: fuzzerPropertyBasedJavaScript,
// Look for direct imports of fast-check and its test runners integrations.
funcPattern: `(from\s+['"](fast-check|@fast-check/(ava|jest|vitest))['"]|` +
`require\(\s*['"](fast-check|@fast-check/(ava|jest|vitest))['"]\s*\))`,
Name: fuzzerPropertyBasedJavaScript,
Desc: asPointer(
"Property-based testing in JavaScript generates test instances randomly or exhaustively " +
"and test that specific properties are satisfied."),
},
clients.TypeScript: {
filePatterns: []string{"*.ts"},
// Look for direct imports of fast-check.
funcPattern: `(from\s+['"]fast-check['"]|require\(\s*['"]fast-check['"]\s*\))`,
Name: fuzzerPropertyBasedTypeScript,
// Look for direct imports of fast-check and its test runners integrations.
funcPattern: `(from\s+['"](fast-check|@fast-check/(ava|jest|vitest))['"]|` +
`require\(\s*['"](fast-check|@fast-check/(ava|jest|vitest))['"]\s*\))`,
Name: fuzzerPropertyBasedTypeScript,
Desc: asPointer(
"Property-based testing in TypeScript generates test instances randomly or exhaustively " +
"and test that specific properties are satisfied."),
Expand Down
48 changes: 48 additions & 0 deletions checks/raw/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,30 @@ func Test_checkFuzzFunc(t *testing.T) {
},
fileContent: "import fc from \"fast-check\";",
},
{
name: "JavaScript fast-check scoped via require",
want: true,
fileName: []string{"main.spec.js"},
langs: []clients.Language{
{
Name: clients.JavaScript,
NumLines: 50,
},
},
fileContent: "const { fc, testProp } = require('@fast-check/ava');",
},
{
name: "JavaScript fast-check scoped via import",
want: true,
fileName: []string{"main.spec.js"},
langs: []clients.Language{
{
Name: clients.JavaScript,
NumLines: 50,
},
},
fileContent: "import { fc, test } from \"@fast-check/jest\";",
},
{
name: "JavaScript with no property-based testing",
want: false,
Expand Down Expand Up @@ -477,6 +501,30 @@ func Test_checkFuzzFunc(t *testing.T) {
},
fileContent: "import fc from \"fast-check\";",
},
{
name: "TypeScript fast-check scoped via require",
want: true,
fileName: []string{"main.spec.ts"},
langs: []clients.Language{
{
Name: clients.TypeScript,
NumLines: 50,
},
},
fileContent: "const { fc, testProp } = require('@fast-check/ava');",
},
{
name: "TypeScript fast-check scoped via import",
want: true,
fileName: []string{"main.spec.ts"},
langs: []clients.Language{
{
Name: clients.TypeScript,
NumLines: 50,
},
},
fileContent: "import { fc, test } from \"@fast-check/vitest\";",
},
{
name: "TypeScript with no property-based testing",
want: false,
Expand Down
7 changes: 6 additions & 1 deletion checks/sast.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const CheckSAST = "SAST"

var errInvalid = errors.New("invalid")

var sastTools = map[string]bool{"github-code-scanning": true, "lgtm-com": true, "sonarcloud": true}
var sastTools = map[string]bool{
"github-advanced-security": true,
"github-code-scanning": true,
"lgtm-com": true,
"sonarcloud": true,
}

var allowedConclusions = map[string]bool{"success": true, "neutral": true}

Expand Down
Loading

0 comments on commit ae0379d

Please sign in to comment.