Skip to content

Commit

Permalink
foo!
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Schrock <[email protected]>
  • Loading branch information
spencerschrock committed Apr 24, 2024
1 parent 2c06bea commit cc97442
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
5 changes: 4 additions & 1 deletion probes/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ossf/scorecard/v5/probes/createdRecently"
"github.com/ossf/scorecard/v5/probes/dependencyUpdateToolConfigured"
"github.com/ossf/scorecard/v5/probes/dismissesStaleReviews"
"github.com/ossf/scorecard/v5/probes/foo"
"github.com/ossf/scorecard/v5/probes/fuzzed"
"github.com/ossf/scorecard/v5/probes/hasBinaryArtifacts"
"github.com/ossf/scorecard/v5/probes/hasDangerousWorkflowScriptInjection"
Expand Down Expand Up @@ -165,7 +166,9 @@ var (
}

// Probes which don't use pre-computed raw data but rather collect it themselves.
Independent = []IndependentProbeImpl{}
Independent = []IndependentProbeImpl{
foo.Run,
}
)

//nolint:gochecknoinits
Expand Down
27 changes: 27 additions & 0 deletions probes/foo/def.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 OpenSSF 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.

id: foo
short: foo
motivation: >
foo
implementation: >
believe it or not, foo.
outcome:
- foo!
remediation:
onOutcome: False
effort: Low
text:
- foo?
55 changes: 55 additions & 0 deletions probes/foo/impl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2024 OpenSSF 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 foo

import (
"embed"
"fmt"

"github.com/ossf/scorecard/v5/checker"
"github.com/ossf/scorecard/v5/finding"
"github.com/ossf/scorecard/v5/internal/probes"
"github.com/ossf/scorecard/v5/probes/internal/utils/uerror"
)

func init() {
probes.MustRegisterIndependent(Probe, Run)
}

//go:embed *.yml
var fs embed.FS

const Probe = "foo"

func Run(cr *checker.CheckRequest) ([]finding.Finding, string, error) {
if cr == nil {
return nil, "", fmt.Errorf("%w: check request", uerror.ErrNil)
}

name, err := cr.RepoClient.GetDefaultBranchName()
if err != nil {
return nil, Probe, fmt.Errorf("fetching default branch name: %w", err)
}
f, err := finding.New(fs, Probe)
if err != nil {
return nil, Probe, fmt.Errorf("create finding: %w", err)
}
if name == "foo" {
f.WithMessage("foo!").WithOutcome(finding.OutcomeTrue)
} else {
f.WithMessage("not foo!!").WithOutcome(finding.OutcomeFalse)
}
return []finding.Finding{*f}, Probe, nil
}

0 comments on commit cc97442

Please sign in to comment.