2021-06-29 06:09:40 +03:00
|
|
|
// Copyright 2021 Security 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 e2e
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
2021-07-26 21:01:25 +03:00
|
|
|
"github.com/ossf/scorecard/v2/checker"
|
|
|
|
"github.com/ossf/scorecard/v2/checks"
|
2021-07-30 09:02:53 +03:00
|
|
|
"github.com/ossf/scorecard/v2/clients/githubrepo"
|
2021-07-26 21:01:25 +03:00
|
|
|
scut "github.com/ossf/scorecard/v2/utests"
|
2021-06-29 06:09:40 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("E2E TEST:Vulnerabilities", func() {
|
|
|
|
Context("E2E TEST:Validating vulnerabilities status", func() {
|
|
|
|
It("Should return that there are no vulnerabilities", func() {
|
2021-09-10 20:13:14 +03:00
|
|
|
repo, err := githubrepo.MakeGithubRepo("ossf/scorecard")
|
|
|
|
Expect(err).Should(BeNil())
|
2021-09-02 05:32:26 +03:00
|
|
|
repoClient := githubrepo.CreateGithubRepoClient(context.Background(), logger)
|
2021-09-10 20:13:14 +03:00
|
|
|
err = repoClient.InitRepo(repo)
|
2021-07-30 09:02:53 +03:00
|
|
|
Expect(err).Should(BeNil())
|
|
|
|
|
2021-07-21 23:40:16 +03:00
|
|
|
dl := scut.TestDetailLogger{}
|
|
|
|
req := checker.CheckRequest{
|
2021-09-02 05:32:26 +03:00
|
|
|
Ctx: context.Background(),
|
|
|
|
RepoClient: repoClient,
|
2021-09-10 20:13:14 +03:00
|
|
|
Repo: repo,
|
2021-09-02 05:32:26 +03:00
|
|
|
Dlogger: &dl,
|
2021-06-29 06:09:40 +03:00
|
|
|
}
|
2021-07-21 23:40:16 +03:00
|
|
|
expected := scut.TestReturn{
|
2021-08-31 00:12:57 +03:00
|
|
|
Error: nil,
|
2021-07-21 23:40:16 +03:00
|
|
|
Score: checker.MaxResultScore,
|
|
|
|
NumberOfWarn: 0,
|
|
|
|
NumberOfInfo: 0,
|
|
|
|
NumberOfDebug: 0,
|
|
|
|
}
|
|
|
|
result := checks.HasUnfixedVulnerabilities(&req)
|
|
|
|
// UPGRADEv2: to remove.
|
|
|
|
// Old version.
|
2021-06-29 06:09:40 +03:00
|
|
|
Expect(result.Error).Should(BeNil())
|
|
|
|
Expect(result.Pass).Should(BeTrue())
|
2021-07-21 23:40:16 +03:00
|
|
|
// New version.
|
|
|
|
Expect(scut.ValidateTestReturn(nil, "no osv vulnerabilities", &expected, &result, &dl)).Should(BeTrue())
|
2021-06-29 06:09:40 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Should return that there are vulnerabilities", func() {
|
2021-09-10 20:13:14 +03:00
|
|
|
repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-vulnerabilities-open62541")
|
|
|
|
Expect(err).Should(BeNil())
|
2021-09-02 05:32:26 +03:00
|
|
|
repoClient := githubrepo.CreateGithubRepoClient(context.Background(), logger)
|
2021-09-10 20:13:14 +03:00
|
|
|
err = repoClient.InitRepo(repo)
|
2021-07-30 09:02:53 +03:00
|
|
|
Expect(err).Should(BeNil())
|
|
|
|
|
2021-07-21 23:40:16 +03:00
|
|
|
dl := scut.TestDetailLogger{}
|
2021-06-29 06:09:40 +03:00
|
|
|
checkRequest := checker.CheckRequest{
|
2021-09-02 05:32:26 +03:00
|
|
|
Ctx: context.Background(),
|
|
|
|
RepoClient: repoClient,
|
2021-09-10 20:13:14 +03:00
|
|
|
Repo: repo,
|
2021-09-02 05:32:26 +03:00
|
|
|
Dlogger: &dl,
|
2021-07-21 23:40:16 +03:00
|
|
|
}
|
|
|
|
expected := scut.TestReturn{
|
2021-08-31 00:12:57 +03:00
|
|
|
Error: nil,
|
2021-07-21 23:40:16 +03:00
|
|
|
Score: checker.MinResultScore,
|
|
|
|
NumberOfWarn: 1,
|
|
|
|
NumberOfInfo: 0,
|
|
|
|
NumberOfDebug: 0,
|
2021-06-29 06:09:40 +03:00
|
|
|
}
|
|
|
|
result := checks.HasUnfixedVulnerabilities(&checkRequest)
|
2021-07-21 23:40:16 +03:00
|
|
|
// UPGRADEv2: to remove.
|
|
|
|
// Old version.
|
2021-06-29 06:09:40 +03:00
|
|
|
Expect(result.Error).Should(BeNil())
|
|
|
|
Expect(result.Pass).Should(BeFalse())
|
2021-07-21 23:40:16 +03:00
|
|
|
// New version.
|
|
|
|
Expect(scut.ValidateTestReturn(nil, "osv vulnerabilities", &expected, &result, &dl)).Should(BeTrue())
|
2021-06-29 06:09:40 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|