cosign(install): verify binary signature with keyless verification bundle

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-12-16 11:46:22 +01:00
parent 5e6dd63795
commit 44e7279490
4 changed files with 52 additions and 10 deletions

View File

@@ -27,7 +27,10 @@ describe('download', () => {
'install cosign %s', async (version) => {
await expect((async () => {
const install = new Install();
const toolPath = await install.download(version);
const toolPath = await install.download({
version: version,
verifySignature: true
});
if (!fs.existsSync(toolPath)) {
throw new Error('toolPath does not exist');
}

View File

@@ -38,7 +38,7 @@ describe('download', () => {
])(
'acquires %p of cosign', async (version) => {
const install = new Install();
const toolPath = await install.download(version);
const toolPath = await install.download({version});
expect(fs.existsSync(toolPath)).toBe(true);
const cosignBin = await install.install(toolPath, tmpDir);
expect(fs.existsSync(cosignBin)).toBe(true);
@@ -52,7 +52,7 @@ describe('download', () => {
])(
'acquires %p of cosign with cache', async (version) => {
const install = new Install();
const toolPath = await install.download(version);
const toolPath = await install.download({version});
expect(fs.existsSync(toolPath)).toBe(true);
}, 100000);
@@ -63,7 +63,10 @@ describe('download', () => {
])(
'acquires %p of cosign without cache', async (version) => {
const install = new Install();
const toolPath = await install.download(version, true);
const toolPath = await install.download({
version: version,
ghaNoCache: true
});
expect(fs.existsSync(toolPath)).toBe(true);
}, 100000);
@@ -80,7 +83,9 @@ describe('download', () => {
jest.spyOn(osm, 'platform').mockImplementation(() => os as NodeJS.Platform);
jest.spyOn(osm, 'arch').mockImplementation(() => arch);
const install = new Install();
const cosignBin = await install.download('latest');
const cosignBin = await install.download({
version: 'latest'
});
expect(fs.existsSync(cosignBin)).toBe(true);
}, 100000);
});

View File

@@ -30,7 +30,9 @@ jest.unmock('@actions/github');
beforeAll(async () => {
const cosignInstall = new CosignInstall();
const cosignBinPath = await cosignInstall.download('v3.0.2', true);
const cosignBinPath = await cosignInstall.download({
version: 'v3.0.2'
});
await cosignInstall.install(cosignBinPath);
}, 100000);