@@ -4,11 +4,11 @@ import { test } from "tap";
4
4
import * as plugin from "../../lib" ;
5
5
6
6
function getFixture ( fixturePath ) : string {
7
- return path . join ( __dirname , "../fixtures/docker-archives " , fixturePath ) ;
7
+ return path . join ( __dirname , "../fixtures" , fixturePath ) ;
8
8
}
9
9
10
10
test ( "docker-archive image type can be scanned" , async ( t ) => {
11
- const fixturePath = getFixture ( "docker-save/nginx.tar" ) ;
11
+ const fixturePath = getFixture ( "docker-archives/docker- save/nginx.tar" ) ;
12
12
const imageNameAndTag = `docker-archive:${ fixturePath } ` ;
13
13
14
14
const dockerfile = undefined ;
@@ -83,6 +83,58 @@ test("docker-archive image type throws on bad files", async (t) => {
83
83
) ;
84
84
} ) ;
85
85
86
+ test ( "oci-archive image type can be scanned" , async ( t ) => {
87
+ const fixturePath = getFixture ( "oci-archives/alpine-3.12.0.tar" ) ;
88
+ const imageNameAndTag = `oci-archive:${ fixturePath } ` ;
89
+
90
+ const dockerfile = undefined ;
91
+ const pluginOptions = {
92
+ experimental : true ,
93
+ } ;
94
+
95
+ const pluginResult = await plugin . inspect (
96
+ imageNameAndTag ,
97
+ dockerfile ,
98
+ pluginOptions ,
99
+ ) ;
100
+
101
+ t . same (
102
+ pluginResult . scannedProjects [ 0 ] . depTree . name ,
103
+ "docker-image|alpine-3.12.0.tar" ,
104
+ "Image name matches" ,
105
+ ) ;
106
+ t . same (
107
+ pluginResult . scannedProjects [ 0 ] . depTree . version ,
108
+ "" ,
109
+ "Version must be empty" ,
110
+ ) ;
111
+ t . same (
112
+ pluginResult . plugin . dockerImageId ,
113
+ "sha256:0f5f445df8ccbd8a062ad3d02d459e8549d9998c62a5b7cbf77baf68aa73bf5b" ,
114
+ "The image ID matches" ,
115
+ ) ;
116
+ t . same (
117
+ pluginResult . plugin . packageManager ,
118
+ "apk" ,
119
+ "Correct package manager detected" ,
120
+ ) ;
121
+ t . ok (
122
+ pluginResult . scannedProjects [ 0 ] . depTree . dependencies &&
123
+ "alpine-keys/alpine-keys" in
124
+ pluginResult . scannedProjects [ 0 ] . depTree . dependencies ,
125
+ "Contains some expected dependency" ,
126
+ ) ;
127
+ t . deepEqual (
128
+ pluginResult . plugin . imageLayers ,
129
+ [
130
+ path . normalize (
131
+ "sha256:df20fa9351a15782c64e6dddb2d4a6f50bf6d3688060a34c4014b0d9a752eb4c" ,
132
+ ) ,
133
+ ] ,
134
+ "Layers are read correctly" ,
135
+ ) ;
136
+ } ) ;
137
+
86
138
test ( "static scan for Identifier type image (nginx:1.19.0)" , async ( t ) => {
87
139
const imageNameAndTag = `nginx:1.19.0` ;
88
140
const dockerfile = undefined ;
0 commit comments