File tree 2 files changed +31
-2
lines changed
2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,19 @@ const npmChange: Change = {
22
22
]
23
23
}
24
24
25
+ const actionsChange : Change = {
26
+ manifest : 'workflow.yml' ,
27
+ change_type : 'added' ,
28
+ ecosystem : 'actions' ,
29
+ name : 'actions/checkout' ,
30
+ version : 'v3' ,
31
+ package_url : 'pkg:githubactions/actions@v3' ,
32
+ license : 'MIT' ,
33
+ source_repository_url : 'null' ,
34
+ scope : 'runtime' ,
35
+ vulnerabilities : [ ]
36
+ }
37
+
25
38
test ( 'Get scorecard from API' , async ( ) => {
26
39
const changes : Changes = [ npmChange ]
27
40
const scorecard = await getScorecardLevels ( changes )
@@ -38,3 +51,11 @@ test('Get project URL from deps.dev API', async () => {
38
51
)
39
52
expect ( result ) . not . toBeNull ( )
40
53
} )
54
+
55
+ test ( 'Handles Actions special case' , async ( ) => {
56
+ const changes : Changes = [ actionsChange ]
57
+ const result = await getScorecardLevels ( changes )
58
+ expect ( result ) . not . toBeNull ( )
59
+ expect ( result . dependencies ) . toHaveLength ( 1 )
60
+ expect ( result . dependencies [ 0 ] . scorecard ?. score ) . toBeGreaterThan ( 0 )
61
+ } )
Original file line number Diff line number Diff line change @@ -17,8 +17,16 @@ export async function getScorecardLevels(
17
17
repositoryUrl = repositoryUrl . replace ( 'https://' , '' )
18
18
}
19
19
20
+ // Handle the special case for GitHub Actions, where the repository URL is null
21
+ if ( ecosystem === 'actions' ) {
22
+ // The package name for GitHub Actions in the API is in the format `owner/repo/`, so we can use that to get the repository URL
23
+ // If the package name has more than 2 slashes, it's referencing a sub-action, and we need to strip the last part out
24
+ const parts = packageName . split ( '/' )
25
+ repositoryUrl = `github.com/${ parts [ 0 ] } /${ parts [ 1 ] } ` // e.g. github.com/actions/checkout
26
+ }
27
+
20
28
// If GitHub API doesn't have the repository URL, query deps.dev for it.
21
- if ( repositoryUrl ) {
29
+ if ( ! repositoryUrl ) {
22
30
// Call the deps.dev API to get the repository URL from there
23
31
repositoryUrl = await getProjectUrl ( ecosystem , packageName , version )
24
32
}
@@ -70,4 +78,4 @@ export async function getProjectUrl(
70
78
}
71
79
}
72
80
return ''
73
- }
81
+ }
You can’t perform that action at this time.
0 commit comments