2022-12-02 02:08:48 +03:00
|
|
|
// Copyright 2020 OpenSSF Scorecard Authors
|
2021-01-15 19:29:07 +03:00
|
|
|
//
|
|
|
|
// 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 (
|
2022-01-12 22:49:01 +03:00
|
|
|
"github.com/ossf/scorecard/v4/checker"
|
2022-06-01 19:41:20 +03:00
|
|
|
"github.com/ossf/scorecard/v4/checks/evaluation"
|
:sparkles: Enable gitlab Packaging Reporting (#2941)
* feat: Added yaml file that contains the full, flattened gitlab ci/cd contents
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated to meet linting failures
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated filename for flattened gitlab
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated to include the generated, flattened ci yaml in the file listing
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated the apiFunction to be part of the handler
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Moved packaging collection to be a repoClient specific sub-package
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* feat: Added path for gitlab projects, including a basic search for lines containing nuget, poetry, twine publishes
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* test: Added tests for gitlab packaging finders
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* test: Added more tests for parsing through the client and grouping packaging data
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Utilizing existing mock objects to prevent race condition exception
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Addressed linting errors
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* test: Updated expectation for log message
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Reverted back to the original error
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
---------
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
Co-authored-by: raghavkaul <8695110+raghavkaul@users.noreply.github.com>
2023-05-08 20:20:12 +03:00
|
|
|
"github.com/ossf/scorecard/v4/checks/raw/github"
|
|
|
|
"github.com/ossf/scorecard/v4/checks/raw/gitlab"
|
|
|
|
"github.com/ossf/scorecard/v4/clients/githubrepo"
|
|
|
|
"github.com/ossf/scorecard/v4/clients/gitlabrepo"
|
2022-01-12 22:49:01 +03:00
|
|
|
sce "github.com/ossf/scorecard/v4/errors"
|
2023-10-24 22:12:05 +03:00
|
|
|
"github.com/ossf/scorecard/v4/probes"
|
|
|
|
"github.com/ossf/scorecard/v4/probes/zrunner"
|
2021-01-15 19:29:07 +03:00
|
|
|
)
|
|
|
|
|
2021-05-28 00:54:34 +03:00
|
|
|
// CheckPackaging is the registered name for Packaging.
|
|
|
|
const CheckPackaging = "Packaging"
|
2021-04-10 15:26:56 +03:00
|
|
|
|
2021-05-22 20:19:52 +03:00
|
|
|
//nolint:gochecknoinits
|
2021-01-15 19:29:07 +03:00
|
|
|
func init() {
|
2022-02-08 03:49:49 +03:00
|
|
|
if err := registerCheck(CheckPackaging, Packaging, nil); err != nil {
|
2022-01-13 01:14:18 +03:00
|
|
|
// this should never happen
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-01-15 19:29:07 +03:00
|
|
|
}
|
|
|
|
|
2021-08-01 01:31:34 +03:00
|
|
|
// Packaging runs Packaging check.
|
2021-04-19 22:18:34 +03:00
|
|
|
func Packaging(c *checker.CheckRequest) checker.CheckResult {
|
:sparkles: Enable gitlab Packaging Reporting (#2941)
* feat: Added yaml file that contains the full, flattened gitlab ci/cd contents
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated to meet linting failures
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated filename for flattened gitlab
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated to include the generated, flattened ci yaml in the file listing
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Updated the apiFunction to be part of the handler
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Moved packaging collection to be a repoClient specific sub-package
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* feat: Added path for gitlab projects, including a basic search for lines containing nuget, poetry, twine publishes
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* test: Added tests for gitlab packaging finders
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* test: Added more tests for parsing through the client and grouping packaging data
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Utilizing existing mock objects to prevent race condition exception
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Addressed linting errors
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* test: Updated expectation for log message
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
* refactor: Reverted back to the original error
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
---------
Signed-off-by: Robison, Jim B <jim.b.robison@lmco.com>
Co-authored-by: raghavkaul <8695110+raghavkaul@users.noreply.github.com>
2023-05-08 20:20:12 +03:00
|
|
|
var rawData checker.PackagingData
|
|
|
|
var err error
|
|
|
|
|
|
|
|
switch v := c.RepoClient.(type) {
|
|
|
|
case *githubrepo.Client:
|
|
|
|
rawData, err = github.Packaging(c)
|
|
|
|
case *gitlabrepo.Client:
|
|
|
|
rawData, err = gitlab.Packaging(c)
|
|
|
|
default:
|
|
|
|
_ = v
|
|
|
|
}
|
|
|
|
|
2021-01-15 19:29:07 +03:00
|
|
|
if err != nil {
|
2022-06-01 19:41:20 +03:00
|
|
|
e := sce.WithMessage(sce.ErrScorecardInternal, err.Error())
|
2021-07-21 23:40:16 +03:00
|
|
|
return checker.CreateRuntimeErrorResult(CheckPackaging, e)
|
2021-01-15 19:29:07 +03:00
|
|
|
}
|
|
|
|
|
2023-10-24 22:12:05 +03:00
|
|
|
pRawResults := getRawResults(c)
|
|
|
|
pRawResults.PackagingResults = rawData
|
|
|
|
|
|
|
|
findings, err := zrunner.Run(pRawResults, probes.Packaging)
|
|
|
|
if err != nil {
|
|
|
|
e := sce.WithMessage(sce.ErrScorecardInternal, err.Error())
|
|
|
|
return checker.CreateRuntimeErrorResult(CheckPackaging, e)
|
2021-01-15 19:29:07 +03:00
|
|
|
}
|
|
|
|
|
2023-10-24 22:12:05 +03:00
|
|
|
return evaluation.Packaging(CheckPackaging, findings, c.Dlogger)
|
2021-01-15 19:29:07 +03:00
|
|
|
}
|