Skip to content

Commit a6b5687

Browse files
committed
🌱 New check: Mean time to update dependencies
Signed-off-by: Adam Korczynski <[email protected]>
1 parent 488797d commit a6b5687

32 files changed

+5299
-20
lines changed

checker/raw_result.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type RawResults struct {
4040
SBOMResults SBOMData
4141
MaintainedResults MaintainedData
4242
Metadata MetadataData
43+
MTTUDependenciesResults MTTUDependenciesData
4344
PackagingResults PackagingData
4445
PinningDependenciesResults PinningDependenciesData
4546
SASTResults SASTData
@@ -302,6 +303,36 @@ type SecurityPolicyData struct {
302303
PolicyFiles []SecurityPolicyFile
303304
}
304305

306+
type MTTUDependenciesData struct {
307+
Dependencies []LockDependency
308+
}
309+
310+
// Ecosystem represents the ecosystem of a dependency.
311+
type Ecosystem string
312+
313+
const (
314+
EcosystemCargo Ecosystem = "CARGO"
315+
EcosystemGo Ecosystem = "GO"
316+
EcosystemMaven Ecosystem = "MAVEN"
317+
EcosystemNPM Ecosystem = "NPM"
318+
EcosystemNuget Ecosystem = "NUGET"
319+
EcosystemPypi Ecosystem = "PYPI"
320+
EcosystemRubyGems Ecosystem = "RUBYGEMS"
321+
)
322+
323+
func (e Ecosystem) String() string {
324+
return string(e)
325+
}
326+
327+
type LockDependency struct {
328+
TimeSinceOldestReleast time.Time
329+
IsLatest *bool
330+
Name string
331+
Version string
332+
Comparator string
333+
Ecosystem Ecosystem
334+
}
335+
305336
// BinaryArtifactData contains the raw results
306337
// for the Binary-Artifact check.
307338
type BinaryArtifactData struct {

checks/MTTUDependencies.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2025 OpenSSF Scorecard Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package checks
16+
17+
import (
18+
"github.com/ossf/scorecard/v5/checker"
19+
"github.com/ossf/scorecard/v5/checks/evaluation"
20+
"github.com/ossf/scorecard/v5/checks/raw"
21+
sce "github.com/ossf/scorecard/v5/errors"
22+
"github.com/ossf/scorecard/v5/probes"
23+
zrunner "github.com/ossf/scorecard/v5/probes/zrunner"
24+
)
25+
26+
const CheckMTTUDependencies = "MTTUDependencies"
27+
28+
//nolint:gochecknoinits
29+
func init() {
30+
supportedRequestTypes := []checker.RequestType{
31+
checker.FileBased,
32+
}
33+
if err := registerCheck(CheckMTTUDependencies, MTTUDependencies, supportedRequestTypes); err != nil {
34+
// this should never happen
35+
panic(err)
36+
}
37+
}
38+
39+
// indirections to ease testing.
40+
var runProbes = zrunner.Run
41+
42+
func MTTUDependencies(c *checker.CheckRequest) checker.CheckResult {
43+
// 1) get raw data
44+
rawData, err := raw.MTTUDependencies(c)
45+
if err != nil {
46+
e := sce.WithMessage(sce.ErrScorecardInternal, err.Error())
47+
return checker.CreateRuntimeErrorResult(CheckMTTUDependencies, e)
48+
}
49+
50+
// 2) set raw results
51+
pRawResults := getRawResults(c)
52+
pRawResults.MTTUDependenciesResults = rawData
53+
54+
// 3) run probes
55+
findings, err := runProbes(pRawResults, probes.MTTUDependencies)
56+
if err != nil {
57+
e := sce.WithMessage(sce.ErrScorecardInternal, err.Error())
58+
return checker.CreateRuntimeErrorResult(CheckMTTUDependencies, e)
59+
}
60+
61+
// 4) evaluate
62+
ret := evaluation.MTTUDependencies(CheckMTTUDependencies, findings, c.Dlogger)
63+
return ret
64+
}

0 commit comments

Comments
 (0)