2023-05-23 04:13:24 +03:00
|
|
|
// Copyright 2023 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 probes
|
|
|
|
|
|
|
|
import (
|
2023-12-12 20:38:50 +03:00
|
|
|
"errors"
|
|
|
|
|
2023-05-23 04:13:24 +03:00
|
|
|
"github.com/ossf/scorecard/v4/checker"
|
|
|
|
"github.com/ossf/scorecard/v4/finding"
|
2023-10-25 00:02:18 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/contributorsFromOrgOrCompany"
|
2023-12-05 11:24:16 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/freeOfUnverifiedBinaryArtifacts"
|
2023-10-10 01:41:58 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithCLibFuzzer"
|
2023-08-21 20:50:20 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithClusterFuzzLite"
|
2023-10-10 01:41:58 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithCppLibFuzzer"
|
2023-08-21 20:50:20 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithGoNative"
|
2023-10-10 01:41:58 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithJavaJazzerFuzzer"
|
2023-08-21 20:50:20 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithOSSFuzz"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithPropertyBasedHaskell"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithPropertyBasedJavascript"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithPropertyBasedTypescript"
|
2023-10-10 01:41:58 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithPythonAtheris"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithRustCargofuzz"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/fuzzedWithSwiftLibFuzzer"
|
2023-11-07 00:43:03 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/hasDangerousWorkflowScriptInjection"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/hasDangerousWorkflowUntrustedCheckout"
|
2023-10-24 21:48:41 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/hasFSFOrOSIApprovedLicense"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/hasLicenseFile"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/hasLicenseFileAtTopDir"
|
2023-10-25 20:02:24 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/hasOSVVulnerabilities"
|
2023-11-28 23:02:26 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/hasOpenSSFBadge"
|
2023-11-17 20:57:10 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/hasRecentCommits"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/issueActivityByProjectMember"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/notArchived"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/notCreatedRecently"
|
2023-10-24 22:12:05 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/packagedWithAutomatedWorkflow"
|
2023-11-07 16:41:44 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/sastToolCodeQLInstalled"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/sastToolRunsOnAllCommits"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/sastToolSonarInstalled"
|
2023-08-04 07:52:15 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/securityPolicyContainsLinks"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/securityPolicyContainsText"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/securityPolicyContainsVulnerabilityDisclosure"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/securityPolicyPresent"
|
2023-12-11 21:15:50 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/testsRunInCI"
|
2023-05-23 04:13:24 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/toolDependabotInstalled"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/toolPyUpInstalled"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/toolRenovateInstalled"
|
2023-12-05 21:59:42 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes/webhooksUseSecrets"
|
2023-05-23 04:13:24 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// ProbeImpl is the implementation of a probe.
|
|
|
|
type ProbeImpl func(*checker.RawResults) ([]finding.Finding, string, error)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// All represents all the probes.
|
|
|
|
All []ProbeImpl
|
2023-08-04 07:52:15 +03:00
|
|
|
// SecurityPolicy is all the probes for the
|
|
|
|
// SecurityPolicy check.
|
|
|
|
SecurityPolicy = []ProbeImpl{
|
|
|
|
securityPolicyPresent.Run,
|
|
|
|
securityPolicyContainsLinks.Run,
|
|
|
|
securityPolicyContainsVulnerabilityDisclosure.Run,
|
|
|
|
securityPolicyContainsText.Run,
|
|
|
|
}
|
2023-05-23 04:13:24 +03:00
|
|
|
// DependencyToolUpdates is all the probes for the
|
|
|
|
// DpendencyUpdateTool check.
|
|
|
|
DependencyToolUpdates = []ProbeImpl{
|
|
|
|
toolRenovateInstalled.Run,
|
|
|
|
toolDependabotInstalled.Run,
|
|
|
|
toolPyUpInstalled.Run,
|
|
|
|
}
|
2023-08-21 20:50:20 +03:00
|
|
|
Fuzzing = []ProbeImpl{
|
|
|
|
fuzzedWithOSSFuzz.Run,
|
|
|
|
fuzzedWithGoNative.Run,
|
2023-10-10 01:41:58 +03:00
|
|
|
fuzzedWithPythonAtheris.Run,
|
|
|
|
fuzzedWithCLibFuzzer.Run,
|
|
|
|
fuzzedWithCppLibFuzzer.Run,
|
|
|
|
fuzzedWithSwiftLibFuzzer.Run,
|
|
|
|
fuzzedWithRustCargofuzz.Run,
|
|
|
|
fuzzedWithJavaJazzerFuzzer.Run,
|
2023-08-21 20:50:20 +03:00
|
|
|
fuzzedWithClusterFuzzLite.Run,
|
|
|
|
fuzzedWithPropertyBasedHaskell.Run,
|
|
|
|
fuzzedWithPropertyBasedTypescript.Run,
|
|
|
|
fuzzedWithPropertyBasedJavascript.Run,
|
|
|
|
}
|
2023-10-24 22:12:05 +03:00
|
|
|
Packaging = []ProbeImpl{
|
|
|
|
packagedWithAutomatedWorkflow.Run,
|
|
|
|
}
|
2023-10-24 21:48:41 +03:00
|
|
|
License = []ProbeImpl{
|
|
|
|
hasLicenseFile.Run,
|
|
|
|
hasFSFOrOSIApprovedLicense.Run,
|
|
|
|
hasLicenseFileAtTopDir.Run,
|
|
|
|
}
|
2023-10-25 00:02:18 +03:00
|
|
|
Contributors = []ProbeImpl{
|
|
|
|
contributorsFromOrgOrCompany.Run,
|
|
|
|
}
|
2023-10-25 20:02:24 +03:00
|
|
|
Vulnerabilities = []ProbeImpl{
|
|
|
|
hasOSVVulnerabilities.Run,
|
|
|
|
}
|
2023-11-07 16:41:44 +03:00
|
|
|
SAST = []ProbeImpl{
|
|
|
|
sastToolCodeQLInstalled.Run,
|
|
|
|
sastToolRunsOnAllCommits.Run,
|
|
|
|
sastToolSonarInstalled.Run,
|
|
|
|
}
|
2023-11-07 00:43:03 +03:00
|
|
|
DangerousWorkflows = []ProbeImpl{
|
|
|
|
hasDangerousWorkflowScriptInjection.Run,
|
|
|
|
hasDangerousWorkflowUntrustedCheckout.Run,
|
|
|
|
}
|
2023-11-17 20:57:10 +03:00
|
|
|
Maintained = []ProbeImpl{
|
|
|
|
notArchived.Run,
|
|
|
|
hasRecentCommits.Run,
|
|
|
|
issueActivityByProjectMember.Run,
|
|
|
|
notCreatedRecently.Run,
|
|
|
|
}
|
2023-11-28 23:02:26 +03:00
|
|
|
CIIBestPractices = []ProbeImpl{
|
|
|
|
hasOpenSSFBadge.Run,
|
|
|
|
}
|
2023-12-05 11:24:16 +03:00
|
|
|
BinaryArtifacts = []ProbeImpl{
|
|
|
|
freeOfUnverifiedBinaryArtifacts.Run,
|
|
|
|
}
|
2023-12-05 21:59:42 +03:00
|
|
|
Webhook = []ProbeImpl{
|
|
|
|
webhooksUseSecrets.Run,
|
|
|
|
}
|
2023-12-11 21:15:50 +03:00
|
|
|
CITests = []ProbeImpl{
|
|
|
|
testsRunInCI.Run,
|
|
|
|
}
|
2023-12-12 20:38:50 +03:00
|
|
|
|
|
|
|
probeRunners = map[string]func(*checker.RawResults) ([]finding.Finding, string, error){
|
|
|
|
securityPolicyPresent.Probe: securityPolicyPresent.Run,
|
|
|
|
securityPolicyContainsLinks.Probe: securityPolicyContainsLinks.Run,
|
|
|
|
securityPolicyContainsVulnerabilityDisclosure.Probe: securityPolicyContainsVulnerabilityDisclosure.Run,
|
|
|
|
securityPolicyContainsText.Probe: securityPolicyContainsText.Run,
|
|
|
|
toolRenovateInstalled.Probe: toolRenovateInstalled.Run,
|
|
|
|
toolDependabotInstalled.Probe: toolDependabotInstalled.Run,
|
|
|
|
toolPyUpInstalled.Probe: toolPyUpInstalled.Run,
|
|
|
|
fuzzedWithOSSFuzz.Probe: fuzzedWithOSSFuzz.Run,
|
|
|
|
fuzzedWithGoNative.Probe: fuzzedWithGoNative.Run,
|
|
|
|
fuzzedWithPythonAtheris.Probe: fuzzedWithPythonAtheris.Run,
|
|
|
|
fuzzedWithCLibFuzzer.Probe: fuzzedWithCLibFuzzer.Run,
|
|
|
|
fuzzedWithCppLibFuzzer.Probe: fuzzedWithCppLibFuzzer.Run,
|
|
|
|
fuzzedWithSwiftLibFuzzer.Probe: fuzzedWithSwiftLibFuzzer.Run,
|
|
|
|
fuzzedWithRustCargofuzz.Probe: fuzzedWithRustCargofuzz.Run,
|
|
|
|
fuzzedWithJavaJazzerFuzzer.Probe: fuzzedWithJavaJazzerFuzzer.Run,
|
|
|
|
fuzzedWithClusterFuzzLite.Probe: fuzzedWithClusterFuzzLite.Run,
|
|
|
|
fuzzedWithPropertyBasedHaskell.Probe: fuzzedWithPropertyBasedHaskell.Run,
|
|
|
|
fuzzedWithPropertyBasedTypescript.Probe: fuzzedWithPropertyBasedTypescript.Run,
|
|
|
|
fuzzedWithPropertyBasedJavascript.Probe: fuzzedWithPropertyBasedJavascript.Run,
|
|
|
|
packagedWithAutomatedWorkflow.Probe: packagedWithAutomatedWorkflow.Run,
|
|
|
|
hasLicenseFile.Probe: hasLicenseFile.Run,
|
|
|
|
hasFSFOrOSIApprovedLicense.Probe: hasFSFOrOSIApprovedLicense.Run,
|
|
|
|
hasLicenseFileAtTopDir.Probe: hasLicenseFileAtTopDir.Run,
|
|
|
|
contributorsFromOrgOrCompany.Probe: contributorsFromOrgOrCompany.Run,
|
|
|
|
hasOSVVulnerabilities.Probe: hasOSVVulnerabilities.Run,
|
|
|
|
sastToolCodeQLInstalled.Probe: sastToolCodeQLInstalled.Run,
|
|
|
|
sastToolRunsOnAllCommits.Probe: sastToolRunsOnAllCommits.Run,
|
|
|
|
sastToolSonarInstalled.Probe: sastToolSonarInstalled.Run,
|
|
|
|
hasDangerousWorkflowScriptInjection.Probe: hasDangerousWorkflowScriptInjection.Run,
|
|
|
|
hasDangerousWorkflowUntrustedCheckout.Probe: hasDangerousWorkflowUntrustedCheckout.Run,
|
|
|
|
notArchived.Probe: notArchived.Run,
|
|
|
|
hasRecentCommits.Probe: hasRecentCommits.Run,
|
|
|
|
issueActivityByProjectMember.Probe: issueActivityByProjectMember.Run,
|
|
|
|
notCreatedRecently.Probe: notCreatedRecently.Run,
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckMap = map[string]string{
|
|
|
|
securityPolicyPresent.Probe: "Security-Policy",
|
|
|
|
securityPolicyContainsLinks.Probe: "Security-Policy",
|
|
|
|
securityPolicyContainsVulnerabilityDisclosure.Probe: "Security-Policy",
|
|
|
|
securityPolicyContainsText.Probe: "Security-Policy",
|
|
|
|
toolRenovateInstalled.Probe: "Dependency-Update-Tool",
|
|
|
|
toolDependabotInstalled.Probe: "Dependency-Update-Tool",
|
|
|
|
toolPyUpInstalled.Probe: "Dependency-Update-Tool",
|
|
|
|
fuzzedWithOSSFuzz.Probe: "Fuzzing",
|
|
|
|
fuzzedWithGoNative.Probe: "Fuzzing",
|
|
|
|
fuzzedWithPythonAtheris.Probe: "Fuzzing",
|
|
|
|
fuzzedWithCLibFuzzer.Probe: "Fuzzing",
|
|
|
|
fuzzedWithCppLibFuzzer.Probe: "Fuzzing",
|
|
|
|
fuzzedWithSwiftLibFuzzer.Probe: "Fuzzing",
|
|
|
|
fuzzedWithRustCargofuzz.Probe: "Fuzzing",
|
|
|
|
fuzzedWithJavaJazzerFuzzer.Probe: "Fuzzing",
|
|
|
|
fuzzedWithClusterFuzzLite.Probe: "Fuzzing",
|
|
|
|
fuzzedWithPropertyBasedHaskell.Probe: "Fuzzing",
|
|
|
|
fuzzedWithPropertyBasedTypescript.Probe: "Fuzzing",
|
|
|
|
fuzzedWithPropertyBasedJavascript.Probe: "Fuzzing",
|
|
|
|
packagedWithAutomatedWorkflow.Probe: "Packaging",
|
|
|
|
hasLicenseFile.Probe: "License",
|
|
|
|
hasFSFOrOSIApprovedLicense.Probe: "License",
|
|
|
|
hasLicenseFileAtTopDir.Probe: "License",
|
|
|
|
contributorsFromOrgOrCompany.Probe: "Contributors",
|
|
|
|
hasOSVVulnerabilities.Probe: "Vulnerabilities",
|
|
|
|
sastToolCodeQLInstalled.Probe: "SAST",
|
|
|
|
sastToolRunsOnAllCommits.Probe: "SAST",
|
|
|
|
sastToolSonarInstalled.Probe: "SAST",
|
|
|
|
hasDangerousWorkflowScriptInjection.Probe: "Dangerous-Workflow",
|
|
|
|
hasDangerousWorkflowUntrustedCheckout.Probe: "Dangerous-Workflow",
|
|
|
|
notArchived.Probe: "Maintained",
|
|
|
|
hasRecentCommits.Probe: "Maintained",
|
|
|
|
issueActivityByProjectMember.Probe: "Maintained",
|
|
|
|
notCreatedRecently.Probe: "Maintained",
|
|
|
|
}
|
|
|
|
|
|
|
|
errProbeNotFound = errors.New("probe not found")
|
2023-05-23 04:13:24 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
//nolint:gochecknoinits
|
|
|
|
func init() {
|
|
|
|
All = concatMultipleProbes([][]ProbeImpl{
|
|
|
|
DependencyToolUpdates,
|
2023-08-04 07:52:15 +03:00
|
|
|
SecurityPolicy,
|
2023-08-21 20:50:20 +03:00
|
|
|
Fuzzing,
|
2023-10-24 21:48:41 +03:00
|
|
|
License,
|
2023-10-25 00:02:18 +03:00
|
|
|
Contributors,
|
2023-05-23 04:13:24 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-12-12 20:38:50 +03:00
|
|
|
func GetProbeRunner(probeName string) (func(*checker.RawResults) ([]finding.Finding, string, error), error) {
|
|
|
|
if runner, ok := probeRunners[probeName]; ok {
|
|
|
|
return runner, nil
|
|
|
|
}
|
|
|
|
return nil, errProbeNotFound
|
|
|
|
}
|
|
|
|
|
2023-05-23 04:13:24 +03:00
|
|
|
func concatMultipleProbes(slices [][]ProbeImpl) []ProbeImpl {
|
|
|
|
var totalLen int
|
|
|
|
for _, s := range slices {
|
|
|
|
totalLen += len(s)
|
|
|
|
}
|
|
|
|
tmp := make([]ProbeImpl, 0, totalLen)
|
|
|
|
for _, s := range slices {
|
|
|
|
tmp = append(tmp, s...)
|
|
|
|
}
|
|
|
|
return tmp
|
|
|
|
}
|