mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-21 05:57:42 +03:00
47e04c102a
* Convert SAST checks to probes Signed-off-by: AdamKorcz <adam@adalogics.com> * Update checks/evaluation/sast.go Co-authored-by: Raghav Kaul <8695110+raghavkaul@users.noreply.github.com> Signed-off-by: AdamKorcz <44787359+AdamKorcz@users.noreply.github.com> * preserve file info when logging positive Sonar findings Signed-off-by: AdamKorcz <adam@adalogics.com> * rebase Signed-off-by: AdamKorcz <adam@adalogics.com> * Remove warning logging Signed-off-by: AdamKorcz <adam@adalogics.com> * add outcome and message to finding on the same line Signed-off-by: AdamKorcz <adam@adalogics.com> * codeql workflow -> codeql action Signed-off-by: AdamKorcz <adam@adalogics.com> * 'the Sonar' -> 'Sonar' in probe def.yml Signed-off-by: AdamKorcz <adam@adalogics.com> * fix typo Signed-off-by: AdamKorcz <adam@adalogics.com> * Change how probe creates location Signed-off-by: AdamKorcz <adam@adalogics.com> * Change names of values Signed-off-by: AdamKorcz <adam@adalogics.com> * change 'SAST tool detected: xx' to 'SAST tool installed: xx' Signed-off-by: AdamKorcz <adam@adalogics.com> * make text in probe def.yml easier to read Signed-off-by: AdamKorcz <adam@adalogics.com> * Change 'to' to 'two' Signed-off-by: AdamKorcz <adam@adalogics.com> * Minor change Signed-off-by: AdamKorcz <adam@adalogics.com> --------- Signed-off-by: AdamKorcz <adam@adalogics.com> Signed-off-by: AdamKorcz <44787359+AdamKorcz@users.noreply.github.com> Co-authored-by: Raghav Kaul <8695110+raghavkaul@users.noreply.github.com>
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
// Copyright 2020 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 checks
|
|
|
|
import (
|
|
"github.com/ossf/scorecard/v4/checker"
|
|
"github.com/ossf/scorecard/v4/checks/evaluation"
|
|
"github.com/ossf/scorecard/v4/checks/raw"
|
|
sce "github.com/ossf/scorecard/v4/errors"
|
|
"github.com/ossf/scorecard/v4/probes"
|
|
"github.com/ossf/scorecard/v4/probes/zrunner"
|
|
)
|
|
|
|
// CheckSAST is the registered name for SAST.
|
|
const CheckSAST = "SAST"
|
|
|
|
//nolint:gochecknoinits
|
|
func init() {
|
|
if err := registerCheck(CheckSAST, SAST, nil); err != nil {
|
|
// This should never happen.
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// SAST runs SAST check.
|
|
func SAST(c *checker.CheckRequest) checker.CheckResult {
|
|
rawData, err := raw.SAST(c)
|
|
if err != nil {
|
|
e := sce.WithMessage(sce.ErrScorecardInternal, err.Error())
|
|
return checker.CreateRuntimeErrorResult(CheckSAST, e)
|
|
}
|
|
|
|
// Set the raw results.
|
|
pRawResults := getRawResults(c)
|
|
pRawResults.SASTResults = rawData
|
|
|
|
// Evaluate the probes.
|
|
findings, err := zrunner.Run(pRawResults, probes.SAST)
|
|
if err != nil {
|
|
e := sce.WithMessage(sce.ErrScorecardInternal, err.Error())
|
|
return checker.CreateRuntimeErrorResult(CheckSAST, e)
|
|
}
|
|
|
|
// Return the score evaluation.
|
|
return evaluation.SAST(CheckSAST, findings, c.Dlogger)
|
|
}
|